diff options
author | Peter Simons <simons@cryp.to> | 2015-06-12 10:54:02 +0200 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2015-06-12 10:54:02 +0200 |
commit | 85ae0cb070628bcb98e63e6166fd6f52045f385a (patch) | |
tree | d88045acdbe080859dadae9fe59b149bfe07c6ff /pkgs/development/compilers/ghc/gcc-clang-wrapper.sh | |
parent | 33e70ad68a13efc14187a0657d447c26cf765cb7 (diff) | |
download | nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.tar nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.tar.gz nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.tar.bz2 nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.tar.lz nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.tar.xz nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.tar.zst nixlib-85ae0cb070628bcb98e63e6166fd6f52045f385a.zip |
ghc: move gcc-clang-wrapper.sh script into the ghc directory tree since it's the only user of that script
Diffstat (limited to 'pkgs/development/compilers/ghc/gcc-clang-wrapper.sh')
-rwxr-xr-x | pkgs/development/compilers/ghc/gcc-clang-wrapper.sh | 46 |
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 000000000000..d081be231a1c --- /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 |