Cross compiler

Dear All,
I am a newcommer. Terribly sorry for the basic questions whose answers may be out there somewhere.
My questions are the followings:
-With the front end clang, what can be the possible values for the -target parameter? Can I have a full list of them?
-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.

Thank you in advance for your helps
Son TRAN

-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