Hi Greg,
take this with a shovel of salt as i didn't test the port or anything
with Haskell (and i'm unlikely to). So this is purely from code
inspection.
Greg Steuck wrote on Sun, Feb 02, 2020 at 10:00:06PM -0800:
> Do you believe lang/ghc/patches/patch-libraries_base_cbits_PrelIOUtils_c
> is still relevant?
It may have been OK in 2015, but it looks rather bogus now.
> I ran some test programs and both locale_charset() and
The function locale_charset() appears to be part of the converters/libiconv
package, but it appears to be totally undocumented. I failed to
find any documentation whatsoever: neither in the package nor even
with Google on the web. While iconv(3) is in POSIX, locale_charset()
is not. I think we should avoid using stuff when it is unclear
what it is, so consider forcing HAVE_LIBCHARSET to undefined in the
port (i'm not saying you must do this, only that it could be
considered).
> nl_langinfo(CODESET) yield sensible results (at least for UTF8).
And indeed, UTF-8 is the only non-POSIX charset that OpenBSD supports,
and there are no plans to support any others in the future.
Consequently, nl_langinfo(CODESET) will always return either "US-ASCII"
or "UTF-8" on OpenBSD.
> The
> history of the patch seems to go back approximately 10 years, so maybe
> OpenBSD locale support improved enough to consider dropping the patch?
I think so.
Three apsects of the patch look bogus in particular:
1. Avoiding nl_langinfo(3).
There is no longer anything wrong with that function.
2. Inspecting HS_ENCODING.
It appears the code wants to inspect the current locale.
If any environment variable, then LC_ALL/LC_CTYPE/LANG
should probably be inspected, not HS_ENCODING.
The code in the patch gives me the impression that this is
probably already done with setlocale(3) elsewehere in the
program, so i'm not sure the environment should be inspected
again.
Also, using setlocale(3) is almost always preferable to
manual inspection of environment variables.
3. Setting anything to "latin1".
Given that we don't even support that locale at all,
that's the worst of the three dubious aspects.
> I'll rebuild GHC without that patch locally but also wanted to check
> with you in the meantime.
Right, and you might also try convincing ./configure (or whatever is
used in the build system) to switch HAVE_LIBCHARSET off, unless that
has unrelated detrimental effects.
Yours,
Ingo