[llvm-dev] Building an LLVM cross-compiler (original) (raw)
Cág via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 6 14:12:55 PST 2020
- Previous message: [llvm-dev] [lldb] Error - Failed to launch or debug process
- Next message: [llvm-dev] Building an LLVM cross-compiler
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi everyone,
I recently sent a message that may or may not have made it to the list, on problems building an LLVM cross-compiler. Now the issue seems clear to me and is irrelevant at this point, I would like to discuss the general issue.
Suppose you have a host system, a Linux distribution on an x86_64 machine, and want to build a cross-compiler for aarch64 (or any platform supported by LLVM, other than an AMD-/Intel-based machine) to cross compile a Linux distribution.
The process, in my opinion, should go like this:
- Get the sources (llvm, lld, compiler-rt, libunwind, libcxx...).
- Build an LLVM cross-compiler toolchain using native distribution's compiler (i.e. build an x86_64 clang executable that targets aarch64).
- Cross-compile libc and other libraries/dependencies to run the userland.
- Cross-compile the userland.
With LLVM it doesn't work:
- You got the sources.
- Built clang targetting, among others or only, aarch64/mips/etc.
- Clang requires compiler-rt but you need to cross-compile compiler-rt for the target platform. You don't have a cross-compiler.
It stops after that. To build compiler-rt you need C headers, libc runtimes, and libclang_rt.a. You can't cross-compile libc because you don't have compiler-rt because you don't have libc. Chicken or egg.
I.e. you need a cross-compiler to build a cross-compiler.
So, how do you build an LLVM-based cross-compiler?
I hope I am wrong in my assumptions and if it's so, please forgive me. I also hope I made it clear.
Thanks for taking time and have a nice weekend!
-- caóc
- Previous message: [llvm-dev] [lldb] Error - Failed to launch or debug process
- Next message: [llvm-dev] Building an LLVM cross-compiler
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]