diff options
Diffstat (limited to 'pkgs/stdenv/linux/default.nix')
-rw-r--r-- | pkgs/stdenv/linux/default.nix | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 9d13eb0b8e17..e1801abcb485 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -185,9 +185,9 @@ let name = "${name}-gcc-wrapper"; nativeTools = false; nativeLibc = false; - buildPackages = lib.optionalAttrs (prevStage ? stdenv) { - inherit (prevStage) stdenv; - }; + expand-response-params = lib.optionalString + (prevStage.stdenv.hasCC or false && prevStage.stdenv.cc != "/dev/null") + prevStage.expand-response-params; cc = prevStage.gcc-unwrapped; bintools = prevStage.binutils; isGNU = true; @@ -196,6 +196,7 @@ let inherit (prevStage) coreutils gnugrep; stdenvNoCC = prevStage.ccWrapperStdenv; fortify-headers = prevStage.fortify-headers; + runtimeShell = prevStage.ccWrapperStdenv.shell; }).overrideAttrs(a: lib.optionalAttrs (prevStage.gcc-unwrapped.passthru.isXgcc or false) { # This affects only `xgcc` (the compiler which compiles the final compiler). postFixup = (a.postFixup or "") + '' @@ -260,11 +261,12 @@ in name = "bootstrap-stage0-binutils-wrapper"; nativeTools = false; nativeLibc = false; - buildPackages = { }; + expand-response-params = ""; libc = getLibc self; inherit lib; inherit (self) stdenvNoCC coreutils gnugrep; bintools = bootstrapTools; + runtimeShell = "${bootstrapTools}/bin/bash"; }; coreutils = bootstrapTools; gnugrep = bootstrapTools; @@ -328,12 +330,20 @@ in assert isBuiltByBootstrapFilesCompiler prevStage.patchelf; stageFun prevStage { name = "bootstrap-stage-xgcc"; - overrides = final: prev: { + overrides = self: super: { inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl patchelf; ${localSystem.libc} = getLibc prevStage; - gmp = prev.gmp.override { cxx = false; }; + gmp = super.gmp.override { cxx = false; }; + # This stage also rebuilds binutils which will of course be used only in the next stage. + # We inherit this until stage3, in stage4 it will be rebuilt using the adjacent bash/runtimeShell pkg. + # TODO(@sternenseemann): Can we already build the wrapper with the actual runtimeShell here? + # Historically, the wrapper didn't use runtimeShell, so the used shell had to be changed explicitly + # (or stdenvNoCC.shell would be used) which happened in stage4. + binutils = super.binutils.override { + runtimeShell = "${bootstrapTools}/bin/bash"; + }; gcc-unwrapped = - (prev.gcc-unwrapped.override (commonGccOverrides // { + (super.gcc-unwrapped.override (commonGccOverrides // { # The most logical name for this package would be something like # "gcc-stage1". Unfortunately "stage" is already reserved for the # layers of stdenv, so using "stage" in the name of this package @@ -376,7 +386,7 @@ in # configureFlags = (a.configureFlags or []) ++ [ "--with-native-system-header-dir=/include" - "--with-build-sysroot=${lib.getDev final.stdenv.cc.libc}" + "--with-build-sysroot=${lib.getDev self.stdenv.cc.libc}" ]; # This is a separate phase because gcc assembles its phase scripts @@ -544,13 +554,10 @@ in # other purposes (binutils and top-level pkgs) too. inherit (prevStage) gettext gnum4 bison perl texinfo zlib linuxHeaders libidn2 libunistring; ${localSystem.libc} = getLibc prevStage; + # Since this is the first fresh build of binutils since stage2, our own runtimeShell will be used. binutils = super.binutils.override { - # Don't use stdenv's shell but our own - shell = self.bash + "/bin/bash"; # Build expand-response-params with last stage like below - buildPackages = { - inherit (prevStage) stdenv; - }; + inherit (prevStage) expand-response-params; }; # To allow users' overrides inhibit dependencies too heavy for @@ -561,15 +568,12 @@ in nativeTools = false; nativeLibc = false; isGNU = true; - buildPackages = { - inherit (prevStage) stdenv; - }; + inherit (prevStage) expand-response-params; cc = prevStage.gcc-unwrapped; bintools = self.binutils; libc = getLibc self; inherit lib; - inherit (self) stdenvNoCC coreutils gnugrep; - shell = self.bash + "/bin/bash"; + inherit (self) stdenvNoCC coreutils gnugrep runtimeShell; fortify-headers = self.fortify-headers; }; }; @@ -646,7 +650,9 @@ in # More complicated cases ++ (map (x: getOutput x (getLibc prevStage)) [ "out" "dev" "bin" ] ) ++ [ 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 ] ++ [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ] |