Skip to content

Instantly share code, notes, and snippets.

@xianyi xianyi/as
Created Jun 20, 2012

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

anders-sjogren commented Nov 13, 2014

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

This comment has been minimized.

Copy link

gustavengstrom commented Sep 6, 2017

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
You can’t perform that action at this time.