[llvm-dev] How to build host cross-toolchain from another operating system?

unlvsur unlvsur via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 12 13:26:30 PDT 2021


I want to build llvm + clang + lld + compiler-rt on Linux to build a windows host toolchain for example.


In GNU toolchain, it is 2 step.


  1.  Build a target cross toolchain
Binutils : --target=x86_64-w64-mingw32 (multilib)
        MinGW-w64-crt header files: --target=x86_64-w64-mingw32, --host=x86_64-w64-mingw32
        GCC, gcc part: --target=x86_64-w64-mingw32 (multilib)
        MinGW-w64-crt: --target=x86_64-w64-mingw32, --host=x86_64-w64-mingw32
        GCC libgcc and libstdc++: --target=x86_64-w64-mingw32
Done

  1.  Use this target x86_64-w64-mingw32 cross toolchain to build a new host toolchain

Binutils : --target=x86_64-w64-mingw32 (multilib) –host= x86_64-w64-mingw32 –disable-gdb

GCC: --target=x86_64-w64-mingw32 (multilib) –host= x86_64-w64-mingw32

                Then copy the CRT build from the first target cross toolchain in this host toolchain.
                Then we can use this new host toolchain and use it to build programs.

However, I try the same thing with llvm, I could not do it. cmake will do stupid checks to prevent me to just do the 2nd part.
                I could not even use clang –target=x86_64-windows-gnu -fuse-ld=lld to build a host GCC since it fails to build gmp, only GCC could build that.



I think this is extremely important as a cross compiler. You want to bootstrap another toolchain from this platform to a new platform to make the new platform self host.
However, I guess it is very hard for LLVM, since it requires python and all kinds of other dependencies which the target cross toolchain does not provide.

The largest issue is clearly cmake, which prevents cross compilation.

I do not know what is the solution here.


Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210412/fa4184eb/attachment.html>


More information about the llvm-dev mailing list