about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2009-11-17 21:14:57 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2009-11-17 21:14:57 +0000
commit0c631f61819e680bc689d432e6c67e4e0da294fb (patch)
treec5750e2126a7d4b268f21a4d5e1873aa5a1ccaf2
parent2c7fa189fb2ac1c4ef689398ab13a4465448856a (diff)
Trying to move all stdenv cross-compiling details out of the stdenv expression,
into a stdenv adapater.


svn path=/nixpkgs/branches/stdenv-updates/; revision=18397
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/default.nix4
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/setup-hook.sh3
-rw-r--r--pkgs/stdenv/adapters.nix12
-rw-r--r--pkgs/stdenv/default.nix4
-rw-r--r--pkgs/stdenv/generic/default.nix4
-rw-r--r--pkgs/stdenv/linux/default.nix20
-rw-r--r--pkgs/top-level/all-packages.nix12
7 files changed, 29 insertions, 30 deletions
diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix
index 8acdb8356c0d8..a9042dddf1956 100644
--- a/pkgs/build-support/gcc-cross-wrapper/default.nix
+++ b/pkgs/build-support/gcc-cross-wrapper/default.nix
@@ -30,4 +30,8 @@ stdenv.mkDerivation {
   meta = if gcc != null then gcc.meta else
     { description = "System C compiler wrapper";
     };
+
+  passthru = {
+    inherit cross;
+  };
 }
diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
index 7a7ea82269190..e4034820fb3c0 100644
--- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
@@ -23,3 +23,6 @@ fi
 if test -n "@glibc@"; then
     PATH=$PATH:@glibc@/bin
 fi
+
+configureFlags="$configureFlags --build=$system --host=$crossConfig"
+dontStrip=1
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index db38036615316..1191748fb5600 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -107,6 +107,18 @@ rec {
       isStatic = true;
     } // {inherit fetchurl;};
 
+  # Return a modified stdenv that adds a cross compiler to the
+  # builds.
+  makeStdenvCross = stdenv: binutilsCross : gccCross: stdenv //
+    { mkDerivation = args: stdenv.mkDerivation (args // {
+        
+        buildInputs =
+          (if args ? buildInputs then args.buildInputs else [])
+          ++ [ gccCross binutilsCross ];
+
+        crossConfig = gccCross.cross.config;
+      });
+    };
 
   /* Modify a stdenv so that the specified attributes are added to
      every derivation returned by its mkDerivation function.
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 19bbb371a31c8..ed8f0e39f5f89 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -10,7 +10,7 @@
 # system, e.g., cygwin and mingw builds on i686-cygwin.  Most people
 # can ignore it.
 
-{system, stdenvType ? system, allPackages ? import ../.., cross ? null}:
+{system, stdenvType ? system, allPackages ? import ../..}:
 
 assert system != "i686-cygwin" -> system == stdenvType;
 
@@ -41,7 +41,7 @@ rec {
 
 
   # Linux standard environment.
-  stdenvLinux = (import ./linux {inherit system allPackages cross;}).stdenvLinux;
+  stdenvLinux = (import ./linux {inherit system allPackages;}).stdenvLinux;
 
     
   # MinGW/MSYS standard environment.
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index a8eab154db4e1..de525d479f956 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -1,5 +1,4 @@
 { system, name, preHook ? null, postHook ? null, initialPath, gcc, shell
-, cross ? null
 , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
 , extraAttrs ? {}
 
@@ -53,9 +52,6 @@ let
                 ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)];
               stdenv = result;
               system = result.system;
-              # The env variable 'cross' is used in all the crosscompiler
-              # bootstrapping in another sense
-              crossTarget = if (cross != null) then cross.config else null;
             })
           )
           # The meta attribute is passed in the resulting attribute set,
diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix
index 9a90e4b28df8d..cf67e7071736b 100644
--- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -5,8 +5,7 @@
 # ensuring purity of components produced by it.
 
 # The function defaults are for easy testing.
-{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix,
-cross ? null}:
+{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix}:
 
 rec {
 
@@ -205,26 +204,15 @@ rec {
   #    When updating stdenvLinux, make sure that the result has no
   #    dependency (`nix-store -qR') on bootstrapTools.
   stdenvLinux = import ../generic {
-    name = "stdenv-linux" +
-      stdenvLinuxBoot3Pkgs.lib.optionalString (cross != null) "-${cross.config}";
+    name = "stdenv-linux";
     
-    inherit system cross;
+    inherit system;
     
     preHook = builtins.toFile "prehook.sh" commonPreHook;
     
     initialPath = 
       ((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;})
-      ++ [stdenvLinuxBoot3Pkgs.patchelf]
-      ++ stdenvLinuxBoot3Pkgs.lib.optionals (cross != null)
-        [ (stdenvLinuxBoot3Pkgs.binutilsCross cross)
-           (stdenvLinuxBoot3Pkgs.gccCrossStageFinal cross) ];
-
-    postHook = if (cross != null) then
-        (builtins.toFile "cross-posthook.sh" ''
-            configureFlags="$configureFlags --build=${system} --host=${cross.config}"
-            dontStrip=1
-        '')
-        else null;
+      ++ [stdenvLinuxBoot3Pkgs.patchelf];
 
     gcc = wrapGCC rec {
       inherit (stdenvLinuxBoot2Pkgs) binutils;
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 22300675ed885..402f7c6576712 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -213,15 +213,8 @@ let
     allPackages = args: import ./all-packages.nix ({ inherit config; } // args);
   };
 
-  allStdenvsCross = cross : import ../stdenv {
-    inherit system stdenvType cross;
-    allPackages = args: import ./all-packages.nix ({ inherit config; } // args);
-  };
-
   defaultStdenv = allStdenvs.stdenv;
 
-  stdenvCross = cross : (allStdenvsCross cross).stdenv;
-
   stdenv =
     if bootStdenv != null then bootStdenv else
       let changer = getConfig ["replaceStdenv"] null;
@@ -244,7 +237,10 @@ let
   inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;})
     overrideGCC overrideInStdenv overrideSetup
     useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
-    keepBuildTree cleanupBuildTree addCoverageInstrumentation;
+    keepBuildTree cleanupBuildTree addCoverageInstrumentation makeStdenvCross;
+
+  stdenvCross = cross : makeStdenvCross stdenv (binutilsCross cross)
+      (gccCrossStageFinal cross);
 
 
   ### BUILD SUPPORT