[cfe-dev] Cross compiling with clang (and sysroot support)

Stephen Kelly steveire at gmail.com
Wed Apr 24 08:08:51 PDT 2013

Tim Northover wrote:

> Hi Stephen,
> I'm afraid I'm not sure when Clang started accepting sysroot; someone
> else will probably have to answer that.
>> stephen at hal:~/tmp$ clang -target armv7--eabi -mcpu=cortex-a9 main.c
>> gcc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
>> /tmp/main-EitGh6.s: Assembler messages:
>> /tmp/main-EitGh6.s:1: Error: unknown pseudo-op: `.syntax'
> This is because Clang has decided to call (probably) the host's
> assembler, /usr/bin/as, to assemble the ARM code it just produced.
> That's obviously not going to work very well if your host is x86.
> It would actually use the --sysroot option (amongst other things) to
> try and find appropriate headers/assembler/linker/... if it was
> present. Whether it could actually find them or not is another matter,
> of course. The code is rather heuristic.

Thanks for the information. I don't really know where to find an appropriate 
assembler to point clang to. I have several gcc based toolchains on this 
computer, so I guess I should point to the as executable in one of those? 
How would I specify it? 

 /usr/bin/arm-linux-gnueabi-gcc-4.7 main.c

'Just Works'. /usr/bin/arm-linux-gnueabi-as also exists. Should I use that? 
All I need is some way to cross compile something for some platform, so if I 
can invoke clang in a way that it will use that cross-as, that would be 



More information about the cfe-dev mailing list