Unverified Commit f6660bb0 authored by sternenseemann's avatar sternenseemann Committed by Wolfgang Walther
Browse files

haskell.compiler.*: only set LANG if necessary

Our theory is that only sphinx and haddock need a working locale on
the build platform. We should actually put this into practice so our
understanding matches our build instructions.

(cherry picked from commit 22aa9763)
parent 2877c554
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -345,6 +345,10 @@ let
  # TODO(@Ericson2314) Make unconditional
  targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";

  # TODO(@sternenseemann): there's no stage0:exe:haddock target by default,
  # so haddock isn't available for GHC cross-compilers. Can we fix that?
  hasHaddock = stdenv.hostPlatform == stdenv.targetPlatform;

  hadrianSettings =
    # -fexternal-dynamic-refs apparently (because it's not clear from the
    # documentation) makes the GHC RTS able to load static libraries, which may
@@ -497,9 +501,6 @@ stdenv.mkDerivation (
      patchShebangs --build .
    '';

    # GHC needs the locale configured during the Haddock phase.
    LANG = "en_US.UTF-8";

    # GHC is a bit confused on its cross terminology.
    # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
    preConfigure = ''
@@ -550,9 +551,15 @@ stdenv.mkDerivation (
          "${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
      }"
    ''
    # Haddock and sphinx need a working locale
    + lib.optionalString (enableDocs || hasHaddock) (
      ''
        export LANG="en_US.UTF-8"
      ''
      + 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}"
    ''
@@ -856,14 +863,11 @@ stdenv.mkDerivation (

      inherit llvmPackages;
      inherit enableShared;
      inherit hasHaddock;

      # Expose hadrian used for bootstrapping, for debugging purposes
      inherit hadrian;

      # TODO(@sternenseemann): there's no stage0:exe:haddock target by default,
      # so haddock isn't available for GHC cross-compilers. Can we fix that?
      hasHaddock = stdenv.hostPlatform == stdenv.targetPlatform;

      bootstrapAvailable = lib.meta.availableOn stdenv.buildPlatform bootPkgs.ghc;
    };

+9 −6
Original line number Diff line number Diff line
@@ -378,9 +378,6 @@ stdenv.mkDerivation (

    postPatch = "patchShebangs .";

    # GHC needs the locale configured during the Haddock phase.
    LANG = "en_US.UTF-8";

    # GHC is a bit confused on its cross terminology.
    # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
    preConfigure = ''
@@ -435,9 +432,15 @@ stdenv.mkDerivation (
      echo -n "${buildMK}" > mk/build.mk
      sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
    ''
    # Haddock and sphinx need a working locale
    + lib.optionalString (enableDocs || enableHaddockProgram) (
      ''
        export LANG="en_US.UTF-8"
      ''
      + 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}"
    ''