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
This commit is contained in:
Lluís Batlle i Rossell 2009-11-17 21:14:57 +00:00
parent 2c7fa189fb
commit 0c631f6181
7 changed files with 29 additions and 30 deletions

View File

@ -30,4 +30,8 @@ stdenv.mkDerivation {
meta = if gcc != null then gcc.meta else meta = if gcc != null then gcc.meta else
{ description = "System C compiler wrapper"; { description = "System C compiler wrapper";
}; };
passthru = {
inherit cross;
};
} }

View File

@ -23,3 +23,6 @@ fi
if test -n "@glibc@"; then if test -n "@glibc@"; then
PATH=$PATH:@glibc@/bin PATH=$PATH:@glibc@/bin
fi fi
configureFlags="$configureFlags --build=$system --host=$crossConfig"
dontStrip=1

View File

@ -107,6 +107,18 @@ rec {
isStatic = true; isStatic = true;
} // {inherit fetchurl;}; } // {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 /* Modify a stdenv so that the specified attributes are added to
every derivation returned by its mkDerivation function. every derivation returned by its mkDerivation function.

View File

@ -10,7 +10,7 @@
# system, e.g., cygwin and mingw builds on i686-cygwin. Most people # system, e.g., cygwin and mingw builds on i686-cygwin. Most people
# can ignore it. # can ignore it.
{system, stdenvType ? system, allPackages ? import ../.., cross ? null}: {system, stdenvType ? system, allPackages ? import ../..}:
assert system != "i686-cygwin" -> system == stdenvType; assert system != "i686-cygwin" -> system == stdenvType;
@ -41,7 +41,7 @@ rec {
# Linux standard environment. # Linux standard environment.
stdenvLinux = (import ./linux {inherit system allPackages cross;}).stdenvLinux; stdenvLinux = (import ./linux {inherit system allPackages;}).stdenvLinux;
# MinGW/MSYS standard environment. # MinGW/MSYS standard environment.

View File

@ -1,5 +1,4 @@
{ system, name, preHook ? null, postHook ? null, initialPath, gcc, shell { system, name, preHook ? null, postHook ? null, initialPath, gcc, shell
, cross ? null
, param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? "" , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
, extraAttrs ? {} , extraAttrs ? {}
@ -53,9 +52,6 @@ let
["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)]; ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)];
stdenv = result; stdenv = result;
system = result.system; 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, # The meta attribute is passed in the resulting attribute set,

View File

@ -5,8 +5,7 @@
# ensuring purity of components produced by it. # ensuring purity of components produced by it.
# The function defaults are for easy testing. # The function defaults are for easy testing.
{system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix, {system ? "i686-linux", allPackages ? import ../../top-level/all-packages.nix}:
cross ? null}:
rec { rec {
@ -205,26 +204,15 @@ rec {
# When updating stdenvLinux, make sure that the result has no # When updating stdenvLinux, make sure that the result has no
# dependency (`nix-store -qR') on bootstrapTools. # dependency (`nix-store -qR') on bootstrapTools.
stdenvLinux = import ../generic { stdenvLinux = import ../generic {
name = "stdenv-linux" + name = "stdenv-linux";
stdenvLinuxBoot3Pkgs.lib.optionalString (cross != null) "-${cross.config}";
inherit system cross; inherit system;
preHook = builtins.toFile "prehook.sh" commonPreHook; preHook = builtins.toFile "prehook.sh" commonPreHook;
initialPath = initialPath =
((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;}) ((import ../common-path.nix) {pkgs = stdenvLinuxBoot3Pkgs;})
++ [stdenvLinuxBoot3Pkgs.patchelf] ++ [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;
gcc = wrapGCC rec { gcc = wrapGCC rec {
inherit (stdenvLinuxBoot2Pkgs) binutils; inherit (stdenvLinuxBoot2Pkgs) binutils;

View File

@ -213,15 +213,8 @@ let
allPackages = args: import ./all-packages.nix ({ inherit config; } // args); 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; defaultStdenv = allStdenvs.stdenv;
stdenvCross = cross : (allStdenvsCross cross).stdenv;
stdenv = stdenv =
if bootStdenv != null then bootStdenv else if bootStdenv != null then bootStdenv else
let changer = getConfig ["replaceStdenv"] null; let changer = getConfig ["replaceStdenv"] null;
@ -244,7 +237,10 @@ let
inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;}) inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;})
overrideGCC overrideInStdenv overrideSetup overrideGCC overrideInStdenv overrideSetup
useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
keepBuildTree cleanupBuildTree addCoverageInstrumentation; keepBuildTree cleanupBuildTree addCoverageInstrumentation makeStdenvCross;
stdenvCross = cross : makeStdenvCross stdenv (binutilsCross cross)
(gccCrossStageFinal cross);
### BUILD SUPPORT ### BUILD SUPPORT