Making the definition of the cross compiling target an attribute set.

svn path=/nixpkgs/branches/stdenv-updates/; revision=18378
This commit is contained in:
Lluís Batlle i Rossell 2009-11-16 23:21:13 +00:00
parent d82c7e0a69
commit 2c7fa189fb
11 changed files with 51 additions and 42 deletions

View file

@ -60,24 +60,24 @@ mkGccWrapper() {
chmod +x "$dst" chmod +x "$dst"
} }
mkGccWrapper $out/bin/$cross-gcc $gccPath/$cross-gcc mkGccWrapper $out/bin/$crossConfig-gcc $gccPath/$crossConfig-gcc
#ln -s gcc $out/bin/cc #ln -s gcc $out/bin/cc
mkGccWrapper $out/bin/g++ $gccPath/g++ mkGccWrapper $out/bin/$crossConfig-g++ $gccPath/$crossConfig-g++
ln -s g++ $out/bin/c++ ln -s $crossConfig-g++ $out/bin/$crossConfig-c++
mkGccWrapper $out/bin/g77 $gccPath/g77 mkGccWrapper $out/bin/$crossConfig-g77 $gccPath/$crossConfig-g77
ln -s g77 $out/bin/f77 ln -s $crossConfig-g77 $out/bin/$crossConfig-f77
ln -s $binutils/bin/$cross-ar $out/bin/$cross-ar ln -s $binutils/bin/$crossConfig-ar $out/bin/$crossConfig-ar
ln -s $binutils/bin/$cross-as $out/bin/$cross-as ln -s $binutils/bin/$crossConfig-as $out/bin/$crossConfig-as
ln -s $binutils/bin/$cross-nm $out/bin/$cross-nm ln -s $binutils/bin/$crossConfig-nm $out/bin/$crossConfig-nm
ln -s $binutils/bin/$cross-strip $out/bin/$cross-strip ln -s $binutils/bin/$crossConfig-strip $out/bin/$crossConfig-strip
# Make a wrapper around the linker. # Make a wrapper around the linker.
doSubstitute "$ldWrapper" "$out/bin/$cross-ld" doSubstitute "$ldWrapper" "$out/bin/$crossConfig-ld"
chmod +x "$out/bin/$cross-ld" chmod +x "$out/bin/$crossConfig-ld"
# Emit a setup hook. Also store the path to the original GCC and # Emit a setup hook. Also store the path to the original GCC and

View file

@ -20,7 +20,8 @@ stdenv.mkDerivation {
ldWrapper = ./ld-wrapper.sh; ldWrapper = ./ld-wrapper.sh;
utils = ./utils.sh; utils = ./utils.sh;
addFlags = ./add-flags; addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix gcc libc binutils cross; inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
crossConfig = if (cross != null) then cross.config else null;
name = if name == "" then gcc.name else name; name = if name == "" then gcc.name else name;
langC = if nativeTools then true else gcc.langC; langC = if nativeTools then true else gcc.langC;
langCC = if nativeTools then true else gcc.langCC; langCC = if nativeTools then true else gcc.langCC;

View file

@ -40,7 +40,7 @@ if test "$noSysDirs" = "1"; then
export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i" export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
done done
if test -n "$cross"; then if test -n "$crossConfig"; then
if test -z "$crossStageStatic"; then if test -z "$crossStageStatic"; then
extraXCFlags="-B${glibcCross}/lib -idirafter ${glibcCross}/include" extraXCFlags="-B${glibcCross}/lib -idirafter ${glibcCross}/include"
extraXLDFlags="-L${glibcCross}/lib" extraXLDFlags="-L${glibcCross}/lib"
@ -71,7 +71,7 @@ if test "$noSysDirs" = "1"; then
) )
fi fi
if test -n "$cross" -a "$crossStageStatic" == 1; then if test -n "$crossConfig" -a "$crossStageStatic" == 1; then
# We don't want the gcc build to assume there will be a libc providing # We don't want the gcc build to assume there will be a libc providing
# limits.h in this stagae # limits.h in this stagae
makeFlagsArray=( \ makeFlagsArray=( \
@ -86,8 +86,8 @@ if test "$noSysDirs" = "1"; then
fi fi
fi fi
if test -n "$cross"; then if test -n "$crossConfig"; then
# The host stripp will destroy everything in the target binaries otherwise # The host strip will destroy everything in the target binaries otherwise
dontStrip=1 dontStrip=1
fi fi
@ -126,13 +126,13 @@ postInstall() {
done done
# gcc will look for the binutils there, called through collect2 # gcc will look for the binutils there, called through collect2
if test -n "$cross"; then if test -n "$crossConfig"; then
ln -s $binutilsCross/$cross/bin $out/$cross/bin ln -s $binutilsCross/$crossConfig/bin $out/$crossConfig/bin
fi fi
} }
if test -z "$cross"; then if test -z "$crossConfig"; then
if test -z "$profiledCompiler"; then if test -z "$profiledCompiler"; then
buildFlags="bootstrap $buildFlags" buildFlags="bootstrap $buildFlags"
else else

View file

@ -27,7 +27,7 @@ with stdenv.lib;
let let
version = "4.3.4"; version = "4.3.4";
crossConfigureFlags = crossConfigureFlags =
"--target=${cross}" + "--target=${cross.config}" +
(if crossStageStatic then (if crossStageStatic then
" --disable-libssp --disable-nls" + " --disable-libssp --disable-nls" +
" --without-headers" + " --without-headers" +
@ -43,7 +43,7 @@ let
); );
stageNameAddon = if (crossStageStatic) then "-stage-static" else stageNameAddon = if (crossStageStatic) then "-stage-static" else
"-stage-final"; "-stage-final";
crossNameAddon = if (cross != null) then "-${cross}" + stageNameAddon else ""; crossNameAddon = if (cross != null) then "-${cross.config}" + stageNameAddon else "";
in in
@ -76,8 +76,9 @@ stdenv.mkDerivation ({
++ optional (noSysDirs && langFortran) ./no-sys-dirs-fortran.patch ++ optional (noSysDirs && langFortran) ./no-sys-dirs-fortran.patch
++ optional langJava ./java-jvgenmain-link.patch; ++ optional langJava ./java-jvgenmain-link.patch;
inherit noSysDirs profiledCompiler staticCompiler cross crossStageStatic inherit noSysDirs profiledCompiler staticCompiler crossStageStatic
binutilsCross glibcCross; binutilsCross glibcCross;
crossConfig = if (cross != null) then cross.config else null;
buildInputs = [texinfo gmp mpfr] buildInputs = [texinfo gmp mpfr]
++ (optionals langTreelang [bison flex]) ++ (optionals langTreelang [bison flex])

View file

@ -29,7 +29,7 @@ preConfigure() {
tar xvjf "$srcPorts" tar xvjf "$srcPorts"
if test -n "$cross"; then if test -n "$crossConfig"; then
sed -i s/-lgcc_eh//g Makeconfig sed -i s/-lgcc_eh//g Makeconfig
fi fi
@ -37,16 +37,16 @@ preConfigure() {
cd build cd build
configureScript=../configure configureScript=../configure
if test -n "$cross"; then if test -n "$crossConfig"; then
cat > config.cache << "EOF" cat > config.cache << "EOF"
libc_cv_forced_unwind=yes libc_cv_forced_unwind=yes
libc_cv_c_cleanup=yes libc_cv_c_cleanup=yes
libc_cv_gnu89_inline=yes libc_cv_gnu89_inline=yes
EOF EOF
export BUILD_CC=gcc export BUILD_CC=gcc
export CC="${cross}-gcc" export CC="${crossConfig}-gcc"
export AR="${cross}-ar" export AR="${crossConfig}-ar"
export RANLIB="${cross}-ranlib" export RANLIB="${crossConfig}-ranlib"
configureFlags="${configureFlags} --cache-file=config.cache" configureFlags="${configureFlags} --cache-file=config.cache"
# The host stripp will destroy everything in the target binaries otherwise # The host stripp will destroy everything in the target binaries otherwise

View file

@ -8,7 +8,7 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "glibc-2.9" + name = "glibc-2.9" +
stdenv.lib.optionalString (cross != null) "-${cross}"; stdenv.lib.optionalString (cross != null) "-${cross.config}";
builder = ./builder.sh; builder = ./builder.sh;
@ -22,7 +22,8 @@ stdenv.mkDerivation rec {
sha256 = "0r2sn527wxqifi63di7ns9wbjh1cainxn978w178khhy7yw9fk42"; sha256 = "0r2sn527wxqifi63di7ns9wbjh1cainxn978w178khhy7yw9fk42";
}; };
inherit kernelHeaders installLocales cross; inherit kernelHeaders installLocales;
crossConfig = if (cross != null) then cross.config else null;
inherit (stdenv) is64bit; inherit (stdenv) is64bit;
@ -67,7 +68,7 @@ stdenv.mkDerivation rec {
"--with-headers=${kernelHeaders}/include" "--with-headers=${kernelHeaders}/include"
(if profilingLibraries then "--enable-profile" else "--disable-profile") (if profilingLibraries then "--enable-profile" else "--disable-profile")
] ++ stdenv.lib.optionals (cross != null) [ ] ++ stdenv.lib.optionals (cross != null) [
"--host=${cross}" "--host=${cross.config}"
"--build=${stdenv.system}" "--build=${stdenv.system}"
"--with-tls" "--with-tls"
"--enable-kernel=2.6.0" "--enable-kernel=2.6.0"

View file

@ -4,7 +4,7 @@ let
basename = "binutils-2.20"; basename = "binutils-2.20";
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = basename + stdenv.lib.optionalString (cross != null) "-${cross}"; name = basename + stdenv.lib.optionalString (cross != null) "-${cross.config}";
src = fetchurl { src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2"; url = "mirror://gnu/binutils/${basename}.tar.bz2";
@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
''; '';
configureFlags = "--disable-werror" # needed for dietlibc build configureFlags = "--disable-werror" # needed for dietlibc build
+ stdenv.lib.optionalString (cross != null) " --target=${cross}"; + stdenv.lib.optionalString (cross != null) " --target=${cross.config}";
meta = { meta = {
description = "GNU Binutils, tools for manipulating binaries (linker, assembler, etc.)"; description = "GNU Binutils, tools for manipulating binaries (linker, assembler, etc.)";

View file

@ -14,11 +14,10 @@ stdenv.mkDerivation {
sha256 = "0hifjh75sinifr5138v22zwbpqln6lhn65k8b57a1dyzlqca7cl9"; sha256 = "0hifjh75sinifr5138v22zwbpqln6lhn65k8b57a1dyzlqca7cl9";
}; };
inherit cross; crossConfig = if (cross != null) then cross.config else null;
platform = platform =
if cross == "armv5tel-unknown-linux-gnueabi" then "arm" else if cross != null then cross.arch else
assert(cross == null);
if stdenv.system == "i686-linux" then "i386" else if stdenv.system == "i686-linux" then "i386" else
if stdenv.system == "x86_64-linux" then "x86_64" else if stdenv.system == "x86_64-linux" then "x86_64" else
if stdenv.system == "powerpc-linux" then "powerpc" else if stdenv.system == "powerpc-linux" then "powerpc" else
@ -29,14 +28,16 @@ stdenv.mkDerivation {
buildInputs = [perl]; buildInputs = [perl];
extraIncludeDirs = extraIncludeDirs =
if stdenv.system == "powerpc-linux" then ["ppc"] else []; if cross != null then
(if cross.arch == "powerpc" then ["ppc"] else [])
else if stdenv.system == "powerpc-linux" then ["ppc"] else [];
patchPhase = '' patchPhase = ''
sed -i '/scsi/d' include/Kbuild sed -i '/scsi/d' include/Kbuild
''; '';
buildPhase = '' buildPhase = ''
if test -n "$cross"; then if test -n "$crossConfig"; then
export ARCH=$platform export ARCH=$platform
fi fi
make mrproper headers_check make mrproper headers_check

View file

@ -18,7 +18,7 @@ let
result = result =
derivation { derivation {
inherit system name cross; inherit system name;
builder = shell; builder = shell;
@ -55,7 +55,7 @@ let
system = result.system; system = result.system;
# The env variable 'cross' is used in all the crosscompiler # The env variable 'cross' is used in all the crosscompiler
# bootstrapping in another sense # bootstrapping in another sense
crossTarget = result.cross; crossTarget = if (cross != null) then cross.config else null;
}) })
) )
# The meta attribute is passed in the resulting attribute set, # The meta attribute is passed in the resulting attribute set,

View file

@ -206,7 +206,7 @@ rec {
# dependency (`nix-store -qR') on bootstrapTools. # dependency (`nix-store -qR') on bootstrapTools.
stdenvLinux = import ../generic { stdenvLinux = import ../generic {
name = "stdenv-linux" + name = "stdenv-linux" +
stdenvLinuxBoot3Pkgs.lib.optionalString (cross != null) "-${cross}"; stdenvLinuxBoot3Pkgs.lib.optionalString (cross != null) "-${cross.config}";
inherit system cross; inherit system cross;
@ -221,7 +221,7 @@ rec {
postHook = if (cross != null) then postHook = if (cross != null) then
(builtins.toFile "cross-posthook.sh" '' (builtins.toFile "cross-posthook.sh" ''
configureFlags="$configureFlags --build=${system} --host=${cross}" configureFlags="$configureFlags --build=${system} --host=${cross.config}"
dontStrip=1 dontStrip=1
'') '')
else null; else null;

View file

@ -2720,7 +2720,12 @@ let
bisonArm = import ../development/tools/parsing/bison/bison-2.3.nix { bisonArm = import ../development/tools/parsing/bison/bison-2.3.nix {
inherit fetchurl m4; inherit fetchurl m4;
stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi"; stdenv = stdenvCross {
config = "armv5tel-unknown-linux-gnueabi";
bigEndian = false;
arch = "arm";
float = "soft";
};
}; };
bison1875 = import ../development/tools/parsing/bison/bison-1.875.nix { bison1875 = import ../development/tools/parsing/bison/bison-1.875.nix {