[LLVMdev] Cross compiler

Renato Golin renato.golin at linaro.org
Fri Feb 8 04:28:39 PST 2013


On 7 February 2013 22:35, SON TRAN <soq2000 at yahoo.com> wrote:

> -With the front end clang, what can be the possible values for the -target
> parameter? Can I have a full list of them?
>

Hi Son,

I'm not sure there is a dynamic list, but if you're feeling adventurous,
check the ToolChain.cpp in Clang's source.


-How can I create a (static) library from the object files as with the
> command "ar" in linux ? I wonder whether I should use llvm-ar. But then I
> can not link the resulting file as a lib with clang.
>


You should use the GNU binutils for your target. Unfortunately, LLVM
doesn't provide that part, but most of the time it integrates nicely with
it if you're compiling natively.

On cross-compilation, you'll have to inform where the tools are with
passing the argument "-gcc-toolchain myarch-gcc" with that being the path
to your gcc (it should find the rest from it). You should also need to
provide the include path of most headers, if your toolchain doesn't have
the structure clang is expecting (happens with most modern toolchains,
unfortunately).

As an example, I use the command line below to cross-compile to ARM:

$ clang -target armv7a-linux-gnueabihf -gcc-toolchain
arm-linux-gnueabihf-gcc -I /usr/arm-linux-gnueabihf/include/c++/4.7.2/ -I
/usr/arm-linux-gnueabihf/include/c++/4.7.2/arm-linux-gnueabihf/ -I
/usr/arm-linux-gnueabihf/include/

Since I have the Ubuntu package gcc-4.7-arm-linux-gnueabihf and all its
dependencies installed.

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130208/588e17b1/attachment.html>


More information about the llvm-dev mailing list