3
0
Fork 0
forked from mirrors/nixpkgs

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

View file

@ -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;
});

View file

@ -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,

View file

@ -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"

View file

@ -4195,7 +4195,7 @@ let
};
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
# don't build for me in unicode.
unicode = (system != "i686-cygwin" && ! (stdenv ? cross));