diff options
author | Lluís Batlle i Rossell <viric@vicerveza.homeunix.net> | 2009-11-19 23:05:11 +0000 |
---|---|---|
committer | Lluís Batlle i Rossell <viric@vicerveza.homeunix.net> | 2009-11-19 23:05:11 +0000 |
commit | 6f3630e1289923de7d7b3e720fac56013fe7aea6 (patch) | |
tree | c62613c86c80eac522ad1e1b267272be3bee5997 /pkgs/stdenv | |
parent | 40e564c87c69ff193d64ed3ac8de5deb47c7b664 (diff) | |
download | nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.tar nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.tar.gz nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.tar.bz2 nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.tar.lz nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.tar.xz nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.tar.zst nixlib-6f3630e1289923de7d7b3e720fac56013fe7aea6.zip |
Attention, people who care on the builders for native builds. In the stdenv
derivation, the "buildInputs" in every stdenv mkDerivation don't map now directly to the environment variable "buildInputs" in the builder, but "buildNativeInputs". So, the inputs build by the native compiler. When cross compiling, they will map to the environment variable "buildInputs" (yes, now the same name), which means does to be built with the cross compiler. I think I improved the naming of variables a bit. There was a big mess, specially in the stdenv adapter for cross building, and also in the default builder script. I also tried to add proper manager of propagatedInputBuilds, these being propagated considering the host or build origin of that input build (so, at the end, being those propagatedInputBuilds being propagated properly to the native or the cross compiler. svn path=/nixpkgs/branches/stdenv-updates/; revision=18477
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 30 | ||||
-rw-r--r-- | pkgs/stdenv/generic/default.nix | 18 | ||||
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 36 |
3 files changed, 58 insertions, 26 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 1b739f851686..f6939f57e62c 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -111,20 +111,34 @@ rec { # builds. makeStdenvCross = stdenv: cross: binutilsCross: gccCross: stdenv // { mkDerivation = {name, buildInputs ? [], buildNativeInputs ? [], - propagatedBuildInputs ? [], ...}@args: let - # propagatedBuildInputs exists temporarily as another name for - # propagatedHostInputs. + propagatedBuildInputs ? [], propagatedBuildNativeInputs ? [], ...}@args: let + + # *BuildInputs exists temporarily as another name for + # *HostInputs. + getBuildDrv = drv : if (drv ? buildDrv) then drv.buildDrv else drv; - buildInputsDrvs = map (getBuildDrv) buildNativeInputs; - hostInputsDrvs = map (drv: drv.hostDrv) buildInputs; - hostInputsDrvsAsBuildInputs = map (getBuildDrv) buildInputs; - propagatedHostInputsDrvs = map (drv: drv.buildDrv) (propagatedBuildInputs); + buildNativeInputsDrvs = map (getBuildDrv) buildNativeInputs; + buildInputsDrvs = map (drv: drv.hostDrv) buildInputs; + buildInputsDrvsAsBuildInputs = map (getBuildDrv) buildInputs; + propagatedBuildInputsDrvs = map (drv: drv.hostDrv) (propagatedBuildInputs); + propagatedBuildNativeInputsDrvs = map (drv: drv.buildDrv) + (propagatedBuildNativeInputs); + + # The base stdenv already knows that buildNativeInputs and + # buildInputs should be built with the usual gcc-wrapper + # And the same for propagatedBuildInputs. buildDrv = stdenv.mkDerivation args; + + # We should overwrite the input attributes in hostDrv, to overwrite + # the defaults for only-native builds in the base stdenv hostDrv = if (cross == null) then buildDrv else stdenv.mkDerivation (args // { name = name + "-" + cross.config; - buildInputs = buildInputsDrvs + buildNativeInputs = buildNativeInputsDrvs ++ [ gccCross binutilsCross ]; + buildInputs = buildInputsDrvs; + propagatedBuildInputs = propagatedBuildInputsDrvs; + propagatedBuildNativeInputs = propagatedBuildNativeInputsDrvs; crossConfig = cross.config; }); diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index d9ce8d6f825d..0755ee46904b 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -48,8 +48,13 @@ let // (let buildInputs = if attrs ? buildInputs then attrs.buildInputs else []; - buildNativeInputs = if attrs ? buildNativeInputs then attrs.buildNativeInputs - else []; + buildNativeInputs = if attrs ? buildNativeInputs then + attrs.buildNativeInputs else []; + propagatedBuildInputs = if attrs ? propagatedBuildInputs then + attrs.propagatedBuildInputs else []; + propagatedBuildNativeInputs = if attrs ? + propagatedBuildNativeInputs then + attrs.propagatedBuildNativeInputs else []; in { builder = if attrs ? realBuilder then attrs.realBuilder else shell; @@ -57,7 +62,14 @@ let ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)]; stdenv = result; system = result.system; - buildInputs = buildInputs ++ buildNativeInputs; + + # That build by the cross compiler + buildInputs = []; + propagatedBuildInputs = []; + # That build by the usual native compiler + buildNativeInputs = buildInputs ++ buildNativeInputs; + propagatedBuildNativeInputs = propagatedBuildInputs ++ + propagatedBuildNativeInputs; })) ) # The meta attribute is passed in the resulting attribute set, diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index efd1abbe02a9..ac0a0b69e64d 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -153,6 +153,7 @@ runHook addInputsHook findInputs() { local pkg=$1 local var=$2 + local propagatedBuildInputsFile=$3 case ${!var} in *\ $pkg\ *) @@ -166,27 +167,26 @@ findInputs() { source $pkg/nix-support/setup-hook fi - if test -f $pkg/nix-support/propagated-build-inputs; then - for i in $(cat $pkg/nix-support/propagated-build-inputs); do + if test -f $pkg/nix-support/$propagatedBuildInputsFile; then + for i in $(cat $pkg/nix-support/$propagatedBuildInputsFile); do findInputs $i $var done fi } -pkgs="" +crossPkgs="" for i in $buildInputs $propagatedBuildInputs; do - findInputs $i pkgs + findInputs $i crossPkgs propagated-build-inputs done -hostPkgs="" -for i in $hostInputs $propagatedBuildInputs; do - findInputs $i hostPkgs +nativePkgs="" +for i in $buildNativeInputs $propagatedBuildNativeInputs; do + findInputs $i nativePkgs propagated-build-native-inputs done # Set the relevant environment variables to point to the build inputs # found above. -envHostHooks=() -addToEnv() { +addToNativeEnv() { local pkg=$1 if test -d $1/bin; then @@ -199,21 +199,22 @@ addToEnv() { done } -for i in $pkgs; do - addToEnv $i +for i in $nativePkgs; do + addToNativeEnv $i done -addToEnvHost() { +crossEnvHooks=() +addToCrossEnv() { local pkg=$1 # Run the package-specific hooks set by the setup-hook scripts. - for i in "${envHostHooks[@]}"; do + for i in "${crossEnvHooks[@]}"; do $i $pkg done } -for i in $hostPkgs; do - addToEnvHost $i +for i in $crossPkgs; do + addToCrossEnv $i done @@ -716,6 +717,11 @@ fixupPhase() { echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs" fi + if test -n "$propagatedBuildNativeInputs"; then + ensureDir "$out/nix-support" + echo "$propagatedBuildNativeInputs" > "$out/nix-support/propagated-build-native-inputs" + fi + if test -n "$setupHook"; then ensureDir "$out/nix-support" substituteAll "$setupHook" "$out/nix-support/setup-hook" |