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

Joerg Sonnenberger joerg at britannica.bec.de
Fri May 17 05:19:15 PDT 2013


On Wed, Apr 24, 2013 at 05:08:51PM +0200, Stephen Kelly wrote:
> 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 
> great.

clang looks for as and ld helper programs in the paths specified with -B
followed by $PATH. It is first looking for an executable file named
"${triple}-as" / "${triple-ld}" and then for "as" / "ld". So in your
case, it should just work, if you invoke clang with -target
arm-linux-gnueabi or as arm-linux-gnueabi-clang.

The --sysroot option is used for finding header files and libraries. For
linking, it depends on ld implementing sysroot support itself.

Joerg



More information about the cfe-dev mailing list