[llvm-dev] Building an LLVM cross-compiler

Cág via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 6 15:39:27 PST 2020


Hello Martin,

Martin Storsjö wrote:
>> 1. Get the sources (llvm, lld, compiler-rt, libunwind, libcxx...).
>> 2. Build an LLVM cross-compiler toolchain using native distribution's
>> compiler (i.e. build an x86_64 clang executable that targets aarch64).
>> 3. Cross-compile libc and other libraries/dependencies to run the
>> userland.
>> 4. Cross-compile the userland.
> Yes, for such a full from-scratch setup, the procedure is a bit fiddly
> to get right, and exactly how to do it is very dependent on how
> configurable the lower level components of your target platform are
> for such bootstrap setups.
> 
> I regularly build my toolchain that targets mingw, in exactly this way. 
> First I build the compiler, then I install the target "libc"'s headers, 
> then build the mingw equivalent of the libc.
> After this stage, higher level runtimes like libc++ can be built on top,
> followed by other compiler-rt libraries.
> See https://github.com/mstorsjo/llvm-mingw for the full set of scripts I
> use to build my setup; built-all.sh is the toplevel script you can star 
> following if you want to dig in.

I like this.  I hope you don't mind if I borrow some of these ideas to
play with.  C_COMPILER_WORKS is something I've never heard of.

Thank you!

-- 
caóc


More information about the llvm-dev mailing list