summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2010-08-01 21:21:26 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2010-08-01 21:21:26 +0000
commitda3ba13fb57d4c9415f42906772c180f7ac9486c (patch)
tree2674fb7d7520c1cdb0c72fb145f2f06357f97f78 /pkgs/development
parent2954596106c5d6e96c9f121573a05baf4bc8630d (diff)
downloadnixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.tar
nixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.tar.gz
nixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.tar.bz2
nixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.tar.lz
nixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.tar.xz
nixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.tar.zst
nixpkgs-da3ba13fb57d4c9415f42906772c180f7ac9486c.zip
Trying to make gcc 4.5 cross-buildable
svn path=/nixpkgs/branches/stdenv-updates/; revision=22848
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/gcc-4.5/builder.sh55
-rw-r--r--pkgs/development/compilers/gcc-4.5/default.nix50
-rw-r--r--pkgs/development/libraries/cloog-ppl/default.nix4
-rw-r--r--pkgs/development/libraries/gettext/default.nix2
-rw-r--r--pkgs/development/libraries/ppl/default.nix2
5 files changed, 103 insertions, 10 deletions
diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc-4.5/builder.sh
index 6c3ced85d75..adcb03ef4dd 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 0bdd0dd900a..4c3fd8079af 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 b1372d79cb5..5738f76682a 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 f7f0cb0018c..ddcfc327a9e 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 9b52958b3e5..cbe6ee21ecd 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