[cfe-dev] Targeting ARM with Clang

David McNamara david.mcnamara at crescentbaysoftware.com
Fri Jul 16 13:06:57 PDT 2010


 I am just learning about clang/ llvm now and I have a very simple 
question (and I must be missing something easy) but can someone answer 
how I can use clang to create an ARM executable?

I've downloaded clang + llvm and built them together on an x86 system 
using the default configuration -- which I believe is to build all 
targets. Here is some information:

 163) llvm-config --version

165) llvm-config --targets-built
x86 sparc powerpc alpha arm mips cellspu pic16 xcore msp430 systemz 
blackfin cbackend msil cppbackend mblaze

166) clang --version
clang version 2.0 (trunk 105977)
Target: x86_64-unknown-linux-gnu
Thread model: posix

 167) clang -arch arm main.c
clang: warning: argument unused during compilation: '-arch arm'

The resulting a.out is an x86 executable.

168) clang -march=arm main.c
'arm' is not a recognized processor for this target (ignoring processor)

 169) clang -march=armv7 main.c
'armv7' is not a recognized processor for this target (ignoring processor)

(I've tried various armxx names)

It tried generating assembler for arm by using clang with -emit-llvm and 
 llc -march=arm main.bc  (no complaint)

But the resulting main.s will not compile with an arm-compiler that I 
currently have.

Isn't there is a way to simply generate an executable for an 
arm-platform using "clang [option] main.c"?

I just noticed this -- isn't the default build for clang to build a 
native compiler (not something that uses gcc)??

195) clang -target-cpu=arm main.c
gcc: unrecognized option '-target-cpu=arm'
gcc: unrecognized option '-target-cpu=arm'

Thanks in advance!

David McNamara

More information about the cfe-dev mailing list