Fixed some details on cross compilation. Among others:

- Stating better the guile dependencies (native/host) for guile to build
- Fixing cross-linking, through --rpath-link (ld(1) explains well about it
- Made gcc call the linker and the assembler through the gcc wrapper instead of
  directly. I thought this was the source of missing -rpath's, but the source
  of the problem ended up being the lack of --rpath-link. But I think the
  native gcc calls the wrapped ld and as, so let's do the same cross
  compiling.
- Removed the binutilsCross from the glibc expressions. Now they are built
  using the gcc-cross-wrapper, and they were built with the direct gcc and
  binutils before this change.
- I think patchelf and strip don't break the cross-compiled binaries, so I
  reallow them on cross compilation.
- I disable the checkPhase on cross compilation. This made gmp and libtool
  fail when cross compiled, iirc.


svn path=/nixpkgs/branches/stdenv-updates/; revision=18498
This commit is contained in:
Lluís Batlle i Rossell 2009-11-21 02:42:52 +00:00
parent a5fee3325a
commit a263cb814e
11 changed files with 28 additions and 25 deletions

View File

@ -17,7 +17,7 @@ if test -n "$nativeTools"; then
else
ldflags="$ldflags -L$gcc/lib"
gccPath="$gcc/bin"
ldPath="$binutils/bin"
ldPath="$binutils/$crossConfig/bin"
fi
@ -40,7 +40,8 @@ doSubstitute() {
--subst-var "cflagsLink" \
--subst-var "ldflags" \
--subst-var "ldflagsBefore" \
--subst-var-by "ld" "$ldPath/$crossConfig-ld"
--subst-var "ldPath" \
--subst-var-by "ld" "$ldPath/ld"
}

View File

@ -5,13 +5,13 @@
# stdenv.mkDerivation provides a wrapper that sets up the right environment
# variables so that the compiler and the linker just "work".
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
{ name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? ""
, gcc ? null, libc ? null, binutils ? null, shell ? "", cross ? ""
}:
assert nativeTools -> nativePrefix != "";
assert !nativeTools -> gcc != null && binutils != null;
assert !nativeLibc -> libc != null;
assert !noLibc -> (!nativeLibc -> libc != null);
stdenv.mkDerivation {
builder = ./builder.sh;

View File

@ -112,6 +112,8 @@ if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then
source "$NIX_GCC_WRAPPER_EXEC_HOOK"
fi
# We want gcc to call the wrapper linker, not that of binutils.
export PATH="@ldPath@:$PATH"
# Call the real `gcc'. Filter out warnings from stderr about unused
# `-B' flags, since they confuse some programs. Deep bash magic to

View File

@ -121,7 +121,7 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
# Finally, add `-rpath' switches.
for i in $rpath; do
extra=(${extra[@]} -rpath $i)
extra=(${extra[@]} -rpath $i -rpath-link $i)
done
fi

View File

@ -26,5 +26,6 @@ if test -n "@libc@"; then
fi
configureFlags="$configureFlags --build=$system --host=$crossConfig"
dontPatchELF=1
dontStrip=1
# Disabling the tests when cross compiling, as usually the tests are meant for
# native compilations.
doCheck=""

View File

@ -124,11 +124,6 @@ postInstall() {
ln -sfn g++ $i
fi
done
# gcc will look for the binutils there, called through collect2
if test -n "$crossConfig"; then
ln -s $binutilsCross/$crossConfig/bin $out/$crossConfig/bin
fi
}

View File

@ -9,13 +9,15 @@ stdenv.mkDerivation rec {
};
buildNativeInputs = [ makeWrapper ];
propagatedBuildInputs = [ libtool ];
propagatedBuildNativeInputs = [readline gmp gawk];
propagatedBuildInputs = [ libtool gmp ];
propagatedBuildNativeInputs = [readline gawk];
postInstall = ''
wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
'';
NIX_DEBUG=1;
preBuild = ''
sed -e '/lt_dlinit/a lt_dladdsearchdir("'$out/lib'");' -i libguile/dynl.c
'';

View File

@ -2,7 +2,6 @@
, installLocales ? true
, profilingLibraries ? false
, cross ? null
, binutilsCross ? null
, gccCross ? null
}:
@ -78,7 +77,7 @@ stdenv.mkDerivation rec {
"--without-fp"
] else []);
buildInputs = stdenv.lib.optionals (cross != null) [ binutilsCross gccCross ];
buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ];
preInstall = ''
ensureDir $out/lib

View File

@ -2,7 +2,6 @@
, installLocales ? true
, profilingLibraries ? false
, cross ? null
, binutilsCross ? null
, gccCross ? null
}:
@ -80,7 +79,7 @@ stdenv.mkDerivation rec {
"--without-fp"
] else []);
buildInputs = stdenv.lib.optionals (cross != null) [ binutilsCross gccCross ];
buildInputs = stdenv.lib.optionals (cross != null) [ gccCross ];
preInstall = ''
ensureDir $out/lib

View File

@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
sha256 = "1j5pklq36ivg2cim5wfysns229a544lqkimp3mlzkwjl513ra0ma";
};
buildInputs = [m4];
buildNativeInputs = [m4];
preConfigure = "ln -sf configfsf.guess config.guess";

View File

@ -1785,10 +1785,15 @@ let
crossStageStatic = false;
};
gccCrossStageStatic = cross: (gcc43_realCross cross).override {
crossStageStatic = true;
langCC = false;
glibcCross = null;
gccCrossStageStatic = cross: wrapGCCCross {
gcc = (gcc43_realCross cross).override {
crossStageStatic = true;
langCC = false;
glibcCross = null;
};
libc = null;
binutils = binutilsCross cross;
inherit cross;
};
gccCrossStageFinal = cross: wrapGCCCross {
@ -2218,6 +2223,7 @@ let
import ../build-support/gcc-cross-wrapper {
nativeTools = false;
nativeLibc = false;
noLibc = (libc == null);
inherit stdenv gcc binutils libc shell name cross;
};
@ -3415,7 +3421,6 @@ let
glibc29Cross = cross : makeOverridable (import ../development/libraries/glibc-2.9) {
inherit stdenv fetchurl cross;
binutilsCross = binutilsCross cross;
gccCross = gccCrossStageStatic cross;
kernelHeaders = kernelHeadersCross cross;
installLocales = getPkgConfig "glibc" "locales" false;
@ -3428,7 +3433,6 @@ let
glibc211Cross = cross : makeOverridable (import ../development/libraries/glibc-2.11) {
inherit stdenv fetchurl cross;
binutilsCross = binutilsCross cross;
gccCross = gccCrossStageStatic cross;
kernelHeaders = kernelHeadersCross cross;
installLocales = getPkgConfig "glibc" "locales" false;