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-04 16:18:02 -05:00
parent 8560c025bc
commit 81553124cf
4 changed files with 47 additions and 32 deletions

View File

@@ -1,4 +1,5 @@
{ pkgs, stdenv, lib, haskellLib, ghc, all-cabal-hashes
, buildHaskellPackages
, compilerConfig ? (self: super: {})
, packageSetConfig ? (self: super: {})
, overrides ? (self: super: {})
@@ -14,7 +15,7 @@ let
haskellPackages = pkgs.callPackage makePackageSet {
package-set = initialPackages;
inherit stdenv haskellLib ghc extensible-self;
inherit stdenv haskellLib ghc buildHaskellPackages extensible-self;
};
commonConfiguration = configurationCommon { inherit pkgs haskellLib; };

View File

@@ -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
'';

View File

@@ -4,6 +4,10 @@
{ # package-set used for build tools (all of nixpkgs)
buildPackages
, # A haskell package set for Setup.hs, compiler plugins, and similar
# build-time uses.
buildHaskellPackages
, # package-set used for non-haskell dependencies (all of nixpkgs)
pkgs
@@ -18,8 +22,8 @@
, # compiler to use
ghc
, # A function that takes `{ pkgs, stdenv, callPackage }` as the first arg and `self`
# as second, and returns a set of haskell packages
, # A function that takes `{ pkgs, stdenv, callPackage }` as the first arg and
# `self` as second, and returns a set of haskell packages
package-set
, # The final, fully overriden package set usable with the nixpkgs fixpoint
@@ -36,15 +40,12 @@ let
inherit (stdenv.lib) fix' extends makeOverridable;
inherit (haskellLib) overrideCabal;
buildHaskellPackages = if hostPlatform != buildPlatform
then self.ghc.bootPkgs
else self;
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
inherit stdenv;
nodejs = buildPackages.nodejs-slim;
inherit (buildHaskellPackages) jailbreak-cabal;
inherit buildHaskellPackages;
inherit (self) ghc;
inherit (buildHaskellPackages) jailbreak-cabal;
hscolour = overrideCabal buildHaskellPackages.hscolour (drv: {
isLibrary = false;
doHaddock = false;