haskell.compiler.*: locales are required for build not host

The commit adding LOCALE_ARCHIVE, 8a21e02e31, cites haddock
generation which happens during the build and on the build platform.
As it turns out, the user guide also depends on locales because
sphinx tries to set a locale during execution.

This should fix cross compiling ghc from glibc to non glibc, e.g.

  x86_64-pc-linux-gnu -> aarch64-unknown-linux-musl
This commit is contained in:
sternenseemann
2025-09-09 15:11:41 +02:00
parent c09f4121f2
commit e7627649cd
2 changed files with 4 additions and 6 deletions
@@ -36,7 +36,6 @@
libiconv ? null,
ncurses,
glibcLocales ? null,
# GHC can be built with system libffi or a bundled one.
libffi ? null,
@@ -549,8 +548,8 @@ stdenv.mkDerivation (
"${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
}"
''
+ lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
+ lib.optionalString (stdenv.buildPlatform.libc == "glibc") ''
export LOCALE_ARCHIVE="${buildPackages.glibcLocales}/lib/locale/locale-archive"
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
@@ -29,7 +29,6 @@
libiconv ? null,
ncurses,
glibcLocales ? null,
# GHC can be built with system libffi or a bundled one.
libffi ? null,
@@ -436,8 +435,8 @@ stdenv.mkDerivation (
echo -n "${buildMK}" > mk/build.mk
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
''
+ lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
+ lib.optionalString (stdenv.buildPlatform.libc == "glibc") ''
export LOCALE_ARCHIVE="${buildPackages.glibcLocales}/lib/locale/locale-archive"
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"