Simply put: Can ANY part of llvm be cross-compiled WITHOUT the need of ANY gcc component?
I had been trying a whole number of attempts from various llvm.org links and got bupkus, only errors.
I first posed the question on the IRC channel(s) and one user said it could be done without needing gcc, but almost everywhere I’ve looked, I’d see references to using some aspect of gcc.
It was even suggested I look into using compiler-rt, but building that resulted in the same issues that arise either during cmake tests or during the build (probably from a child cmake).
My latest test was to go bare-minimum by just doing llvm’s libc alone.
However, every method listed in https://libc.llvm.org/full_cross_build.html failed.
Going by the “standalone”, the error was:
…
-- Skipping startup for target architecture arm
CMake Error at /<pathTo>llvm-project/libc/cmake/modules/LLVMLibCTestRules.cmake:397 (message):
The 'crt1' target for the integration test is missing.
Call Stack (most recent call first):
/<pathTo>/llvm-project/libc/test/src/CMakeLists.txt:135 (add_integration_test)
I even made sure to use the true triplet form shown on that page (rather than including “vendor”, which shouldn’t have made any difference), and it still failed:
$ /usr/bin/cmake \
-S "<pathToGit>/llvm" \
-B "<pathToBuild>" \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_COMPILER="/usr/bin/clang" \
-DCMAKE_CXX_COMPILER="/usr/bin/clang++" \
-DLLVM_ENABLE_PROJECTS=libc \
-DLLVM_LIBC_FULL_BUILD=ON \
-DLIBC_TARGET_TRIPLE=arm-linux-gnueabi
Seems to me that some SYSROOT ought to have been included in there, except this is libc that’s being built so it should only be looking for where it was built, except it couldn’t even get out of the starting-gate to even begin to get built.
Setting something like -DCMAKE_C_FLAGS="--target=<tuple> --sysroot=<hostTargetDir>" for other llvm component builds ends up also failing because it’s looking for files that are normally provided by gcc. Example: crtbeginS.o or lgcc_s.
But like I said, I’m looking to go completely sans-GCC, and figured llvm could bootstrap in a similar way that GCC can, as shown on LFS. The only things gcc needed was some libc, linux headers, binutils, and itself.
Is this not the case for llvm?
How To Cross-Compile Clang/LLVM using Clang/LLVM — LLVM 19.0.0git documentation “or whatever is the location of your GCC’s sysroot”
Getting Started with the LLVM System — LLVM 19.0.0git documentation “The first step is to get a recent GCC toolchain installed”
CMLFS/1-Stage0/0-Build-Notes at master · dslm4515/CMLFS · GitHub also shows GCC used (if even just for building a libc).