Fixing many things related to the cross compilation in stdenvCross.

It still does not work, but I think I already get glibc cross compiled.
Next: gcc and g++, and set some setup script hooks on stdenvCross.

It took quite enough hours for this commit.


svn path=/nixpkgs/branches/stdenv-updates/; revision=18351
This commit is contained in:
Lluís Batlle i Rossell
2009-11-15 05:28:35 +00:00
parent 2aba922d30
commit 9b977f5c60
8 changed files with 168 additions and 47 deletions

View File

@@ -43,13 +43,30 @@ if test "$noSysDirs" = "1"; then
"${makeFlagsArray[@]}" \
NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
LIMITS_H_TEST=true \
X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
)
if test -n "$cross" -a "$crossStageStatic" == 1; then
# We don't want the gcc build to assume there will be a libc providing
# limits.h in this stagae
makeFlagsArray=( \
"${makeFlagsArray[@]}" \
LIMITS_H_TEST=false \
)
else
makeFlagsArray=( \
"${makeFlagsArray[@]}" \
LIMITS_H_TEST=true \
)
fi
fi
if test -n "$cross"; then
# The host stripp will destroy everything in the target binaries otherwise
dontStrip=1
fi
preConfigure() {
# Perform the build in a different directory.
@@ -84,15 +101,24 @@ postInstall() {
ln -sfn g++ $i
fi
done
# gcc will look for the binutils there, called through collect2
if test -n "$cross"; then
ln -s $binutilsCross/$cross/bin $out/$cross/bin
fi
}
if test -n "$cross"; then
if test -z "$cross"; then
if test -z "$profiledCompiler"; then
buildFlags="bootstrap $buildFlags"
else
buildFlags="profiledbootstrap $buildFlags"
fi
else
:
# buildFlags="all-gcc all-target-libgcc $buildFlags"
# installTargets="install-gcc install-target-libgcc"
fi
genericBuild

View File

@@ -13,19 +13,38 @@
, cross ? null
, binutilsCross ? null
, glibcHeadersCross ? null
, crossStageStatic ? true
}:
assert langTreelang -> bison != null && flex != null;
assert cross != null -> profiledCompiler == false && enableMultilib == true;
assert (cross != null && crossStageStatic) -> (langCC == false && langFortran
== false && langTreelang == false);
with stdenv.lib;
let version = "4.3.4"; in
let
version = "4.3.4";
crossConfigureFlags =
"--target=${cross}" +
(if crossStageStatic then
" --disable-libssp --disable-nls" +
" --without-headers" +
" --disable-threads " +
" --disable-libmudflap " +
" --disable-libgomp " +
" --disable-shared" else
" --with-headers=${glibcHeadersCross}"
);
stageNameAddon = if (crossStageStatic) then "-stage-static" else
"-stage-final";
crossNameAddon = if (cross != null) then "-${cross}" + stageNameAddon else "";
in
stdenv.mkDerivation ({
name = "${name}-${version}" +
stdenv.lib.optionalString (cross != null) "-${cross}";
name = "${name}-${version}" + crossNameAddon;
builder = ./builder.sh;
@@ -53,7 +72,7 @@ stdenv.mkDerivation ({
++ optional (noSysDirs && langFortran) ./no-sys-dirs-fortran.patch
++ optional langJava ./java-jvgenmain-link.patch;
inherit noSysDirs profiledCompiler staticCompiler;
inherit noSysDirs profiledCompiler staticCompiler cross crossStageStatic binutilsCross;
buildInputs = [texinfo gmp mpfr]
++ (optionals langTreelang [bison flex])
@@ -78,9 +97,7 @@ stdenv.mkDerivation ({
)
}
${if stdenv.isi686 then "--with-arch=i686" else ""}
${if cross != null then "--disable-libssp --disable-nls" +
" --with-headers=${glibcHeadersCross}/include --target=${cross}" +
" --disable-shared" else ""}
${if cross != null then crossConfigureFlags else ""}
";
#Above I added a hack on making the build different than the host.