LLVM Cross-Compiler

From OSDev.wiki
Revision as of 08:46, 23 March 2012 by osdev>Berkus
Jump to navigation Jump to search
Difficulty level

Advanced

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, you can specify x86 ELF output format (for example) to clang using "-ccc-host-triple i686-pc-linux-gnu".

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.