summary refs log tree commit diff
path: root/pkgs/build-support/gcc-wrapper
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2007-05-24 15:35:14 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2007-05-24 15:35:14 +0000
commit37aa92faec609a6d2b6869f56ae5cdf7272f2fd2 (patch)
tree7724e5fbee5ae74a8e0ab013682e26b591bb7fc6 /pkgs/build-support/gcc-wrapper
parent210f4950ac5b58f58a542100401e5d335e49d1b8 (diff)
downloadnixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.tar
nixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.tar.gz
nixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.tar.bz2
nixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.tar.lz
nixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.tar.xz
nixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.tar.zst
nixlib-37aa92faec609a6d2b6869f56ae5cdf7272f2fd2.zip
* Merge gcc-wrapper-new.
svn path=/nixpkgs/trunk/; revision=8758
Diffstat (limited to 'pkgs/build-support/gcc-wrapper')
-rw-r--r--pkgs/build-support/gcc-wrapper/gcc-wrapper.sh44
1 files changed, 27 insertions, 17 deletions
diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
index fda6b65c5251..a76684806b88 100644
--- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh
@@ -14,24 +14,34 @@ source @out@/nix-support/utils.sh
 # Figure out if linker flags should be passed.  GCC prints annoying
 # warnings when they are not needed.
 dontLink=0
-if test "$*" = "-v" -o -z "$*"; then
+getVersion=0
+nonFlagArgs=0
+
+for i in "$@"; do
+    if test "$i" = "-c"; then
+        dontLink=1
+    elif test "$i" = "-S"; then
+        dontLink=1
+    elif test "$i" = "-E"; then
+        dontLink=1
+    elif test "$i" = "-E"; then
+        dontLink=1
+    elif test "$i" = "-M"; then
+        dontLink=1
+    elif test "$i" = "-MM"; then
+        dontLink=1
+    elif test "${i:0:1}" != "-"; then
+        nonFlagArgs=1
+    fi
+done
+
+# If we pass a flag like -Wl, then gcc will call the linker unless it
+# can figure out that it has to do something else (e.g., because of a
+# "-c" flag).  So if no non-flag arguments are given, don't pass any
+# linker flags.  This catches cases like "gcc" (should just print
+# "gcc: no input files") and "gcc -v" (should print the version).
+if test "$nonFlagArgs" = "0"; then
     dontLink=1
-else
-    for i in "$@"; do
-        if test "$i" = "-c"; then
-            dontLink=1
-        elif test "$i" = "-S"; then
-            dontLink=1
-        elif test "$i" = "-E"; then
-            dontLink=1
-        elif test "$i" = "-E"; then
-            dontLink=1
-        elif test "$i" = "-M"; then
-            dontLink=1
-        elif test "$i" = "-MM"; then
-            dontLink=1
-        fi
-    done
 fi