diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc-4.5/builder.sh index 6c3ced85d754..adcb03ef4dd7 100644 --- a/pkgs/development/compilers/gcc-4.5/builder.sh +++ b/pkgs/development/compilers/gcc-4.5/builder.sh @@ -54,11 +54,52 @@ if test "$noSysDirs" = "1"; then EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i" done - if test -z "$targetConfig"; then - EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" - EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" + if test -n "$targetConfig"; then + # Cross-compiling, we need gcc not to read ./specs in order to build + # the g++ compiler (after the specs for the cross-gcc are created). + # Having LIBRARY_PATH= makes gcc read the specs from ., and the build + # breaks. Having this variable comes from the default.nix code to bring + # gcj in. + unset LIBRARY_PATH + unset CPATH + if test -z "$crossStageStatic"; then + EXTRA_TARGET_CFLAGS="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include" + EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib" + fi + else + if test -z "$NIX_GCC_CROSS"; then + EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" + EXTRA_TARGET_LDFLAGS="$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_TARGET_CFLAGS="$extraFlags" + for i in $extraLDFlags; do + EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -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 @@ -68,17 +109,17 @@ if test "$noSysDirs" = "1"; then NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS" \ + CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS" \ + LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \ ) if test -z "$targetConfig"; then makeFlagsArray=( \ "${makeFlagsArray[@]}" \ BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - BOOT_LDFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ + BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ ) fi @@ -161,7 +202,7 @@ postInstall() { } -if test -z "$targetConfig"; then +if test -z "$targetConfig" && test -z "$crossConfig"; then if test -z "$profiledCompiler"; then buildFlags="bootstrap $buildFlags" else diff --git a/pkgs/development/compilers/gcc-4.5/default.nix b/pkgs/development/compilers/gcc-4.5/default.nix index 0bdd0dd900a3..4c3fd8079afe 100644 --- a/pkgs/development/compilers/gcc-4.5/default.nix +++ b/pkgs/development/compilers/gcc-4.5/default.nix @@ -169,8 +169,9 @@ stdenv.mkDerivation ({ inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic libcCross crossMingw; - buildInputs = [ texinfo gmp mpfr mpc libelf gettext which ] - ++ (optional (perl != null) perl) + buildNativeInputs = [ texinfo which ] + ++ optional (perl != null) perl; + buildInputs = [ gmp mpfr mpc libelf gettext ] ++ (optional (ppl != null) ppl) ++ (optional (cloogppl != null) cloogppl) ++ (optionals langTreelang [bison flex]) @@ -225,6 +226,51 @@ stdenv.mkDerivation ({ targetConfig = if (cross != null) then cross.config else null; + 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} + "; + }; + + # Needed for the cross compilation to work AR = "ar"; LD = "ld"; diff --git a/pkgs/development/libraries/cloog-ppl/default.nix b/pkgs/development/libraries/cloog-ppl/default.nix index b1372d79cb50..5738f76682a8 100644 --- a/pkgs/development/libraries/cloog-ppl/default.nix +++ b/pkgs/development/libraries/cloog-ppl/default.nix @@ -12,6 +12,10 @@ stdenv.mkDerivation rec { configureFlags = "--with-ppl=${ppl}"; + crossAttrs = { + configureFlags = "--with-ppl=${ppl.hostDrv}"; + }; + doCheck = true; meta = { diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index f7f0cb0018ca..ddcfc327a9ee 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -26,6 +26,8 @@ stdenv.mkDerivation (rec { crossAttrs = { buildInputs = stdenv.lib.optional (stdenv.gccCross.libc ? libiconv) stdenv.gccCross.libc.libiconv.hostDrv; + # Gettext fails to guess the cross compiler + configureFlags = "CXX=${stdenv.cross.config}-g++"; }; meta = { diff --git a/pkgs/development/libraries/ppl/default.nix b/pkgs/development/libraries/ppl/default.nix index 9b52958b3e5e..cbe6ee21ecd6 100644 --- a/pkgs/development/libraries/ppl/default.nix +++ b/pkgs/development/libraries/ppl/default.nix @@ -9,7 +9,7 @@ let version = "0.10.2"; in sha256 = "0lly44sac4jd72klnhhil3wha15vak76r6gy88sh0zjsaww9hf6h"; }; - buildInputs = [ perl gnum4 ]; + buildNativeInputs = [ perl gnum4 ]; propagatedBuildInputs = [ gmpxx ]; # Beware! It took ~6 hours to compile PPL and run its tests on a 1.2 GHz diff --git a/pkgs/os-specific/linux/klibc/default.nix b/pkgs/os-specific/linux/klibc/default.nix index c3f5db58303f..5a27816472db 100644 --- a/pkgs/os-specific/linux/klibc/default.nix +++ b/pkgs/os-specific/linux/klibc/default.nix @@ -3,7 +3,7 @@ assert stdenv.isLinux; let - version = "1.5.15"; + version = "1.5.18"; baseMakeFlags = ["V=1" "prefix=$out" "SHLIBDIR=$out/lib"]; in @@ -11,8 +11,8 @@ stdenv.mkDerivation { name = "klibc-${version}"; src = fetchurl { - url = "mirror://kernel/linux/libs/klibc/klibc-${version}.tar.bz2"; - sha256 = "1x401wmjca6zkyikf9xz45b3wb1hnj0m2s9in1sg6xdhi3pk8lwb"; + url = "mirror://kernel/linux/libs/klibc/1.5/klibc-${version}.tar.bz2"; + sha256 = "0ik4ddkfzjrrhpb50i31f2zihqlcnm82yqnl5ci59wx56j5ly474"; }; makeFlags = baseMakeFlags; @@ -20,17 +20,14 @@ stdenv.mkDerivation { inherit linuxHeaders; crossAttrs = { - name = "klibc-1.5.17"; - src = fetchurl { - url = "mirror://kernel/linux/libs/klibc/Testing/klibc-1.5.17.tar.bz2"; - sha256 = "1jmiszf9pdlzj9f72nkv50d7aqrzz12hrmw792xnd2lmn5nrfyx6"; - }; - makeFlags = baseMakeFlags ++ [ "CROSS_COMPILE=${stdenv.cross.config}-" "KLIBCARCH=${stdenv.cross.arch}" ]; patchPhase = '' + sed -i 's/-fno-pic -mno-abicalls/& -mabi=32/' usr/klibc/arch/mips/MCONFIG sed -i /KLIBCKERNELSRC/d scripts/Kbuild.install + # Wrong check for __mips64 in klibc + sed -i s/__mips64__/__mips64/ usr/include/fcntl.h ''; linuxHeaders = linuxHeadersCross; diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix index 445a7f90fb62..5c941f064109 100644 --- a/pkgs/os-specific/linux/uclibc/default.nix +++ b/pkgs/os-specific/linux/uclibc/default.nix @@ -42,6 +42,10 @@ stdenv.mkDerivation { -e 's@.*UCLIBC_HAS_RPC.*@UCLIBC_HAS_RPC=y@' \ -e 's@.*DO_C99_MATH.*@DO_C99_MATH=y@' \ -e 's@.*UCLIBC_HAS_PROGRAM_INVOCATION_NAME.*@UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y@' \ + -e 's@.*CONFIG_MIPS_ISA_1.*@#CONFIG_MIPS_ISA_1=y@' \ + -e 's@.*CONFIG_MIPS_ISA_3.*@CONFIG_MIPS_ISA_3=y@' \ + -e 's@.*CONFIG_MIPS_O32_ABI.*@#CONFIG_MIPS_O32_ABI=y@' \ + -e 's@.*CONFIG_MIPS_N32_ABI.*@CONFIG_MIPS_N32_ABI=y@' \ ${configArmEABI} \ ${configBigEndian} \ -i .config diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 68f0b6ed74cb..56b361f6e807 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -187,7 +187,7 @@ let gccCrossStageFinal; stdenv = - if bootStdenv != null then bootStdenv else + if bootStdenv != null then (bootStdenv // {inherit platform;}) else let changer = getConfig ["replaceStdenv"] null; in if changer != null then changer {