wrapCC, wrapBintools: move expand-response-params bootstrapping out

The cc and bintools wrapper contained ad hoc bootstrapping logic for
expand-response-params (which was callPackage-ed in a let binding). This
lead to the strange situation that the bootstrapping logic related to
expand-response-params is split between the wrapper derivations (where
it is duplicated) and the actual stdenv bootstrapping.

To clean this up, the wrappers simply should take expand-response-params
as an ordinary input: They need an adjacent expand-response-params (i.e.
one that runs on their host platform), but don't care about the how.
Providing this is only problematic during stdenv bootstrapping where we
have to pull it from the previous stage at times.
This commit is contained in:
sternenseemann 2024-04-16 17:44:08 +02:00
parent b2a568906a
commit 7be562d046
5 changed files with 25 additions and 33 deletions

View File

@ -29,7 +29,7 @@
, isGNU ? bintools.isGNU or false , isGNU ? bintools.isGNU or false
, isLLVM ? bintools.isLLVM or false , isLLVM ? bintools.isLLVM or false
, isCCTools ? bintools.isCCTools or false , isCCTools ? bintools.isCCTools or false
, buildPackages ? {} , expand-response-params
, targetPackages ? {} , targetPackages ? {}
, useMacosReexportHack ? false , useMacosReexportHack ? false
, wrapGas ? false , wrapGas ? false
@ -132,10 +132,6 @@ let
else if hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else if hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1"
else ""; else "";
expand-response-params =
optionalString (buildPackages ? stdenv && buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null")
(import ../expand-response-params { inherit (buildPackages) stdenv; });
in in
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
@ -419,6 +415,7 @@ stdenvNoCC.mkDerivation {
env = { env = {
# for substitution in utils.bash # for substitution in utils.bash
# TODO(@sternenseemann): invent something cleaner than passing in "" in case of absence
expandResponseParams = "${expand-response-params}/bin/expand-response-params"; expandResponseParams = "${expand-response-params}/bin/expand-response-params";
# TODO(@sternenseemann): rename env var via stdenv rebuild # TODO(@sternenseemann): rename env var via stdenv rebuild
shell = (getBin runtimeShell + runtimeShell.shellPath or ""); shell = (getBin runtimeShell + runtimeShell.shellPath or "");

View File

@ -16,7 +16,7 @@
, extraTools ? [], extraPackages ? [], extraBuildCommands ? "" , extraTools ? [], extraPackages ? [], extraBuildCommands ? ""
, nixSupport ? {} , nixSupport ? {}
, isGNU ? false, isClang ? cc.isClang or false, isCcache ? cc.isCcache or false, gnugrep ? null , isGNU ? false, isClang ? cc.isClang or false, isCcache ? cc.isCcache or false, gnugrep ? null
, buildPackages ? {} , expand-response-params
, libcxx ? null , libcxx ? null
# Whether or not to add `-B` and `-L` to `nix-support/cc-{c,ld}flags` # Whether or not to add `-B` and `-L` to `nix-support/cc-{c,ld}flags`
@ -113,9 +113,6 @@ let
# unstable implementation detail, however. # unstable implementation detail, however.
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
expand-response-params =
optionalString ((buildPackages.stdenv.hasCC or false) && buildPackages.stdenv.cc != "/dev/null") (import ../expand-response-params { inherit (buildPackages) stdenv; });
useGccForLibs = useCcForLibs useGccForLibs = useCcForLibs
&& libcxx == null && libcxx == null
&& !targetPlatform.isDarwin && !targetPlatform.isDarwin
@ -298,6 +295,9 @@ stdenvNoCC.mkDerivation {
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)})) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
''; '';
# Expose expand-response-params we are /actually/ using. In stdenv
# bootstrapping, expand-response-params usually comes from an earlier stage,
# so it is important to expose this for reference checking.
inherit expand-response-params; inherit expand-response-params;
inherit nixSupport; inherit nixSupport;
@ -739,6 +739,7 @@ stdenvNoCC.mkDerivation {
inherit isClang; inherit isClang;
# for substitution in utils.bash # for substitution in utils.bash
# TODO(@sternenseemann): invent something cleaner than passing in "" in case of absence
expandResponseParams = "${expand-response-params}/bin/expand-response-params"; expandResponseParams = "${expand-response-params}/bin/expand-response-params";
# TODO(@sternenseemann): rename env var via stdenv rebuild # TODO(@sternenseemann): rename env var via stdenv rebuild
shell = getBin runtimeShell + runtimeShell.shellPath or ""; shell = getBin runtimeShell + runtimeShell.shellPath or "";

View File

@ -76,9 +76,9 @@ let
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
buildPackages = lib.optionalAttrs (prevStage ? stdenv) { expand-response-params = lib.optionalString
inherit (prevStage) stdenv; (prevStage.stdenv.hasCC or false && prevStage.stdenv.cc != "/dev/null")
}; prevStage.expand-response-params;
extraPackages = [ extraPackages = [
prevStage.llvmPackages.compiler-rt prevStage.llvmPackages.compiler-rt
@ -254,7 +254,7 @@ in
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
buildPackages = { }; expand-response-params = "";
libc = selfDarwin.Libsystem; libc = selfDarwin.Libsystem;
inherit lib; inherit lib;
@ -841,9 +841,7 @@ in
# Rewrap binutils so it uses the rebuilt Libsystem. # Rewrap binutils so it uses the rebuilt Libsystem.
binutils = superDarwin.binutils.override { binutils = superDarwin.binutils.override {
buildPackages = { inherit (prevStage) expand-response-params;
inherit (prevStage) stdenv;
};
libc = selfDarwin.Libsystem; libc = selfDarwin.Libsystem;
} // { } // {
passthru = { inherit (prevStage.bintools.passthru) isFromBootstrapFiles; }; passthru = { inherit (prevStage.bintools.passthru) isFromBootstrapFiles; };
@ -1048,9 +1046,7 @@ in
}; };
binutils = superDarwin.binutils.override { binutils = superDarwin.binutils.override {
buildPackages = { inherit (prevStage) expand-response-params;
inherit (prevStage) stdenv;
};
bintools = selfDarwin.binutils-unwrapped; bintools = selfDarwin.binutils-unwrapped;
libc = selfDarwin.Libsystem; libc = selfDarwin.Libsystem;
@ -1087,9 +1083,7 @@ in
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
buildPackages = { inherit (prevStage) expand-response-params;
inherit (prevStage) stdenv;
};
extraPackages = [ extraPackages = [
self.llvmPackages.compiler-rt self.llvmPackages.compiler-rt

View File

@ -185,9 +185,9 @@ let
name = "${name}-gcc-wrapper"; name = "${name}-gcc-wrapper";
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
buildPackages = lib.optionalAttrs (prevStage ? stdenv) { expand-response-params = lib.optionalString
inherit (prevStage) stdenv; (prevStage.stdenv.hasCC or false && prevStage.stdenv.cc != "/dev/null")
}; prevStage.expand-response-params;
cc = prevStage.gcc-unwrapped; cc = prevStage.gcc-unwrapped;
bintools = prevStage.binutils; bintools = prevStage.binutils;
isGNU = true; isGNU = true;
@ -261,7 +261,7 @@ in
name = "bootstrap-stage0-binutils-wrapper"; name = "bootstrap-stage0-binutils-wrapper";
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
buildPackages = { }; expand-response-params = "";
libc = getLibc self; libc = getLibc self;
inherit lib; inherit lib;
inherit (self) stdenvNoCC coreutils gnugrep; inherit (self) stdenvNoCC coreutils gnugrep;
@ -557,9 +557,7 @@ in
# Since this is the first fresh build of binutils since stage2, our own runtimeShell will be used. # Since this is the first fresh build of binutils since stage2, our own runtimeShell will be used.
binutils = super.binutils.override { binutils = super.binutils.override {
# Build expand-response-params with last stage like below # Build expand-response-params with last stage like below
buildPackages = { inherit (prevStage) expand-response-params;
inherit (prevStage) stdenv;
};
}; };
# To allow users' overrides inhibit dependencies too heavy for # To allow users' overrides inhibit dependencies too heavy for
@ -570,9 +568,7 @@ in
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
isGNU = true; isGNU = true;
buildPackages = { inherit (prevStage) expand-response-params;
inherit (prevStage) stdenv;
};
cc = prevStage.gcc-unwrapped; cc = prevStage.gcc-unwrapped;
bintools = self.binutils; bintools = self.binutils;
libc = getLibc self; libc = getLibc self;
@ -654,7 +650,9 @@ in
# More complicated cases # More complicated cases
++ (map (x: getOutput x (getLibc prevStage)) [ "out" "dev" "bin" ] ) ++ (map (x: getOutput x (getLibc prevStage)) [ "out" "dev" "bin" ] )
++ [ linuxHeaders # propagated from .dev ++ [ linuxHeaders # propagated from .dev
binutils gcc gcc.cc gcc.cc.lib gcc.expand-response-params gcc.cc.libgcc glibc.passthru.libgcc binutils gcc gcc.cc gcc.cc.lib
gcc.expand-response-params # != (prevStage.)expand-response-params
gcc.cc.libgcc glibc.passthru.libgcc
] ]
++ lib.optionals (localSystem.libc == "musl") [ fortify-headers ] ++ lib.optionals (localSystem.libc == "musl") [ fortify-headers ]
++ [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ] ++ [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ]

View File

@ -656,6 +656,8 @@ with pkgs;
evhz = callPackage ../tools/misc/evhz { }; evhz = callPackage ../tools/misc/evhz { };
expand-response-params = callPackage ../build-support/expand-response-params { };
expressvpn = callPackage ../applications/networking/expressvpn { }; expressvpn = callPackage ../applications/networking/expressvpn { };
faq = callPackage ../development/tools/faq { }; faq = callPackage ../development/tools/faq { };