summary refs log tree commit diff
path: root/pkgs/stdenv/linux
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2016-12-24 07:28:40 -0800
committerJohn Ericson <Ericson2314@Yahoo.com>2017-01-13 13:23:26 -0500
commitb10f415c2172b3b89b7f93aa62c466fcef911d61 (patch)
tree9b163707fae6f70f14de1e723e9ef7e61899188b /pkgs/stdenv/linux
parent6a45e911c408bfd256531ba4d81bf8151f2f4df8 (diff)
downloadnixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.tar
nixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.tar.gz
nixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.tar.bz2
nixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.tar.lz
nixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.tar.xz
nixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.tar.zst
nixpkgs-b10f415c2172b3b89b7f93aa62c466fcef911d61.zip
linux stdenv: Remove stray use of stage0 to bootstrap more elegantly
Diffstat (limited to 'pkgs/stdenv/linux')
-rw-r--r--pkgs/stdenv/linux/default.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 76c15372d1d..f841c7a778a 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -75,7 +75,7 @@ rec {
           libc = prevStage.glibc;
           inherit (prevStage) binutils coreutils gnugrep;
           name = name;
-          stdenv = stage0.stdenv;
+          stdenv = prevStage.ccWrapperStdenv;
         };
 
         extraAttrs = {
@@ -95,7 +95,9 @@ rec {
       stdenv = thisStdenv;
     };
 
-  baseCase = {
+  baseCase = {}: {
+    __raw = true;
+
     gcc-unwrapped = null;
     glibc = null;
     binutils = null;
@@ -105,10 +107,15 @@ rec {
 
   # Build a dummy stdenv with no GCC or working fetchurl.  This is
   # because we need a stdenv to build the GCC wrapper and fetchurl.
-  stage0 = stageFun baseCase {
+  stage0 = prevStage: stageFun prevStage {
     name = null;
 
     overrides = self: super: {
+      # We thread stage0's stdenv through under this name so downstream stages
+      # can use it for wrapping gcc too. This way, downstream stages don't need
+      # to refer to this stage directly, which violates the principle that each
+      # stage should only access the stage that came before it.
+      ccWrapperStdenv = self.stdenv;
       # The Glibc include directory cannot have the same prefix as the
       # GCC include directory, since GCC gets confused otherwise (it
       # will search the Glibc headers before the GCC headers).  So
@@ -146,7 +153,9 @@ rec {
     # Rebuild binutils to use from stage2 onwards.
     overrides = self: super: {
       binutils = super.binutils.override { gold = false; };
-      inherit (prevStage) glibc gcc-unwrapped coreutils gnugrep;
+      inherit (prevStage)
+        ccWrapperStdenv
+        glibc gcc-unwrapped coreutils gnugrep;
 
       # A threaded perl build needs glibc/libpthread_nonshared.a,
       # which is not included in bootstrapTools, so disable threading.
@@ -165,6 +174,7 @@ rec {
 
     overrides = self: super: {
       inherit (prevStage)
+        ccWrapperStdenv
         binutils gcc-unwrapped coreutils gnugrep
         perl paxctl gnum4 bison;
       # This also contains the full, dynamically linked, final Glibc.
@@ -180,6 +190,7 @@ rec {
 
     overrides = self: super: rec {
       inherit (prevStage)
+        ccWrapperStdenv
         binutils glibc coreutils gnugrep
         perl patchelf linuxHeaders gnum4 bison;
       # Link GCC statically against GMP etc.  This makes sense because
@@ -278,7 +289,8 @@ rec {
   };
 
   stagesLinux = [
-    ({}: stage0)
+    baseCase
+    stage0
     stage1
     stage2
     stage3