[cfe-dev] Using Clang as a cross-compiler, build on Windows for Linux x86_64

Leander Bessa Beernaert leanderbb at gmail.com
Fri Nov 22 01:45:58 PST 2013


Hello,

I'm currently trying to get Clang to work as a cross compiler  in order to
enable my colleges to compile the code for Linux (x86_64) on Windows. So
far I have a working version GCC to cross compile my, so I have access to
the native linkers and binary tools on Windows.

I'm currently using the windows snapshot build of clang and I'm trying to
compile a simple hello world example in both C and C++. I invoke clang as
follows:

clang --target=x86_64-unknown-linux-gnu --toolchain=<toolchain-dir> main.c

clang++ --target=x86_64-unknown-linux-gnu --toolchain=<toolchain-dir>
main.cpp


At the moment I have the following issues:

1) I am unable to use the stdlib++ from the cross compiled GCC, am I
missing a flag?

2) I am unable to link the final binary for the C example, clang crashes
with the following output: http://justpaste.it/dnpb

In theory this should work right? Clang compiles the code to LLVM IR and
then uses the native linker to generate the object files, as far as I can
tell from the documentation. Or, should I compile Clang from source on
Linux, just like I did with GCC in order to have a working cross-compiler?

Leander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131122/a3d7fc73/attachment.html>


More information about the cfe-dev mailing list