I'm under Ubuntu 12.04 x86 64 bit, I have compiled a 32 bit version of llvm/clang
from the official svn repository successfully.
I'm now trying to compile c++ code for ARM, at this point i don't care about platform versions like armv5
vs armv7a
, I'm focusing on how the platform switch works for clang
:
llvm-config --targets-built
ARM CellSPU CppBackend Hexagon Mips MBlaze MSP430 NVPTX PowerPC Sparc X86 XCore
but the following command doesn't work
clang++ -arch arm soft.cpp -o soft_ARM
the output is
clang-3: warning: argument unused during compilation: '-arch arm'
I have also tried gcc-like variants or other combinations like -arch=arm
, -arch=armv7a
, -march=armv5
but nothing seems to work.
After reading some docs i noticed that clang works for ARM only under MAC OS X / Darwin and it's not supposed to work for ARM under other OS.
How i can compile for ARM with clang and what the output of llvm-config --targets-built
is really about ?
On the other hand, Clang/LLVM is natively a cross-compiler, meaning that one set of programs can compile to all targets by setting the -target option.
The Clang tool is a front end compiler that is used to compile programming languages such as C++, C, Objective C++ and Objective C into machine code. Clang is also used as a compiler for frameworks like OpenMP, OpenCL, RenderScript, CUDA and HIP.
The Clang driver is intended to be a production quality compiler driver providing access to the Clang compiler and tools, with a command line interface which is compatible with the gcc driver.
GCC does not have this. GCC's PCH mechanism (which is just a dump of the compiler memory image) is related, but is architecturally only able to read the dump back into the exact same executable as the one that produced it (it is not a structured format). Clang is much faster and uses far less memory than GCC.
-arch is darwin-only feature. You should use -target on non-darwin platforms. Alternatively, compile llvm/target specifying target triplet or create a link from clang to -clang. In your case the target triplet would be arm-none-linux-gnueabi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With