From 0c631f61819e680bc689d432e6c67e4e0da294fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Tue, 17 Nov 2009 21:14:57 +0000 Subject: [PATCH] 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 --- .../gcc-cross-wrapper/default.nix | 4 ++++ .../gcc-cross-wrapper/setup-hook.sh | 3 +++ pkgs/stdenv/adapters.nix | 12 +++++++++++ pkgs/stdenv/default.nix | 4 ++-- pkgs/stdenv/generic/default.nix | 4 ---- pkgs/stdenv/linux/default.nix | 20 ++++--------------- pkgs/top-level/all-packages.nix | 12 ++++------- 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 8acdb8356c0d..a9042dddf195 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 7a7ea8226919..e4034820fb3c 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 db3803661531..1191748fb560 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 19bbb371a31c..ed8f0e39f5f8 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 a8eab154db4e..de525d479f95 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 9a90e4b28df8..cf67e7071736 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 22300675ed88..402f7c657671 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