Skip to content

Instantly share code, notes, and snippets.

@xianyi
Created June 20, 2012 02:39
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save xianyi/2957847 to your computer and use it in GitHub Desktop.
Save xianyi/2957847 to your computer and use it in GitHub Desktop.
Replace the native OS X assembler (/usr/bin/as) by a script which calls the clang assembler. (http://old.nabble.com/Re%3a-gcc,-as,-AVX,-binutils-and-MacOS-X-10.7-p32584737.html)
#!/bin/sh
HAS_INPUT_FILE=0
ARGS=$@
while [ $# -ne 0 ]; do
ARG=$1
# Skip options
if [ $ARG == "-arch" ] || [ $ARG == "-o" ]; then
# Skip next token
shift
shift
continue
fi
if [ `echo $ARG | head -c1` == "-" ]; then
shift
continue
fi
HAS_INPUT_FILE=1
break
done
if [ $HAS_INPUT_FILE -eq 1 ]; then
clang -c -x assembler $ARGS
else
clang -c -x assembler $ARGS -
fi
@anders-sjogren
Copy link

Thanks a bunch for this!
When I use it with include flags (e.g. g++ -I/opt/local/include/), then I get warnings such as
clang: warning: argument unused during compilation: '-I /opt/local/include/'
Would it be possible to filter out includes from $ARGS before passing them into clang?

@gustavengstrom
Copy link

Thanks this solved my problem! I had installing xgboost which gave me the following error: FATAL:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!
I noticed something was wrong with the assembler since running $as --version also gave me a similar error. Replacing /usr/bin/as with the above solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment