summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2004-03-30 12:46:52 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2004-03-30 12:46:52 +0000
commit01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4 (patch)
treef47da9f336227f99789f4f819837dcd25cc566c0
parent68327c3a9dbbea3cd647c509d8cfd2db8ccd0c72 (diff)
downloadnixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.tar
nixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.tar.gz
nixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.tar.bz2
nixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.tar.lz
nixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.tar.xz
nixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.tar.zst
nixpkgs-01a1658c6b8cdf75ad87ea24d1f82bc6c17670d4.zip
* Finally we have a working stdenvLinux again.
  On the downside, the build process of stdenvLinux builds gcc 9 times
  (3 x 3 bootstrap stages).  That's a bit excessive.

svn path=/nixpkgs/trunk/; revision=880
-rw-r--r--pkgs/build-support/gcc-wrapper/builder.sh4
-rw-r--r--pkgs/build-support/gcc-wrapper/default.nix3
-rw-r--r--pkgs/build-support/gcc-wrapper/gcc-wrapper.sh2
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-wrapper.sh5
-rw-r--r--pkgs/stdenv/generic/builder.sh1
-rw-r--r--pkgs/stdenv/generic/default.nix8
-rw-r--r--pkgs/stdenv/generic/setup.sh1
-rw-r--r--pkgs/stdenv/initial/default.nix8
-rw-r--r--pkgs/stdenv/native/default.nix2
-rw-r--r--pkgs/stdenv/native/prehook.sh2
-rw-r--r--pkgs/stdenv/nix-linux/boot.nix19
-rw-r--r--pkgs/stdenv/nix-linux/default.nix7
-rw-r--r--pkgs/stdenv/nix-linux/prehook-boot.sh3
-rw-r--r--pkgs/stdenv/nix-linux/prehook.sh2
-rw-r--r--pkgs/stdenv/nix/default.nix5
-rw-r--r--pkgs/stdenv/nix/prehook.sh3
-rw-r--r--pkgs/system/stdenvs.nix69
-rw-r--r--pkgs/test/simple/builder.sh2
-rw-r--r--pkgs/test/simple/default.nix7
19 files changed, 77 insertions, 76 deletions
diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh
index f6f38891153..a6a4c3f7253 100644
--- a/pkgs/build-support/gcc-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-wrapper/builder.sh
@@ -39,7 +39,7 @@ mkGccWrapper () {
     sed \
         -e "s^@gcc@^$src^g" \
         -e "s^@out@^$out^g" \
-        -e "s^@bash@^$SHELL^g" \
+        -e "s^@shell@^$shell^g" \
         < $gccWrapper > $dst
     chmod +x $dst
 }
@@ -58,7 +58,7 @@ sed \
     -e "s^@out@^$out^g" \
     -e "s^@ldflags@^$ldflags^g" \
     -e "s^@ld@^$ldPath/ld^g" \
-    -e "s^@bash@^$SHELL^g" \
+    -e "s^@shell@^$shell^g" \
     < $ldWrapper > $out/bin/ld
 chmod +x $out/bin/ld
 
diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix
index 48687604971..4dfacf9b3b5 100644
--- a/pkgs/build-support/gcc-wrapper/default.nix
+++ b/pkgs/build-support/gcc-wrapper/default.nix
@@ -6,7 +6,7 @@
 # variables so that the compiler and the linker just "work".
 
 { name, stdenv, nativeTools, nativeGlibc, nativePrefix ? ""
-, gcc ? null, glibc ? null, binutils ? null
+, gcc ? null, glibc ? null, binutils ? null, shell ? ""
 }:
 
 assert nativeTools -> nativePrefix != "";
@@ -23,4 +23,5 @@ stdenv.mkDerivation {
   langC = if nativeTools then true else gcc.langC;
   langCC = if nativeTools then true else gcc.langCC;
   langF77 = if nativeTools then false else gcc.langF77;
+  shell = if shell == "" then stdenv.shell else shell;
 }
diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
index 21e51924209..149d6e2fcbc 100644
--- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
@@ -1,4 +1,4 @@
-#! @bash@ -e
+#! @shell@ -e
 
 if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
     . "$NIX_GCC_WRAPPER_START_HOOK"
diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
index 1443af33155..3196a932246 100644
--- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
@@ -1,4 +1,4 @@
-#! @bash@ -e
+#! @shell@ -e
 
 if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
     . "$NIX_LD_WRAPPER_START_HOOK"
@@ -9,7 +9,8 @@ fi
 
 # Optionally filter out paths not refering to the store.
 params=("$@")
-if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
+if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
+        -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
     rest=()
     n=0
     while test $n -lt ${#params[*]}; do
diff --git a/pkgs/stdenv/generic/builder.sh b/pkgs/stdenv/generic/builder.sh
index b3d46432249..bbcd19448cb 100644
--- a/pkgs/stdenv/generic/builder.sh
+++ b/pkgs/stdenv/generic/builder.sh
@@ -13,6 +13,7 @@ sed \
  -e "s^@postHook@^$postHook^g" \
  -e "s^@initialPath@^$initialPath^g" \
  -e "s^@gcc@^$gcc^g" \
+ -e "s^@shell@^$shell^g" \
  -e "s^@param1@^$p1^g" \
  -e "s^@param2@^$p2^g" \
  -e "s^@param3@^$p3^g" \
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index d7b953ffb05..3aa2d3bfac0 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, bash
+{ stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, shell
 , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
 }:
 
@@ -13,17 +13,17 @@ let {
 
       setup = ./setup.sh;
 
-      inherit preHook postHook initialPath gcc;
+      inherit preHook postHook initialPath gcc shell;
 
       # TODO: make this more elegant.
       inherit param1 param2 param3 param4 param5;
     }
 
     # Add a utility function to produce derivations that use this
-    # stdenv and its the bash shell.
+    # stdenv and its shell.
     // {
       mkDerivation = attrs: derivation (attrs // {
-        builder = bash;
+        builder = shell;
         args = ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)];
         stdenv = body;
         system = body.system;
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 074e738dca3..4f1485f224b 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -15,6 +15,7 @@ fi
 
 
 # Execute the pre-hook.
+export SHELL=@shell@
 param1=@param1@
 param2=@param2@
 param3=@param3@
diff --git a/pkgs/stdenv/initial/default.nix b/pkgs/stdenv/initial/default.nix
index 6a62751b037..4c67fee7cd5 100644
--- a/pkgs/stdenv/initial/default.nix
+++ b/pkgs/stdenv/initial/default.nix
@@ -7,21 +7,25 @@
 
 let {
 
+  shell = "/bin/sh";
+
   body = 
 
     derivation {
       inherit system name;
-      builder = "/bin/sh";
+      builder = shell;
       args = ["-e" ./builder.sh];
     }
 
     // {
       mkDerivation = attrs: derivation (attrs // {
-        builder = "/bin/sh";
+        builder = shell;
         args = ["-e" attrs.builder];
         stdenv = body;
         system = body.system;
       });
+
+      inherit shell;
     };
 
 }
diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix
index 143230fbd89..2dae9c9fbf4 100644
--- a/pkgs/stdenv/native/default.nix
+++ b/pkgs/stdenv/native/default.nix
@@ -15,5 +15,5 @@ genericStdenv {
     inherit stdenv;
   };
 
-  bash = "/bin/sh";
+  shell = "/bin/sh";
 }
diff --git a/pkgs/stdenv/native/prehook.sh b/pkgs/stdenv/native/prehook.sh
index 21248e16cdb..1714586999e 100644
--- a/pkgs/stdenv/native/prehook.sh
+++ b/pkgs/stdenv/native/prehook.sh
@@ -1,3 +1 @@
-export SHELL=/bin/sh
-
 export NIX_ENFORCE_PURITY=
diff --git a/pkgs/stdenv/nix-linux/boot.nix b/pkgs/stdenv/nix-linux/boot.nix
deleted file mode 100644
index b556ba9ba36..00000000000
--- a/pkgs/stdenv/nix-linux/boot.nix
+++ /dev/null
@@ -1,19 +0,0 @@
-{stdenv, glibc, genericStdenv, gccWrapper}:
-
-genericStdenv {
-  name = "stdenv-nix-linux-boot";
-  preHook = ./prehook-boot.sh;
-  initialPath = "/usr/local /usr /";
-
-  inherit stdenv;
-
-  gcc = gccWrapper {
-    name = "gcc-native";
-    nativeTools = true;
-    nativeGlibc = false;
-    nativePrefix = "/usr";
-    inherit stdenv glibc;
-  };
-
-  bash = "/bin/sh";
-}
diff --git a/pkgs/stdenv/nix-linux/default.nix b/pkgs/stdenv/nix-linux/default.nix
index 9b4231962c3..c06f2cf815a 100644
--- a/pkgs/stdenv/nix-linux/default.nix
+++ b/pkgs/stdenv/nix-linux/default.nix
@@ -12,10 +12,9 @@ genericStdenv {
     nativeTools = false;
     nativeGlibc = false;
     inherit (pkgs) gcc binutils;
-    inherit glibc;
+    inherit stdenv glibc;
+    shell = pkgs.bash ~ /bin/sh;
   };
 
-  bash = pkgs.bash ~ /bin/sh;
-
-  param1 = pkgs.bash;
+  shell = pkgs.bash ~ /bin/sh;
 }
diff --git a/pkgs/stdenv/nix-linux/prehook-boot.sh b/pkgs/stdenv/nix-linux/prehook-boot.sh
deleted file mode 100644
index 21248e16cdb..00000000000
--- a/pkgs/stdenv/nix-linux/prehook-boot.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-export SHELL=/bin/sh
-
-export NIX_ENFORCE_PURITY=
diff --git a/pkgs/stdenv/nix-linux/prehook.sh b/pkgs/stdenv/nix-linux/prehook.sh
index 0e0bada4fcb..08bb6c0332c 100644
--- a/pkgs/stdenv/nix-linux/prehook.sh
+++ b/pkgs/stdenv/nix-linux/prehook.sh
@@ -1,3 +1 @@
-export SHELL=$param1
-
 export NIX_ENFORCE_PURITY=1
diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix
index 5634553dd50..f3fb4a4f951 100644
--- a/pkgs/stdenv/nix/default.nix
+++ b/pkgs/stdenv/nix/default.nix
@@ -13,9 +13,8 @@ genericStdenv {
     nativeGlibc = true;
     inherit (pkgs) gcc binutils;
     inherit stdenv;
+    shell = pkgs.bash ~ /bin/sh;
   };
 
-  bash = pkgs.bash ~ /bin/sh;
-
-  param1 = pkgs.bash;
+  shell = pkgs.bash ~ /bin/sh;
 }
diff --git a/pkgs/stdenv/nix/prehook.sh b/pkgs/stdenv/nix/prehook.sh
index af5121f49c3..734d0f1ae83 100644
--- a/pkgs/stdenv/nix/prehook.sh
+++ b/pkgs/stdenv/nix/prehook.sh
@@ -1 +1,2 @@
-export SHELL=$param1
+export NIX_ENFORCE_PURITY=1
+export NIX_IGNORE_LD_THROUGH_GCC=1
diff --git a/pkgs/system/stdenvs.nix b/pkgs/system/stdenvs.nix
index 0621608f2be..7e41c0b6e86 100644
--- a/pkgs/system/stdenvs.nix
+++ b/pkgs/system/stdenvs.nix
@@ -38,19 +38,14 @@
   # The Nix build environment.
   stdenvNix = (import ../stdenv/nix) {
     stdenv = stdenvNative;
-    pkgs = stdenvNixBootPkgs;
+    pkgs = stdenvNativePkgs;
     inherit genericStdenv gccWrapper;
   };
 
-  stdenvNixBootPkgs = allPackages {
-    stdenv = stdenvNative;
-    bootCurl = null;
-    noSysDirs = true;
-  };
-
   stdenvNixPkgs = allPackages {
     stdenv = stdenvNix;
-    bootCurl = stdenvNixBootPkgs.curl;
+    bootCurl = stdenvNativePkgs.curl;
+    noSysDirs = false;
   };
 
 
@@ -59,40 +54,53 @@
 
   # 1) Build glibc in the Nix build environment.  The result is
   #    pure.
-  stdenvLinuxGlibc = stdenvNativePkgs.glibc; # !!! should be NixPkgs, but doesn't work
-
-  # 2) Construct a stdenv consisting of the native build environment,
-  #    plus the pure glibc.
-  stdenvLinuxBoot1 = (import ../stdenv/nix-linux/boot.nix) {
+  stdenvLinuxGlibc = stdenvNixPkgs.glibc;
+
+  # 2) Construct a stdenv consisting of the Nix build environment, but
+  #    with a gcc-wrapper that causes linking against the glibc from
+  #    step 1.  However, since the gcc wrapper here *does* look in
+  #    native system directories (e.g., `/usr/lib'), it doesn't
+  #    prevent impurity in the things it builds (e.g., through
+  #    `-lncurses').
+  stdenvLinuxBoot1 = (import ../stdenv/nix-linux) {
     stdenv = stdenvNative;
+    pkgs = stdenvNativePkgs;
     glibc = stdenvLinuxGlibc;
     inherit genericStdenv gccWrapper;
   };
 
-  # 3) Now we can build packages that will have the Nix glibc.
+  # 3) Now we can build packages that will link against the Nix
+  #    glibc.  We are on thin ice here: the compiler used to build
+  #    these packages doesn't prevent impurity, so e.g. bash ends up
+  #    linking against `/lib/libncurses.so', but the glibc from step 1
+  #    *doesn't* search in `/lib' etc.  So these programs won't work.
   stdenvLinuxBoot1Pkgs = allPackages {
     stdenv = stdenvLinuxBoot1;
-    bootCurl = null;
+    bootCurl = stdenvNativePkgs.curl;
+    noSysDirs = true;
   };
 
-  # 4) However, since these packages are built by an native C compiler
-  #    and linker, they may well pick up impure references (e.g., bash
-  #    might end up linking against /lib/libncurses).  So repeat, but
-  #    now use the Nix-built tools from step 2/3.
+  # 4) Therefore we build a new standard environment which is the same
+  #    as the one in step 2, but with a gcc and binutils from step 3
+  #    merged in.  Since these are pure (they don't search native
+  #    system directories), things built by this stdenv should be pure.
   stdenvLinuxBoot2 = (import ../stdenv/nix-linux) {
     stdenv = stdenvLinuxBoot1;
-    pkgs = stdenvLinuxBoot1Pkgs;
+    pkgs = stdenvNativePkgs // {
+      inherit (stdenvLinuxBoot1Pkgs) gcc binutils;
+    };
     glibc = stdenvLinuxGlibc;
     inherit genericStdenv gccWrapper;
   };
 
-  # 5) These packages should be pure.
+  # 5) So these packages should be pure.
   stdenvLinuxBoot2Pkgs = allPackages {
     stdenv = stdenvLinuxBoot2;
-    bootCurl = stdenvLinuxBoot1Pkgs.curl;
+    bootCurl = stdenvNativePkgs.curl;
   };
 
-  # 6) So finally we can construct the Nix build environment.
+  # 6) Finally we can construct the Nix build environment from the
+  #    packages from step 5.
   stdenvLinux = (import ../stdenv/nix-linux) {
     stdenv = stdenvLinuxBoot2;
     pkgs = stdenvLinuxBoot2Pkgs;
@@ -109,7 +117,20 @@
     } //
     {inherit (stdenvLinuxBoot2Pkgs)
       gzip bzip2 bash binutils coreutils diffutils findutils gawk gcc
-      gnumake gnused gnutar gnugrep wget;
+      gnumake gnused gnutar gnugrep curl;
     } //
     {glibc = stdenvLinuxGlibc;};
+
+  # In summary, we build gcc (and binutils) three times:
+  #   - in stdenvLinuxBoot1 (from stdenvNativePkgs); impure
+  #   - in stdenvLinuxBoot2 (from stdenvLinuxBoot1Pkgs); pure
+  #   - in stdenvLinux (from stdenvLinuxBoot2Pkgs); pure
+  # The last one may be redundant, but its good for validation (since
+  # the second one may use impure inputs).  To reduce build time, we
+  # could reduce the number of bootstrap stages inside each gcc build.
+  # Right now there are 3 stages, so gcc is built 9 times!
+
+  # On the other hand, a validating build of glibc is a good idea (it
+  # probably won't work right now due to --rpath madness).
+
 }
diff --git a/pkgs/test/simple/builder.sh b/pkgs/test/simple/builder.sh
index 7455f3e2274..dcfa49bd9c3 100644
--- a/pkgs/test/simple/builder.sh
+++ b/pkgs/test/simple/builder.sh
@@ -39,4 +39,4 @@ g++ hello2.cc -o $out/bin/hello2 -DVALUE="1 + 2 * 3"
 
 $out/bin/hello2
 
-ld -v
\ No newline at end of file
+ld -v
diff --git a/pkgs/test/simple/default.nix b/pkgs/test/simple/default.nix
index 0201097dc7d..b7d9446bac7 100644
--- a/pkgs/test/simple/default.nix
+++ b/pkgs/test/simple/default.nix
@@ -2,15 +2,14 @@ let {
   system = "i686-linux";
 
   stdenvs = (import ../../system/stdenvs.nix) {
-    system = "i686-linux";
+    inherit system;
     allPackages = import ../../system/all-packages-generic.nix;
   };
 
-  stdenv = stdenvs.stdenvLinux;
+  stdenv = stdenvs.stdenvNix;
 
-  test = derivation {
+  test = stdenv.mkDerivation {
     name = "simple-test";
-    inherit system stdenv;
     builder = ./builder.sh;
   };