LLVM Cross-Compiler
Difficulty level |
---|
Advanced |
EDIT: A mostly working Clang cross-compiler is generated by this buildscript. Dissect it to learn more. TODO: move details to this page.
EDIT: EmbToolkit project recently added support to clang/llvm based cross compiler. TODO: Add note about how it works.
Is as simple as that:
mkdir crossllvm
cd crossllvm
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
mkdir build
cd build
cmake ../llvm
make
After building you will have a compiler able to output multiple output formats regardless of your current platform.
For example, for ARM, you can use
-march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf
Since 3.1, it can be shortened to
-target armv7--eabi -mcpu=cortex-a9
TODO: beware that clang is both a cross-compiler and a host-compiler and you would have to specify some options to disable host functionality.
TODO: clang requires a fairly recent version of binutils to work, try 2.21 or above if you get assembly compilation errors.
TODO: describe non-svn build from released tarballs.
TODO: integrate libc++ build instructions