summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/fetchurl/mirrors.nix5
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/builder.sh31
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/default.nix20
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh16
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/setup-hook.sh6
-rw-r--r--pkgs/build-support/gcc-wrapper/default.nix21
-rw-r--r--pkgs/build-support/gcc-wrapper/default2.nix72
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-wrapper.sh30
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-wrapper2.sh154
9 files changed, 93 insertions, 262 deletions
diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix
index abb133cd50a1..2b4e382928f6 100644
--- a/pkgs/build-support/fetchurl/mirrors.nix
+++ b/pkgs/build-support/fetchurl/mirrors.nix
@@ -122,14 +122,9 @@ rec {
     http://ftp.cc.uoc.gr/mirrors/nongnu.org/
     http://ftp.twaren.net/Unix/NonGNU/
     http://mirror.csclub.uwaterloo.ca/nongnu/
-    http://mirror.publicns.net/pub/nongnu/
     http://nongnu.askapache.com/
-    http://nongnu.bigsearcher.com/
     http://savannah.c3sl.ufpr.br/
     http://www.centervenus.com/mirrors/nongnu/
-    http://www.de-mirrors.de/nongnu/
-    http://www.very-clever.com/download/nongnu/
-    http://www.wikifusion.info/nongnu/
   ];
 
   # BitlBee mirrors, see http://www.bitlbee.org/main.php/mirrors.html .
diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh
index 674c2b89b526..fae37342940f 100644
--- a/pkgs/build-support/gcc-cross-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh
@@ -1,34 +1,51 @@
 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/"
 
 if test -z "$nativeLibc"; then
-    cflagsCompile="$cflagsCompile -B$libc/lib/ -isystem $libc/include"
+    cflagsCompile="$cflagsCompile -B$gccLibs/lib -B$libc/lib/ -isystem $libc/include"
     ldflags="$ldflags -L$libc/lib"
     # Get the proper dynamic linker for glibc and uclibc. 
     dlinker=`eval 'echo $libc/lib/ld*.so.?'`
     if [ -n "$dlinker" ]; then
       ldflagsBefore="-dynamic-linker $dlinker"
+
+      # The same as above, but put into files, useful for the gcc builder.
+      echo $dlinker > $out/nix-support/dynamic-linker
+      # This trick is to avoid dependencies on the cross-toolchain gcc
+      # for libgcc, libstdc++, ...
+      # -L is for libtool's .la files, and -rpath for the usual fixupPhase
+      # shrinking rpaths.
+      if [ -n "$gccLibs" ]; then
+        ldflagsBefore="$ldflagsBefore -rpath $gccLibs/lib"
+      fi
     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 "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
 fi
 
 if test -n "$nativeTools"; then
     gccPath="$nativePrefix/bin"
     ldPath="$nativePrefix/bin"
 else
-    ldflags="$ldflags -L$gcc/lib"
+    ldflags="$ldflags -L$gcc/lib -L$gcc/lib64"
     gccPath="$gcc/bin"
     ldPath="$binutils/$crossConfig/bin"
 fi
 
 
-mkdir $out
-mkdir $out/bin
-mkdir $out/nix-support
-
-
 doSubstitute() {
     local src=$1
     local dst=$2
diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix
index 362e378273dd..8bf820e3d341 100644
--- a/pkgs/build-support/gcc-cross-wrapper/default.nix
+++ b/pkgs/build-support/gcc-cross-wrapper/default.nix
@@ -13,6 +13,23 @@ assert nativeTools -> nativePrefix != "";
 assert !nativeTools -> gcc != null && binutils != null;
 assert !noLibc -> (!nativeLibc -> libc != null);
 
+let
+  chosenName = if name == "" then gcc.name else name;
+  gccLibs = stdenv.mkDerivation {
+    name = chosenName + "-libs";
+    phases = [ "installPhase" ];
+    installPhase = ''
+      echo $out
+      ensureDir $out
+      cp -Rd ${gcc}/${cross.config}/lib $out/lib
+      chmod -R +w $out/lib
+      for a in $out/lib/*.la; do
+          sed -i -e s,${gcc}/${cross.config}/lib,$out/lib,g $a
+      done
+      rm -f $out/lib/*.py
+    '';
+  };
+in
 stdenv.mkDerivation {
   builder = ./builder.sh;
   setupHook = ./setup-hook.sh;
@@ -22,7 +39,8 @@ stdenv.mkDerivation {
   addFlags = ./add-flags;
   inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
   crossConfig = if (cross != null) then cross.config else null;
-  name = if name == "" then gcc.name else name;
+  gccLibs = if gcc != null then gccLibs else null;
+  name = chosenName;
   langC = if nativeTools then true else gcc.langC;
   langCC = if nativeTools then true else gcc.langCC;
   langF77 = if nativeTools then false else gcc ? langFortran;
diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
index 491de8f7f984..98baafb4878d 100644
--- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
@@ -75,14 +75,18 @@ if test "$dontLink" != "1"; then
     # Add the flags that should be passed to the linker (and prevent
     # `ld-wrapper' from adding NIX_CROSS_LDFLAGS again).
     for i in $NIX_CROSS_LDFLAGS_BEFORE; do
-        extraBefore=(${extraBefore[@]} "-Wl,$i")
+        if test "${i:0:3}" = "-L/"; then
+            extraBefore=(${extraBefore[@]} "$i")
+        else
+            extraBefore=(${extraBefore[@]} "-Wl,$i")
+        fi
     done
     for i in $NIX_CROSS_LDFLAGS; do
-	if test "${i:0:3}" = "-L/"; then
-	    extraAfter=(${extraAfter[@]} "$i")
-	else
-	    extraAfter=(${extraAfter[@]} "-Wl,$i")
-	fi
+        if test "${i:0:3}" = "-L/"; then
+            extraAfter=(${extraAfter[@]} "$i")
+        else
+            extraAfter=(${extraAfter[@]} "-Wl,$i")
+        fi
     done
     export NIX_CROSS_LDFLAGS_SET=1
 
diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
index 0c98062a2db1..a7be09283ee0 100644
--- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
@@ -26,7 +26,7 @@ crossStripDirs() {
     dirs=${dirsNew}
 
     if test -n "${dirs}"; then
-        header "stripping (with flags $stripFlags) in $dirs"
+        header "cross stripping (with flags $stripFlags) in $dirs"
         # libc_nonshared.a should never be stripped, or builds will break.
         find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true
         stopNest
@@ -68,7 +68,9 @@ if test -n "@libc@"; then
     crossAddCVars @libc@
 fi
 
-configureFlags="$configureFlags --build=$system --host=$crossConfig"
+if test "$dontSetConfigureCross" != "1"; then
+    configureFlags="$configureFlags --build=$system --host=$crossConfig"
+fi
 # Disabling the tests when cross compiling, as usually the tests are meant for
 # native compilations.
 doCheck=""
diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix
index c97fd4eb495d..4e486f8fc646 100644
--- a/pkgs/build-support/gcc-wrapper/default.nix
+++ b/pkgs/build-support/gcc-wrapper/default.nix
@@ -50,7 +50,25 @@ stdenv.mkDerivation {
   langAda = if nativeTools then false else gcc ? langAda && gcc.langAda;
   langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl;
   zlib = if (gcc != null && gcc ? langVhdl) then zlib else null;
-  shell = if shell == "" then stdenv.shell else shell;
+  shell = if shell == "" then stdenv.shell else
+    if builtins.isAttrs shell then (shell + shell.shellPath)
+    else shell;
+
+  crossAttrs = {
+    shell = shell.hostDrv + shell.hostDrv.shellPath;
+    libc = libc.hostDrv;
+    coreutils = coreutils.hostDrv;
+    binutils = binutils.hostDrv;
+    gcc = gcc.hostDrv;
+    #
+    # This is not the best way to do this. I think the reference should be
+    # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I
+    # do this sufficient if/else.
+    dynamicLinker = 
+      (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else
+       if stdenv.cross.arch == "mips" then "ld.so.1" else
+       abort "don't know the name of the dynamic linker for this platform");
+  };
   
   meta =
     let gcc_ = if gcc != null then gcc else {}; in
@@ -67,6 +85,7 @@ stdenv.mkDerivation {
        if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
        if stdenv.system == "armv5tel-linux" then "ld-linux.so.3" else
        if stdenv.system == "powerpc-linux" then "ld.so.1" else
+       if stdenv.system == "mips64-linux" then "ld.so.1" else
        abort "don't know the name of the dynamic linker for this platform")
     else "";
 }
diff --git a/pkgs/build-support/gcc-wrapper/default2.nix b/pkgs/build-support/gcc-wrapper/default2.nix
deleted file mode 100644
index efade01963b7..000000000000
--- a/pkgs/build-support/gcc-wrapper/default2.nix
+++ /dev/null
@@ -1,72 +0,0 @@
-# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't
-# know where the C library and standard header files are.  Therefore
-# the compiler produced by that package cannot be installed directly
-# in a user environment and used from the command line.  This
-# stdenv.mkDerivation provides a wrapper that sets up the right environment
-# variables so that the compiler and the linker just "work".
-
-{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
-, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
-, zlib ? null
-}:
-
-assert nativeTools -> nativePrefix != "";
-assert !nativeTools -> gcc != null && binutils != null && coreutils != null;
-assert !nativeLibc -> libc != null;
-
-# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper
-assert (gcc != null && gcc ? langVhdl && gcc.langVhdl) -> zlib != null;
-
-let
-
-  gccVersion = (builtins.parseDrvName gcc.name).version;
-  gccName = (builtins.parseDrvName gcc.name).name;
-  
-in
-
-stdenv.mkDerivation {
-  name =
-    (if name != "" then name else gccName + "-wrapper") +
-    (if gcc != null && gccVersion != "" then "-" + gccVersion else "");
-  
-  builder = ./builder.sh;
-  setupHook = ./setup-hook.sh;
-  gccWrapper = ./gcc-wrapper.sh;
-  gnatWrapper = ./gnat-wrapper.sh;
-  gnatlinkWrapper = ./gnatlink-wrapper.sh;
-  ldWrapper = ./ld-wrapper2.sh;
-  utils = ./utils.sh;
-  addFlags = ./add-flags;
-  
-  inherit nativeTools nativeLibc nativePrefix gcc;
-  libc = if nativeLibc then null else libc;
-  binutils = if nativeTools then null else binutils;
-  # The wrapper scripts use 'cat', so we may need coreutils
-  coreutils = if nativeTools then null else coreutils;
-  
-  langC = if nativeTools then true else gcc.langC;
-  langCC = if nativeTools then true else gcc.langCC;
-  langFortran = if nativeTools then false else gcc ? langFortran;
-  langAda = if nativeTools then false else gcc ? langAda && gcc.langAda;
-  langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl;
-  zlib = if (gcc != null && gcc ? langVhdl) then zlib else null;
-  shell = if shell == "" then stdenv.shell else shell;
-  
-  meta =
-    let gcc_ = if gcc != null then gcc else {}; in
-    (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //
-    { description =
-        stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_
-        + " (wrapper script)";
-    };
-
-  # The dynamic linker has different names on different Linux platforms.
-  dynamicLinker =
-    if !nativeLibc then
-      (if stdenv.system == "i686-linux" then "ld-linux.so.2" else
-       if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
-       if stdenv.system == "armv5tel-linux" then "ld-linux.so.3" else
-       if stdenv.system == "powerpc-linux" then "ld.so.1" else
-       abort "don't know the name of the dynamic linker for this platform")
-    else "";
-}
diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
index 3ca9e815a8f1..99ba3968ae33 100644
--- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
@@ -82,6 +82,13 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
         rpath="$rpath $1 "
     }
 
+    libs=""
+    addToLibs() {
+        libs="$libs $1"
+    }
+
+    rpath=""
+
     # First, find all -L... switches.
     allParams=("${params[@]}" ${extra[@]})
     n=0
@@ -93,6 +100,11 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
         elif test "$p" = "-L"; then
             addToLibPath ${p2}
             n=$((n + 1))
+        elif test "$p" = "-l"; then
+            addToLibs ${p2}
+            n=$((n + 1))
+        elif test "${p:0:2}" = "-l"; then
+            addToLibs ${p:2}
         elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
             # This is a direct reference to a shared library, so add
             # its directory to the rpath.
@@ -105,24 +117,14 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
     # Second, for each directory in the library search path (-L...),
     # see if it contains a dynamic library used by a -l... flag.  If
     # so, add the directory to the rpath.
-    rpath=""
     
-    for i in $libPath; do
-        n=0
-        while test $n -lt ${#allParams[*]}; do
-            p=${allParams[n]}
-            p2=${allParams[$((n+1))]}
-            if test "${p:0:2}" = "-l" -a -f "$i/lib${p:2}.so"; then
-                addToRPath $i
-                break
-            elif test "$p" = "-l" -a -f "$i/lib${p2}"; then
-                # I haven't seen `-l foo', but you never know...
-                addToRPath $i
+    for i in $libs; do
+        for j in $libPath; do
+            if test -f "$j/lib$i.so"; then
+                addToRPath $j
                 break
             fi
-            n=$((n + 1))
         done
-            
     done
     
 
diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper2.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper2.sh
deleted file mode 100644
index 99ba3968ae33..000000000000
--- a/pkgs/build-support/gcc-wrapper/ld-wrapper2.sh
+++ /dev/null
@@ -1,154 +0,0 @@
-#! @shell@ -e
-
-if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
-    source "$NIX_LD_WRAPPER_START_HOOK"
-fi
-
-if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then
-    source @out@/nix-support/add-flags.sh
-fi
-
-source @out@/nix-support/utils.sh
-
-
-# Optionally filter out paths not refering to the store.
-params=("$@")
-if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
-        -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
-    rest=()
-    n=0
-    while test $n -lt ${#params[*]}; do
-        p=${params[n]}
-        p2=${params[$((n+1))]}
-        if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
-            skip $p
-        elif test "$p" = "-L" && badPath "$p2"; then
-            n=$((n + 1)); skip $p2
-        elif test "$p" = "-rpath" && badPath "$p2"; then
-            n=$((n + 1)); skip $p2
-        elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
-            n=$((n + 1)); skip $p2
-        elif test "${p:0:1}" = "/" && badPath "$p"; then
-            # We cannot skip this; barf.
-            echo "impure path \`$p' used in link" >&2
-            exit 1
-        else
-            rest=("${rest[@]}" "$p")
-        fi
-        n=$((n + 1))
-    done
-    params=("${rest[@]}")
-fi
-
-
-extra=()
-extraBefore=()
-
-if test -z "$NIX_LDFLAGS_SET"; then
-    extra=(${extra[@]} $NIX_LDFLAGS)
-    extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE)
-fi
-
-
-# Add all used dynamic libraries to the rpath.
-if test "$NIX_DONT_SET_RPATH" != "1"; then
-
-    libPath=""
-    addToLibPath() {
-        local path="$1"
-        if test "${path:0:1}" != "/"; then return 0; fi
-        case "$path" in
-            *..*|*./*|*/.*|*//*)
-                local path2
-                if path2=$(readlink -f "$path"); then
-                    path="$path2"
-                fi
-                ;;
-        esac
-        case $libPath in
-            *\ $path\ *) return 0 ;;
-        esac
-        libPath="$libPath $path "
-    }
-    
-    addToRPath() {
-        # If the path is not in the store, don't add it to the rpath.
-        # This typically happens for libraries in /tmp that are later
-        # copied to $out/lib.  If not, we're screwed.
-        if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi
-        case $rpath in
-            *\ $1\ *) return 0 ;;
-        esac
-        rpath="$rpath $1 "
-    }
-
-    libs=""
-    addToLibs() {
-        libs="$libs $1"
-    }
-
-    rpath=""
-
-    # First, find all -L... switches.
-    allParams=("${params[@]}" ${extra[@]})
-    n=0
-    while test $n -lt ${#allParams[*]}; do
-        p=${allParams[n]}
-        p2=${allParams[$((n+1))]}
-        if test "${p:0:3}" = "-L/"; then
-            addToLibPath ${p:2}
-        elif test "$p" = "-L"; then
-            addToLibPath ${p2}
-            n=$((n + 1))
-        elif test "$p" = "-l"; then
-            addToLibs ${p2}
-            n=$((n + 1))
-        elif test "${p:0:2}" = "-l"; then
-            addToLibs ${p:2}
-        elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
-            # This is a direct reference to a shared library, so add
-            # its directory to the rpath.
-            path="$(dirname "$p")";
-            addToRPath "${path}"
-        fi
-        n=$((n + 1))
-    done
-
-    # Second, for each directory in the library search path (-L...),
-    # see if it contains a dynamic library used by a -l... flag.  If
-    # so, add the directory to the rpath.
-    
-    for i in $libs; do
-        for j in $libPath; do
-            if test -f "$j/lib$i.so"; then
-                addToRPath $j
-                break
-            fi
-        done
-    done
-    
-
-    # Finally, add `-rpath' switches.
-    for i in $rpath; do
-        extra=(${extra[@]} -rpath $i)
-    done
-fi
-
-
-# Optionally print debug info.
-if test "$NIX_DEBUG" = "1"; then
-  echo "original flags to @ld@:" >&2
-  for i in "${params[@]}"; do
-      echo "  $i" >&2
-  done
-  echo "extra flags to @ld@:" >&2
-  for i in ${extra[@]}; do
-      echo "  $i" >&2
-  done
-fi
-
-if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
-    source "$NIX_LD_WRAPPER_EXEC_HOOK"
-fi
-
-exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}