mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
Making gcc cross-buildable, at least for glibc.
svn path=/nixpkgs/branches/stdenv-updates/; revision=20454
This commit is contained in:
parent
3b54414f31
commit
f36f99e368
@ -1,5 +1,8 @@
|
||||
source $stdenv/setup
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
mkdir $out/nix-support
|
||||
|
||||
# Force gcc to use ld-wrapper.sh when calling ld.
|
||||
cflagsCompile="-B$out/bin/"
|
||||
@ -9,6 +12,23 @@ if test -z "$nativeLibc"; then
|
||||
ldflags="$ldflags -L$libc/lib"
|
||||
ldflagsBefore="-dynamic-linker $libc/lib/ld-linux.so.?"
|
||||
#ldflagsBefore="-dynamic-linker $libc/lib/ld-uClibc.so.0"
|
||||
|
||||
# The same as above, but put into files, useful for the gcc builder.
|
||||
dynamicLinker="$libc/lib/$dynamicLinker"
|
||||
echo $dynamicLinker > $out/nix-support/dynamic-linker
|
||||
|
||||
if test -e $libc/lib/32/ld-linux.so.2; then
|
||||
echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
|
||||
fi
|
||||
|
||||
echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
|
||||
|
||||
echo "-L$libc/lib" > $out/nix-support/libc-ldflags
|
||||
|
||||
# The dynamic linker is passed in `ldflagsBefore' to allow
|
||||
# explicit overrides of the dynamic linker by callers to gcc/ld
|
||||
# (the *last* value counts, so ours should come first).
|
||||
echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before
|
||||
fi
|
||||
|
||||
if test -n "$nativeTools"; then
|
||||
@ -21,11 +41,6 @@ else
|
||||
fi
|
||||
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
mkdir $out/nix-support
|
||||
|
||||
|
||||
doSubstitute() {
|
||||
local src=$1
|
||||
local dst=$2
|
||||
|
@ -61,10 +61,39 @@ if test "$noSysDirs" = "1"; then
|
||||
EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib"
|
||||
fi
|
||||
else
|
||||
EXTRA_FLAGS_TARGET="$EXTRA_FLAGS"
|
||||
EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS"
|
||||
if test -z "$NIX_GCC_CROSS"; then
|
||||
EXTRA_FLAGS_TARGET="$EXTRA_FLAGS"
|
||||
EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS"
|
||||
else
|
||||
# This the case of cross-building the gcc.
|
||||
# We need special flags for the target, different than those of the build
|
||||
# Assertion:
|
||||
test -e $NIX_GCC_CROSS/nix-support/orig-libc
|
||||
|
||||
# Figure out what extra flags to pass to the gcc compilers
|
||||
# being generated to make sure that they use our glibc.
|
||||
extraFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-cflags)"
|
||||
extraLDFlags="$(cat $NIX_GCC_CROSS/nix-support/libc-ldflags) $(cat $NIX_GCC_CROSS/nix-support/libc-ldflags-before)"
|
||||
|
||||
# Use *real* header files, otherwise a limits.h is generated
|
||||
# that does not include Glibc's limits.h (notably missing
|
||||
# SSIZE_MAX, which breaks the build).
|
||||
NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include
|
||||
|
||||
# The path to the Glibc binaries such as `crti.o'.
|
||||
glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib"
|
||||
|
||||
extraFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY_CROSS $extraFlags"
|
||||
extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags"
|
||||
|
||||
EXTRA_FLAGS_TARGET="$extraFlags"
|
||||
for i in $extraLDFlags; do
|
||||
EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS_TARGET -Wl,$i"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
|
||||
# the startfiles.
|
||||
# FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
|
||||
@ -160,7 +189,7 @@ postInstall() {
|
||||
}
|
||||
|
||||
|
||||
if test -z "$targetConfig"; then
|
||||
if test -z "$targetConfig" && test -z "$crossConfig"; then
|
||||
if test -z "$profiledCompiler"; then
|
||||
buildFlags="bootstrap $buildFlags"
|
||||
else
|
||||
|
@ -115,7 +115,9 @@ stdenv.mkDerivation ({
|
||||
inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic
|
||||
libcCross;
|
||||
|
||||
buildInputs = [ texinfo gmp mpfr gettext which ]
|
||||
buildNativeInputs = [ texinfo which ];
|
||||
|
||||
buildInputs = [ gmp mpfr gettext ]
|
||||
++ (optional (ppl != null) ppl)
|
||||
++ (optional (cloogppl != null) cloogppl)
|
||||
++ (optionals langTreelang [bison flex])
|
||||
@ -165,6 +167,50 @@ stdenv.mkDerivation ({
|
||||
LD = "ld";
|
||||
CC = "gcc";
|
||||
|
||||
crossAttrs = {
|
||||
AR = "${stdenv.cross.config}-ar";
|
||||
LD = "${stdenv.cross.config}-ld";
|
||||
CC = "${stdenv.cross.config}-gcc";
|
||||
CXX = "${stdenv.cross.config}-gcc";
|
||||
AR_FOR_TARGET = "${stdenv.cross.config}-ar";
|
||||
LD_FOR_TARGET = "${stdenv.cross.config}-ld";
|
||||
CC_FOR_TARGET = "${stdenv.cross.config}-gcc";
|
||||
NM_FOR_TARGET = "${stdenv.cross.config}-nm";
|
||||
CXX_FOR_TARGET = "${stdenv.cross.config}-g++";
|
||||
# If we are making a cross compiler, cross != null
|
||||
NIX_GCC_CROSS = if cross == null then "${stdenv.gccCross}" else "";
|
||||
configureFlags = "
|
||||
${if enableMultilib then "" else "--disable-multilib"}
|
||||
${if enableShared then "" else "--disable-shared"}
|
||||
${if ppl != null then "--with-ppl=${ppl.hostDrv}" else ""}
|
||||
${if cloogppl != null then "--with-cloog=${cloogppl.hostDrv}" else ""}
|
||||
${if langJava then "--with-ecj-jar=${javaEcj.hostDrv}" else ""}
|
||||
${if javaAwtGtk then "--enable-java-awt=gtk" else ""}
|
||||
${if langJava && javaAntlr != null then "--with-antlr-jar=${javaAntlr.hostDrv}" else ""}
|
||||
--with-gmp=${gmp.hostDrv}
|
||||
--with-mpfr=${mpfr.hostDrv}
|
||||
--disable-libstdcxx-pch
|
||||
--without-included-gettext
|
||||
--with-system-zlib
|
||||
--enable-languages=${
|
||||
concatStrings (intersperse ","
|
||||
( optional langC "c"
|
||||
++ optional langCC "c++"
|
||||
++ optional langFortran "fortran"
|
||||
++ optional langJava "java"
|
||||
++ optional langTreelang "treelang"
|
||||
++ optional langAda "ada"
|
||||
++ optional langVhdl "vhdl"
|
||||
)
|
||||
)
|
||||
}
|
||||
${if langAda then " --enable-libada" else ""}
|
||||
${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""}
|
||||
${if cross != null then crossConfigureFlags else ""}
|
||||
--target=${stdenv.cross.config}
|
||||
";
|
||||
};
|
||||
|
||||
# Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find
|
||||
# the library headers and binaries, regarless of the language being
|
||||
# compiled.
|
||||
|
@ -179,7 +179,9 @@ rec {
|
||||
in buildDrv // {
|
||||
inherit hostDrv buildDrv;
|
||||
};
|
||||
} // { inherit cross; };
|
||||
} // {
|
||||
inherit cross gccCross binutilsCross;
|
||||
};
|
||||
|
||||
|
||||
/* Modify a stdenv so that the specified attributes are added to
|
||||
|
@ -725,6 +725,7 @@ in {
|
||||
linuxPackages_2_6_32.kernel = linux;
|
||||
linuxPackages_2_6_33.kernel = linux;
|
||||
gdbCross = nativePlatforms;
|
||||
gcc44_real.gcc = linux;
|
||||
});
|
||||
}) // (
|
||||
|
||||
@ -760,6 +761,7 @@ in {
|
||||
linuxPackages_2_6_32.kernel = linux;
|
||||
linuxPackages_2_6_33.kernel = linux;
|
||||
gdbCross = nativePlatforms;
|
||||
gcc44_real.gcc = linux;
|
||||
});
|
||||
}) // (
|
||||
|
||||
@ -796,5 +798,6 @@ in {
|
||||
linuxPackages_2_6_32.kernel = linux;
|
||||
linuxPackages_2_6_33.kernel = linux;
|
||||
gdbCross = nativePlatforms;
|
||||
gcc44_real.gcc = linux;
|
||||
});
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user