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
This commit is contained in:
Lluís Batlle i Rossell 2009-11-19 23:05:11 +00:00
parent 40e564c87c
commit 6f3630e128
5 changed files with 60 additions and 29 deletions

View File

@ -8,7 +8,7 @@ addCVars () {
fi fi
} }
envHooksHost=(${envHooksHost[@]} addCVars) crossEnvHooks=(${crossEnvHooks[@]} addCVars)
# Note: these come *after* $out in the PATH (see setup.sh). # Note: these come *after* $out in the PATH (see setup.sh).
@ -25,4 +25,3 @@ if test -n "@glibc@"; then
fi fi
configureFlags="$configureFlags --build=$system --host=$crossConfig" configureFlags="$configureFlags --build=$system --host=$crossConfig"
dontStrip=1

View File

@ -111,20 +111,34 @@ rec {
# builds. # builds.
makeStdenvCross = stdenv: cross: binutilsCross: gccCross: stdenv // makeStdenvCross = stdenv: cross: binutilsCross: gccCross: stdenv //
{ mkDerivation = {name, buildInputs ? [], buildNativeInputs ? [], { mkDerivation = {name, buildInputs ? [], buildNativeInputs ? [],
propagatedBuildInputs ? [], ...}@args: let propagatedBuildInputs ? [], propagatedBuildNativeInputs ? [], ...}@args: let
# propagatedBuildInputs exists temporarily as another name for
# propagatedHostInputs. # *BuildInputs exists temporarily as another name for
# *HostInputs.
getBuildDrv = drv : if (drv ? buildDrv) then drv.buildDrv else drv; getBuildDrv = drv : if (drv ? buildDrv) then drv.buildDrv else drv;
buildInputsDrvs = map (getBuildDrv) buildNativeInputs; buildNativeInputsDrvs = map (getBuildDrv) buildNativeInputs;
hostInputsDrvs = map (drv: drv.hostDrv) buildInputs; buildInputsDrvs = map (drv: drv.hostDrv) buildInputs;
hostInputsDrvsAsBuildInputs = map (getBuildDrv) buildInputs; buildInputsDrvsAsBuildInputs = map (getBuildDrv) buildInputs;
propagatedHostInputsDrvs = map (drv: drv.buildDrv) (propagatedBuildInputs); 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; 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 hostDrv = if (cross == null) then buildDrv else
stdenv.mkDerivation (args // { stdenv.mkDerivation (args // {
name = name + "-" + cross.config; name = name + "-" + cross.config;
buildInputs = buildInputsDrvs buildNativeInputs = buildNativeInputsDrvs
++ [ gccCross binutilsCross ]; ++ [ gccCross binutilsCross ];
buildInputs = buildInputsDrvs;
propagatedBuildInputs = propagatedBuildInputsDrvs;
propagatedBuildNativeInputs = propagatedBuildNativeInputsDrvs;
crossConfig = cross.config; crossConfig = cross.config;
}); });

View File

@ -48,8 +48,13 @@ let
// (let // (let
buildInputs = if attrs ? buildInputs then attrs.buildInputs buildInputs = if attrs ? buildInputs then attrs.buildInputs
else []; else [];
buildNativeInputs = if attrs ? buildNativeInputs then attrs.buildNativeInputs buildNativeInputs = if attrs ? buildNativeInputs then
else []; attrs.buildNativeInputs else [];
propagatedBuildInputs = if attrs ? propagatedBuildInputs then
attrs.propagatedBuildInputs else [];
propagatedBuildNativeInputs = if attrs ?
propagatedBuildNativeInputs then
attrs.propagatedBuildNativeInputs else [];
in in
{ {
builder = if attrs ? realBuilder then attrs.realBuilder else shell; 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)]; ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)];
stdenv = result; stdenv = result;
system = result.system; 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, # The meta attribute is passed in the resulting attribute set,

View File

@ -153,6 +153,7 @@ runHook addInputsHook
findInputs() { findInputs() {
local pkg=$1 local pkg=$1
local var=$2 local var=$2
local propagatedBuildInputsFile=$3
case ${!var} in case ${!var} in
*\ $pkg\ *) *\ $pkg\ *)
@ -166,27 +167,26 @@ findInputs() {
source $pkg/nix-support/setup-hook source $pkg/nix-support/setup-hook
fi fi
if test -f $pkg/nix-support/propagated-build-inputs; then if test -f $pkg/nix-support/$propagatedBuildInputsFile; then
for i in $(cat $pkg/nix-support/propagated-build-inputs); do for i in $(cat $pkg/nix-support/$propagatedBuildInputsFile); do
findInputs $i $var findInputs $i $var
done done
fi fi
} }
pkgs="" crossPkgs=""
for i in $buildInputs $propagatedBuildInputs; do for i in $buildInputs $propagatedBuildInputs; do
findInputs $i pkgs findInputs $i crossPkgs propagated-build-inputs
done done
hostPkgs="" nativePkgs=""
for i in $hostInputs $propagatedBuildInputs; do for i in $buildNativeInputs $propagatedBuildNativeInputs; do
findInputs $i hostPkgs findInputs $i nativePkgs propagated-build-native-inputs
done done
# Set the relevant environment variables to point to the build inputs # Set the relevant environment variables to point to the build inputs
# found above. # found above.
envHostHooks=() addToNativeEnv() {
addToEnv() {
local pkg=$1 local pkg=$1
if test -d $1/bin; then if test -d $1/bin; then
@ -199,21 +199,22 @@ addToEnv() {
done done
} }
for i in $pkgs; do for i in $nativePkgs; do
addToEnv $i addToNativeEnv $i
done done
addToEnvHost() { crossEnvHooks=()
addToCrossEnv() {
local pkg=$1 local pkg=$1
# Run the package-specific hooks set by the setup-hook scripts. # Run the package-specific hooks set by the setup-hook scripts.
for i in "${envHostHooks[@]}"; do for i in "${crossEnvHooks[@]}"; do
$i $pkg $i $pkg
done done
} }
for i in $hostPkgs; do for i in $crossPkgs; do
addToEnvHost $i addToCrossEnv $i
done done
@ -716,6 +717,11 @@ fixupPhase() {
echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs" echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
fi 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 if test -n "$setupHook"; then
ensureDir "$out/nix-support" ensureDir "$out/nix-support"
substituteAll "$setupHook" "$out/nix-support/setup-hook" substituteAll "$setupHook" "$out/nix-support/setup-hook"

View File

@ -4195,7 +4195,7 @@ let
}; };
ncurses = makeOverridable (composedArgsAndFun (import ../development/libraries/ncurses)) { ncurses = makeOverridable (composedArgsAndFun (import ../development/libraries/ncurses)) {
inherit fetchurl stdenv; inherit fetchurl stdenv ncurses;
# The "! (stdenv ? cross)" is for the cross-built arm ncurses, which # The "! (stdenv ? cross)" is for the cross-built arm ncurses, which
# don't build for me in unicode. # don't build for me in unicode.
unicode = (system != "i686-cygwin" && ! (stdenv ? cross)); unicode = (system != "i686-cygwin" && ! (stdenv ? cross));