summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-02-01 21:26:28 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-02-01 21:26:28 +0000
commit472a0d2057a71b816af9e88c39ceafacc160ad9c (patch)
treecf2c8e7a9322fa46f4e2a1977b719400c06cdd91
parent15258b7f50a71b092a9cfec99e396b5fb9bb5f4f (diff)
downloadnixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.tar
nixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.tar.gz
nixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.tar.bz2
nixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.tar.lz
nixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.tar.xz
nixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.tar.zst
nixpkgs-472a0d2057a71b816af9e88c39ceafacc160ad9c.zip
* Pass -rpath flags in the same order as -L flags.
* Put the Glibc linker flags in front of the GCC linker flags.  Needed
  for the stdenv-linux bootstrap.

svn path=/nixpkgs/branches/stdenv-updates/; revision=13940
-rw-r--r--pkgs/build-support/gcc-wrapper/add-flags10
-rw-r--r--pkgs/build-support/gcc-wrapper/ld-wrapper.sh37
2 files changed, 24 insertions, 23 deletions
diff --git a/pkgs/build-support/gcc-wrapper/add-flags b/pkgs/build-support/gcc-wrapper/add-flags
index ace0a789628..02755e44541 100644
--- a/pkgs/build-support/gcc-wrapper/add-flags
+++ b/pkgs/build-support/gcc-wrapper/add-flags
@@ -5,16 +5,16 @@ if test -e @out@/nix-support/libc-cflags; then
     export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE"
 fi
 
-if test -e @out@/nix-support/libc-ldflags; then
-    export NIX_LDFLAGS="$(cat @out@/nix-support/libc-ldflags) $NIX_LDFLAGS"
-fi
-
 if test -e @out@/nix-support/gcc-cflags; then
     export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE"
 fi
 
+if test -e @out@/nix-support/libc-ldflags; then
+    export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)"
+fi
+
 if test -e @out@/nix-support/gcc-ldflags; then
-    export NIX_LDFLAGS="$(cat @out@/nix-support/gcc-ldflags) $NIX_LDFLAGS"
+    export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)"
 fi
 
 if test -e @out@/nix-support/libc-ldflags-before; then
diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
index 94241e42ce9..962adf43861 100644
--- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh
@@ -85,9 +85,11 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
         n=$((n + 1))
     done
 
-    # Second, for each -l... switch, find the directory containing the
-    # library and add it to the rpath.
+    # 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=""
+    
     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
@@ -98,26 +100,25 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
         esac
         rpath="$rpath $1 "
     }
-    findLib() {
-        for i in $libPath; do
-            if test -f $i/lib$1.so; then
+
+    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
+                break
             fi
-        done
-    }
-    n=0
-    while test $n -lt ${#allParams[*]}; do
-        p=${allParams[n]}
-        p2=${allParams[$((n+1))]}
-        if test "${p:0:2}" = "-l"; then
-            findLib ${p:2}
-        elif test "$p" = "-l"; then
-            # I haven't seen `-l foo', but you never know...
-            findLib ${p2}
             n=$((n + 1))
-        fi
-        n=$((n + 1))
+        done
+            
     done
+    
 
     # Finally, add `-rpath' switches.
     for i in $rpath; do