haskell infra: nativeGhc != ghc.bootPkgs.ghc

There's no reason to wait for non-binary native to *build* cross ghc,
but we want a nix-built GHC for Setup.hs or things won't work.
This commit is contained in:
John Ericson
2018-01-21 23:31:04 -05:00
parent 8560c025bc
commit 81553124cf
4 changed files with 47 additions and 32 deletions
@@ -1,4 +1,4 @@
{ stdenv, buildPackages, ghc
{ stdenv, buildPackages, buildHaskellPackages, ghc
, jailbreak-cabal, hscolour, cpphs, nodejs
, buildPlatform, hostPlatform
}:
@@ -81,7 +81,11 @@ let
then "package-db"
else "package-conf";
nativeGhc = if isCross || isGhcjs then ghc.bootPkgs.ghc else ghc;
# GHC used for building Setup.hs
#
# Same as our GHC, unless we're cross, in which case it is native GHC with the
# same version, or ghcjs, in which case its the ghc used to build ghcjs.
nativeGhc = buildHaskellPackages.ghc;
nativePackageDbFlag = if versionOlder "7.6" nativeGhc.version
then "package-db"
else "package-conf";
@@ -147,8 +151,7 @@ let
] ++ crossCabalFlags);
setupCompileFlags = [
(optionalString (!coreSetup) "-${packageDbFlag}=$packageConfDir")
(optionalString isGhcjs "-build-runner")
(optionalString (!coreSetup) "-${nativePackageDbFlag}=$packageConfDir")
(optionalString (isGhcjs || isHaLVM || versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES")
# https://github.com/haskell/cabal/issues/2398
(optionalString (versionOlder "7.10" ghc.version && !isHaLVM) "-threaded")
@@ -160,14 +163,12 @@ let
allPkgconfigDepends = pkgconfigDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++
optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
nativeBuildInputs = [ ghc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++
nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++
buildTools ++ libraryToolDepends ++ executableToolDepends;
propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends;
otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++
optionals (allPkgconfigDepends != []) allPkgconfigDepends ++
optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++
# ghcjs's hsc2hs calls out to the native hsc2hs
optional isGhcjs nativeGhc ++
optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends);
allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;
@@ -176,12 +177,14 @@ let
ghcEnv = ghc.withPackages (p: haskellBuildInputs);
setupBuilder = if isCross then "${nativeGhc}/bin/ghc" else ghcCommand;
setupCommand = "./Setup";
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
ghcCommandCaps= toUpper ghcCommand';
nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
in
assert allPkgconfigDepends != [] -> pkgconfig != null;
@@ -270,7 +273,7 @@ stdenv.mkDerivation ({
done
echo setupCompileFlags: $setupCompileFlags
${setupBuilder} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
runHook postCompileBuildDriver
'';