summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
diff options
context:
space:
mode:
authorEric Seidel <gridaphobe@gmail.com>2015-01-12 22:00:21 -0800
committerPeter Simons <simons@cryp.to>2015-01-14 11:24:59 +0100
commita92afcd34a9e1535083a7b97fd8a5ceb6c04287c (patch)
treec9a5a4279103cfa0a6a74da4697e3e9f473f12d2 /pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
parent1b50c504326ed88d8cf76111a35e2490990ad619 (diff)
downloadnixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.tar
nixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.tar.gz
nixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.tar.bz2
nixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.tar.lz
nixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.tar.xz
nixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.tar.zst
nixpkgs-a92afcd34a9e1535083a7b97fd8a5ceb6c04287c.zip
ghc-7.8.4: fix build on Darwin
https://github.com/NixOS/nixpkgs/pull/5746
Diffstat (limited to 'pkgs/development/compilers/ghc/gcc-clang-wrapper.sh')
-rwxr-xr-xpkgs/development/compilers/ghc/gcc-clang-wrapper.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh b/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
new file mode 100755
index 00000000000..d081be231a1
--- /dev/null
+++ b/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+inPreprocessorMode () {
+    hasE=0
+    hasU=0
+    hasT=0
+    for arg in "$@"
+    do
+        if [ 'x-E' = "x$arg" ];             then hasE=1; fi
+        if [ 'x-undef' = "x$arg" ];         then hasU=1; fi
+        if [ 'x-traditional' = "x$arg" ];   then hasT=1; fi
+    done
+    [ "$hasE$hasU$hasT" = '111' ]
+}
+
+extraClangArgs="-Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
+
+adjustPreprocessorLanguage () {
+    newArgs=''
+    while [ $# -gt 0 ]
+    do
+        newArgs="$newArgs $1"
+        if [ "$1" = '-x' ]
+        then
+            shift
+            if [ $# -gt 0 ]
+            then
+                if [ "$1" = 'c' ]
+                then
+                    newArgs="$newArgs assembler-with-cpp"
+                else
+                    newArgs="$newArgs $1"
+                fi
+            fi
+        fi
+        shift
+    done
+    echo $newArgs
+}
+
+if inPreprocessorMode "$@"
+then
+    exec clang $extraClangArgs `adjustPreprocessorLanguage "$@"`
+else
+    exec clang $extraClangArgs "${@/-nodefaultlibs/}"
+fi