From 097aff7affd0d4bc909797468a1455fcade840de Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Thu, 19 Sep 2024 13:09:46 +0200 Subject: [PATCH] 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. --- pkgs/development/compilers/ghc/8.10.7.nix | 11 ++++++----- pkgs/development/compilers/ghc/common-hadrian.nix | 11 ++++++----- .../compilers/ghc/common-make-native-bignum.nix | 11 ++++++----- pkgs/top-level/haskell-packages.nix | 12 +++++++++++- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 1b6bb9ffa925..4a973b000672 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -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 { diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index f97c355593cc..2b3dd4ff4985 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -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; diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index d028d4535aec..f92bba3f5b5a 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -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 { diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 168a1baaf851..ae8eb3f1d6cc 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -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