about summary refs log tree commit diff
path: root/pkgs/stdenv/generic/gcc-wrapper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/stdenv/generic/gcc-wrapper.sh')
-rw-r--r--pkgs/stdenv/generic/gcc-wrapper.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/stdenv/generic/gcc-wrapper.sh b/pkgs/stdenv/generic/gcc-wrapper.sh
new file mode 100644
index 0000000000000..f68612d2c1e77
--- /dev/null
+++ b/pkgs/stdenv/generic/gcc-wrapper.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+IFS=
+
+justcompile=0
+for i in $@; do
+    if test "$i" == "-c"; then
+        justcompile=1
+    elif test "$i" == "-S"; then
+        justcompile=1
+    elif test "$i" == "-E"; then
+        justcompile=1
+    elif test "$i" == "-E"; then
+        justcompile=1
+    elif test "$i" == "-M"; then
+        justcompile=1
+    elif test "$i" == "-MM"; then
+        justcompile=1
+    fi
+done
+
+IFS=" "
+extra=($NIX_CFLAGS_COMPILE)
+if test "$justcompile" != "1"; then
+    extra=(${extra[@]} $NIX_CFLAGS_LINK)
+    for i in $NIX_LDFLAGS; do
+        extra=(${extra[@]} "-Wl,$i")
+    done
+    if test "$NIX_STRIP_DEBUG" == "1"; then
+        extra=(${extra[@]} -g0 -Wl,-s)
+    fi
+fi
+
+if test "$NIX_DEBUG" == "1"; then
+  echo "extra flags to @GCC@:" >&2
+  for i in ${extra[@]}; do
+      echo "  $i" >&2
+  done
+fi
+
+IFS=
+exec @GCC@ $@ ${extra[@]}