LLVM Cross-Compiler: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
No edit summary
Line 39: Line 39:
-march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf
-march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf
</source>
</source>

JamesM@osdev.forum wrote:

Or since 3.1 you can just shorten this to:

<source lang="bash">
-target armv7--eabi -mcpu=cortex-a9
</source>

It is recommended to build post-3.1 clang as there are some crash bugs fixed.

Revision as of 16:20, 22 September 2012

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.

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.

TODO: integrate libc++ build instructions


pitfall@osdev.forum wrote:

As far as I know, you can use -ccc-host-triple <your target output format> option with -march=<your target architecture> to cross-compile with LLVM. It's been a while since I used LLVM/CLang, but I think this'll work with some investigation.

Here's an example quoted for some obscure mailing lists illustrating what I wrote :

-march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf

JamesM@osdev.forum wrote:

Or since 3.1 you can just shorten this to:

-target armv7--eabi -mcpu=cortex-a9

It is recommended to build post-3.1 clang as there are some crash bugs fixed.