haskell.compiler.*: move bootPkgs.ghc to depsBuildBuild

The stage0 ghc is build->build since it builds the stage1 compiler which
has build for its host platform (i.e. is build->target relative to the
entire GHC derivation).

Also annotate a bit more around the use of pkgsBuildBuild and the boot
compiler and make it more explicit where it comes from in the
derivation.
This commit is contained in:
sternenseemann 2024-09-19 13:09:46 +02:00
parent 4903ac938b
commit 097aff7aff
4 changed files with 29 additions and 16 deletions

View File

@ -83,8 +83,6 @@ assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == std
let
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
targetPrefix = lib.optionalString
(targetPlatform != hostPlatform)
@ -427,7 +425,7 @@ stdenv.mkDerivation (rec {
nativeBuildInputs = [
perl autoreconfHook autoconf automake m4 python3
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
bootPkgs.ghc-settings-edit
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
autoSignDarwinBinariesHook
@ -435,8 +433,11 @@ stdenv.mkDerivation (rec {
sphinx
];
# Used by the STAGE0 compiler to build stage1
# Stage0 compiler and the tools/libs it needs to build Stage1. Stage0 is
# build->build, Stage1 is build->target (which may be the same as
# host->target)
depsBuildBuild = [
bootPkgs.ghc
buildCC
# stage0 builds terminfo unconditionally, so we always need ncurses
ncurses
@ -536,7 +537,7 @@ stdenv.mkDerivation (rec {
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
platforms = lib.platforms.all;
inherit (ghc.meta) license;
inherit (bootPkgs.ghc.meta) license;
};
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {

View File

@ -256,8 +256,6 @@ assert stdenv.buildPlatform == stdenv.hostPlatform;
let
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
targetPrefix = lib.optionalString
(targetPlatform != hostPlatform)
@ -544,7 +542,7 @@ stdenv.mkDerivation ({
dontAddExtraLibs = true;
nativeBuildInputs = [
perl ghc hadrian bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
perl hadrian bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
# autoconf and friends are necessary for hadrian to create the bindist
autoconf automake m4
# Python is used in a few scripts invoked by hadrian to generate e.g. rts headers.
@ -559,8 +557,11 @@ stdenv.mkDerivation ({
# For building runtime libs
depsBuildTarget = toolsForTarget;
# Used by the STAGE0 compiler to build stage1
# Stage0 compiler and the tools/libs it needs to build Stage1. Stage0 is
# build->build, Stage1 is build->target (which may be the same as
# host->target)
depsBuildBuild = [
bootPkgs.ghc
buildCC
# stage0 builds terminfo unconditionally, so we always need ncurses
ncurses
@ -699,7 +700,7 @@ stdenv.mkDerivation ({
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
platforms = lib.platforms.all;
inherit (ghc.meta) license;
inherit (bootPkgs.ghc.meta) license;
};
dontStrip = targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm;

View File

@ -88,8 +88,6 @@ assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == std
let
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
targetPrefix = lib.optionalString
(targetPlatform != hostPlatform)
@ -441,7 +439,7 @@ stdenv.mkDerivation (rec {
nativeBuildInputs = [
perl autoconf automake m4 python3
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
bootPkgs.ghc-settings-edit
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
autoSignDarwinBinariesHook
@ -453,8 +451,11 @@ stdenv.mkDerivation (rec {
xattr
];
# Used by the STAGE0 compiler to build stage1
# Stage0 compiler and the tools/libs it needs to build Stage1. Stage0 is
# build->build, Stage1 is build->target (which may be the same as
# host->target)
depsBuildBuild = [
bootPkgs.ghc
buildCC
# stage0 builds terminfo unconditionally, so we always need ncurses
ncurses
@ -554,7 +555,7 @@ stdenv.mkDerivation (rec {
] ++ lib.teams.haskell.members;
timeout = 24 * 3600;
platforms = lib.platforms.all;
inherit (ghc.meta) license;
inherit (bootPkgs.ghc.meta) license;
};
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {

View File

@ -52,7 +52,17 @@ in {
package-list = callPackage ../development/haskell-modules/package-list.nix {};
# Always get boot compilers from `pkgsBuildBuild`
# Always get boot compilers from `pkgsBuildBuild`. The boot (stage0) compiler
# is used to build another compiler (stage1) that'll be used to build the
# final compiler (stage2) (except when building a cross-compiler). This means
# that stage1's host platform is the same as stage0: build. Consequently,
# stage0 needs to be build->build.
#
# Note that we use bb.haskell.packages.*. haskell.packages.*.ghc is similar to
# stdenv: The ghc comes from the previous package set, i.e. this predicate holds:
# `name: pkgs: pkgs.haskell.packages.${name}.ghc == pkgs.buildPackages.haskell.compiler.${name}.ghc`.
# This isn't problematic since pkgsBuildBuild.buildPackages is also build->build,
# just something to keep in mind.
compiler = let bb = pkgsBuildBuild.haskell; in {
ghc865Binary = callPackage ../development/compilers/ghc/8.6.5-binary.nix {
# Should be llvmPackages_6 which has been removed from nixpkgs