I’m also on the hunt for an LFS-style build-out and came across thread and had “hope” for a tiny bit…
Coming from Cross Compile Any Llvm Component Using Clang Only (No Gcc Requirement)?, I’m still leading to believe (even after going through this thread and examining provided links) that LLVM doesn’t have parity with GCC’s cross-build chicken<->egg solution.
Using some cheats (eg -DCMAKE_C_COMPILER_WORKS (and others)) to get me to start building, the linker always borks trying to get those files that don’t exist yet at [ 96%] Linking CXX shared library ../linux/libclang_rt.asan-arm.so. Even if you don’t use a “*-*-gnu*” triple.
I’ve heard mention to use rt-compiler, but that’s the chicken<->egg issue right there.
I can’t build it without a sysroot already being built-out, while LFS builds out the sysroot without any need for any pre-existing arch-based binaries.
Having looked at fuchsia, it appears that pre-built sysroots are downloaded and installed first, which in my view defeats the objective of bootstrapping.
My desire is to see LLVM reach parity with GCC, where you can cross-build without the need for any pre-existing sysroot for the target arch. You just build out the sysroot yourself.
That way there will no longer be a need for both compilers, and the only need would be like the libc of choice and the kernel (that would be part of the cross build-out of the sysroot).
Basically it’d be like III.5 of Linux From Scratch where the LLVM bootstrap would take the place of binutils and gcc part1, then we’d use the freshly built llvm to finish with the libc source of our choice (knowing llvm currently can’t do glibc), then I figure the 2nd part of the LLVM boostrap would finish up with compiler-rt and libunwind.
EDIT0: One other notable change is the configure automatic finding of <arch>-<bins> (eg arm-unknown-linux-gnueabi-ar), so we’d have to manually point to llvm-ar via the env-var AR. Not sure how that could be nicely handled, and probably lies with the configure itself.