Building a complete, self-contained toolchain

Hi,

I’m attempting to learn LLVM, and my first task is to build a fully functional, self-contained toolchain that does not depend on any external components, e.g. libgcc_s, and as of this moment, I’m struggling :frowning:.

I’m a little confused by all the different build approaches, e.g. bootstrap builds using -DCLANG_ENABLE_BOOTSTRAP=ON", distributions using cmake cache files (e.g. clang/cmake/caches/DistributionExample.cmake referenced by Building a Distribution of LLVM — LLVM 23.0.0git documentation, or several “stand-alone” builds done in order.

I’ve successfully built a toolchain from llvm-project monorepo git tip, using -DCLANG_ENABLE_BOOTSTRAP=ON, with the following config:

        cmake -G "Ninja" \
                -DCMAKE_BUILD_TYPE=Release \
                -DCMAKE_C_COMPILER="/usr/lib/llvm/21/bin/clang" \
                -DCMAKE_CXX_COMPILER="/usr/lib/llvm/21/bin/clang++" \
                -DCMAKE_INSTALL_PREFIX="${HOME}/out" \
                -DCLANG_ENABLE_BOOTSTRAP=ON \
                -DLLVM_ENABLE_PROJECTS="clang;lld;bolt" \
                -DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx;compiler-rt" \
                -DLLVM_HOST_TRIPLE=x86_64-pc-linux-musl \
                -DLLVM_ENABLE_ASSERTIONS=OFF \
                -DLLVM_TARGETS_TO_BUILD=Native \
                -DLLVM_ENABLE_LLD=ON \
                -DLLVM_CCACHE_BUILD=ON \
                -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
                -DLIBCXX_HAS_MUSL_LIBC=ON \
                -DCLANG_DEFAULT_CXX_STDLIB=libc++ \
                -DCLANG_DEFAULT_RTLIB=compiler-rt \
                -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
                -DCOMPILER_RT_BUILD_CTX_PROFILE=OFF \
                -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
                -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
                -DCOMPILER_RT_BUILD_BUILTINS=ON \
                -DCOMPILER_RT_BUILD_MEMPROF=OFF \
                -DCOMPILER_RT_BUILD_PROFILE=OFF \
                -DCOMPILER_RT_BUILD_XRAY=OFF \
                -DCOMPILER_RT_BUILD_ORC=OFF \
                -DCOMPILER_RT_BUILD_CRT=ON \
                -DCOMPILER_RT_USE_ATOMIC_LIBRARY=ON \
                -DCOMPILER_RT_USE_BUILTINS_LIBRARY=ON \
                -DLIBCXXABI_USE_LLVM_UNWINDER=ON \
                -DLIBCXXABI_USE_COMPILER_RT=ON \
                -DLIBCXX_USE_COMPILER_RT=ON \
                -DLIBUNWIND_USE_COMPILER_RT=ON \
                -DBOOTSTRAP_LLVM_TARGETS_TO_BUILD=Native \
                -DBOOTSTRAP_LLVM_HOST_TRIPLE=x86_64-pc-linux-musl \
                -DBOOTSTRAP_LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
                -DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
                -DBOOTSTRAP_CLANG_DEFAULT_CXX_STDLIB=libc++ \
                -DBOOTSTRAP_CLANG_DEFAULT_LINKER=lld \
                -DBOOTSTRAP_CLANG_DEFAULT_RTLIB=compiler-rt \
                -DBOOTSTRAP_CLANG_DEFAULT_UNWINDLIB=libunwind \
                -DBOOTSTRAP_COMPILER_RT_BUILD_GWP_ASAN=OFF \
                -DBOOTSTRAP_LIBCXX_HAS_MUSL_LIBC=ON \
                -DBOOTSTRAP_LIBCXX_USE_COMPILER_RT=ON \
                -DBOOTSTRAP_LIBCXXABI_USE_COMPILER_RT=ON \
                -DBOOTSTRAP_LIBCXXABI_USE_LLVM_UNWINDER=ON \
                -DBOOTSTRAP_LIBUNWIND_USE_COMPILER_RT=ON \
                "${HOME}/src/llvm-project/llvm"

But, ldd ~/out/lib/libc++.so.1.0 still shows:

	ldd (0x7e879f8de000)
	libatomic.so.1 => /usr/lib/gcc/x86_64-pc-linux-musl/15/libatomic.so.1 (0x7e879f7be000)
	libc++abi.so.1 => /lib/libc++abi.so.1 (0x7e879f778000)
	libunwind.so.1 => /lib/libunwind.so.1 (0x7e879f76d000)
	libc.so => ldd (0x7e879f8de000)

I’d appreciate any pointers on how to correctly build a self-contained LLVM toolchain? Or even which method I should be using. The documentation can be quite confusing.

For reference, I’m running a Gentoo host system with native LLVM + musl.

Thanks!

Hi,

I’ve done something similar for the release builds. You can look at Release.cmake and the LLVM_RELEASE_ENABLE_LINK_LOCAL option.

Can you extract the linking command used to link libc++.so.1.0 from the build logs so we can see what it is doing. Also is ~/out/lib/libc++.so.1.0 from the stage1 build or the stage2 build? What command did you use to install it?

Also, is the only thing you are worried about the libatomic library?

Amazing! This seems to be exactly what I was looking for, thanks. :slight_smile: I could have sworn I looked at this file before, but I guess I skimmed right past the `LLVM_RELEASE_ENABLE_LINK_LOCAL` section.

I don’t have the build artifacts from that run anymore, but I can post them if I run that configuration again, unless you think this is a potential bug I could help diagnose? If so, I’ll try to reproduce.

Primarily, yeah.

But my goal is to do a deep dive into the LLVM project and all of its constituent parts, and hopefully become proficient enough to contribute upstream. I would be dogfooding the build for my primary Gentoo workstation and other development work.

I figure the best way to dogfood is to use a complete, self-contained toolchain comprised of as many of the in-tree components as possible, i.e. I would prefer to be using the checked out version of compilter-rt, incl its atomics, builtins, sanitizers, and not be pulling in libgcc for anything, that would “pollute” the toolchain (?).

Hope this makes sense. Thanks again.

Looks like we’re in business, though I got the following errors:

CMake Error at /home/user/src/llvm-project/libunwind/src/CMakeLists.txt:95 (message):
  Compiler doesn't support generation of unwind tables if exception support
  is disabled.  Building libunwind DSO with runtime dependency on C++ ABI
  library is not supported.

This was because I had LLVM_HOST_TRIPLE=x86_64-bdprom-linux-musl set, which I guess caused it to not find my GCC install, which it needs apparently (there goes my self-containment I guess?). Fixed by instead setting LLVM_HOST_TRIPLE=x86_64-pc-linux-musl.

[11/10821] Linking CXX executable bin/llvm-min-tblgen
FAILED: [code=1] bin/llvm-min-tblgen
: && /home/user/build/bin/clang++ -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -flto=thin -ffat-lto-objects -O3 -DNDEBUG -rtlib=compiler-rt --unwindlib=libunwind -static-libgcc -Wl,--emit-relocs,-znow -stdlib=libc++ -static-libstdc++ -fuse-ld=lld -Wl,--color-diagnostics -flto=thin -Wl,--thinlto-cache-dir=/home/user/build/tools/clang/stage2-bins/lto.cache -ffat-lto-objects  -Wl,--gc-sections utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/ARMTargetDefEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/Attributes.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/CodeGenIntrinsics.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/DirectiveEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/IntrinsicEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/RISCVTargetDefEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/RuntimeLibcallsEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/RuntimeLibcalls.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/SDNodeProperties.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/TableGen.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/TargetFeaturesEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/TargetLibraryInfoEmitter.cpp.o utils/TableGen/Basic/CMakeFiles/obj.LLVMTableGenBasic.dir/VTEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-min-tblgen.dir/llvm-min-tblgen.cpp.o -o bin/llvm-min-tblgen  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libLLVMSupport.a  lib/libLLVMTableGen.a  lib/libLLVMSupport.a  -lrt  -ldl  -lm  /usr/lib/libz.so  lib/libLLVMDemangle.a && :
clang++: error: unable to execute command: Segmentation fault
clang++: error: linker command failed due to signal (use -v to see invocation)

Fixed by settings LLVM_RELEASE_ENABLE_LTO=OFF. I’ve had this before, thin LTO isn’t work for me, and I haven’t had chance to delve into why.

Here is my current configuration command:

        cmake -G Ninja "$HOME/src/llvm-project/llvm" \
                -D DEFAULT_PROJECTS="clang;lld;lldb;polly;bolt" \
                -D DEFAULT_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
                -D LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES=ON \
                -D LLVM_RELEASE_ENABLE_PGO=OFF \
                -D LLVM_RELEASE_ENABLE_LTO=OFF \
                -D CMAKE_C_COMPILER="/usr/lib/llvm/21/bin/clang" \
                -D CMAKE_CXX_COMPILER="/usr/lib/llvm/21/bin/clang++" \
                -D CMAKE_INSTALL_PREFIX="${HOME}/out" \
                -D LLVM_HOST_TRIPLE=x86_64-pc-linux-musl \
                -D LLVM_CCACHE_BUILD=ON \
                -D LIBCXX_HAS_MUSL_LIBC=ON \
                -D COMPILER_RT_BUILD_GWP_ASAN=OFF \
                -D BOOTSTRAP_LLVM_CCACHE_BUILD=ON \
                -D BOOTSTRAP_LIBCXX_HAS_MUSL_LIBC=ON \
                -D BOOTSTRAP_COMPILER_RT_BUILD_GWP_ASAN=OFF \
                -C "$HOME/src/llvm-project/clang/cmake/caches/Release.cmake"

I’m thinking the PROJECTS/RUNTIMES options might not be working, as it’s currently building 11,000 objects, which is like 4x what it usually is. Could this be because I’m building with ninja stage2 instead of some other correct CMake target?

Replace DEFAULT_PROJECTS with BOOTSTRAP_LLVM_ENABLE_PROJECTS and DEFAULT_RUNTIMES with BOOTSTRAP_LLVM_ENABLE_RUNTIMES and I think it will work.

Thanks!

Seeing as you seem quite knowledgeable here, could you confirm that ‘stage2’ is the correct target to build everything? Then I assume ‘install’?

I’m assuming stage2 instruments via BOLT too?

(I need to brush up on my CMake again).

ninja stage2 to build and ninja stage2-install to install. Yes, bolt is enabled by default so stage2 should be bolt optimized.

Perfect. Thanks for all your help! :blush:

Eek, more problems.

-- Testing: 2 tests, 2 workers --
FAIL: Clang Perf Training :: cxx/hello_world.cpp (1 of 2)
******************** TEST 'Clang Perf Training :: cxx/hello_world.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst --driver-mode=g++  -c /home/user/src/llvm-project/clang/utils/perf-training/cxx/hello_world.cpp
# executed command: /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst --driver-mode=g++ -c /home/user/src/llvm-project/clang/utils/perf-training/cxx/hello_world.cpp
# .---command stderr------------
# | /home/user/src/llvm-project/clang/utils/perf-training/cxx/hello_world.cpp:3:10: fatal error: 'iostream' file not found
# |     3 | #include <iostream>
# |       |          ^~~~~~~~~~
# | 1 error generated.
# `-----------------------------
# error: command failed with exit status: 1

--

********************
FAIL: Clang Perf Training :: llvm-support/build.test (2 of 2)
******************** TEST 'Clang Perf Training :: llvm-support/build.test' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/usr/bin/cmake -G Ninja -B /mnt/home/common/build/tools/clang/stage2-bins/tools/clang/utils/perf-training/llvm-support/Output/build.test.tmp -S /home/user/src/llvm-project/llvm -DCMAKE_C_COMPILER='/mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst' -DCMAKE_CXX_COMPILER='/mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst;--driver-mode=g++' -DCMAKE_BUILD_TYPE=Release
# executed command: /usr/bin/cmake -G Ninja -B /mnt/home/common/build/tools/clang/stage2-bins/tools/clang/utils/perf-training/llvm-support/Output/build.test.tmp -S /home/user/src/llvm-project/llvm -DCMAKE_C_COMPILER=/mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst '-DCMAKE_CXX_COMPILER=/mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst;--driver-mode=g++' -DCMAKE_BUILD_TYPE=Release
# .---command stdout------------
# | -- The C compiler identification is Clang 23.0.0
# | -- The CXX compiler identification is Clang 23.0.0
# | -- The ASM compiler identification is Clang with GNU-like command-line
# | -- Found assembler: /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - failed
# | -- Check for working C compiler: /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst
# | -- Check for working C compiler: /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst - broken
# | -- Configuring incomplete, errors occurred!
# `-----------------------------
# .---command stderr------------
# | CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
# |   The C compiler
# | 
# |     "/mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst"
# | 
# |   is not able to compile a simple test program.
# | 
# |   It fails with the following output:
# | 
# |     Change Dir: '/mnt/home/common/build/tools/clang/stage2-bins/tools/clang/utils/perf-training/llvm-support/Output/build.test.tmp/CMakeFiles/CMakeScratch/TryCompile-pDLhCL'
# |     
# |     Run Build Command(s): /usr/bin/ninja -v cmTC_099a4
# |     [1/2] /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst    -MD -MT CMakeFiles/cmTC_099a4.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_099a4.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_099a4.dir/testCCompiler.c.o -c /mnt/home/common/build/tools/clang/stage2-bins/tools/clang/utils/perf-training/llvm-support/Output/build.test.tmp/CMakeFiles/CMakeScratch/TryCompile-pDLhCL/testCCompiler.c
# |     [2/2] : && /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst   CMakeFiles/cmTC_099a4.dir/testCCompiler.c.o -o cmTC_099a4   && :
# |     FAILED: [code=1] cmTC_099a4 
# |     : && /mnt/home/common/build/tools/clang/stage2-bins/bin/clang-bolt.inst   CMakeFiles/cmTC_099a4.dir/testCCompiler.c.o -o cmTC_099a4   && :
# |     /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
# |     /usr/bin/ld: cannot find -lgcc: No such file or directory
# |     /usr/bin/ld: cannot find -lgcc_s: No such file or directory
# |     /usr/bin/ld: cannot find -lgcc: No such file or directory
# |     /usr/bin/ld: cannot find -lgcc_s: No such file or directory
# |     /usr/bin/ld: cannot find crtendS.o: No such file or directory
# |     clang-bolt: error: linker command failed with exit code 1 (use -v to see invocation)
# |     ninja: build stopped: subcommand failed.
# |     
# |     
# | 
# | 
# | 
# |   CMake will not be able to correctly generate this project.
# | Call Stack (most recent call first):
# |   CMakeLists.txt:46 (project)
# | 
# | 
# `-----------------------------
# error: command failed with exit status: 1

--

********************
********************
Failed Tests (2):
  Clang Perf Training :: cxx/hello_world.cpp
  Clang Perf Training :: llvm-support/build.test

Any ideas @tstellar ? Sorry to bother you again.

For now you can try disabling bolt.

Thanks @tstellar , I didn’t see an option to disable BOLT, so I just commented out the relevant sections in the .cmake, but now I get:

CMake Error at /home/user/src/llvm-project/libunwind/src/CMakeLists.txt:95 (message):
  Compiler doesn't support generation of unwind tables if exception support
  is disabled.  Building libunwind DSO with runtime dependency on C++ ABI
  library is not supported.


-- Configuring incomplete, errors occurred!
[7310/7314] Linking CXX executable bin/llvm-lto2
FAILED: [code=1] runtimes/runtimes-stamps/runtimes-configure /home/user/build/tools/clang/stage2-bins/runtimes/runtimes-stamps/runtimes-configure 
cd /home/user/build/tools/clang/stage2-bins/runtimes/runtimes-bins && /usr/bin/cmake --no-warn-unused-cli -DCMAKE_C_COMPILER=/home/user/build/tools/clang/stage2-bins/./bin/clang -DCMAKE_CXX_COMPILER=/home/user/build/tools/clang/stage2-bins/./bin/clang++ -DCMAKE_ASM_COMPILER=/home/user/build/tools/clang/stage2-bins/./bin/clang -DCMAKE_LINKER=/home/user/build/tools/clang/stage2-bins/./bin/ld.lld -DCMAKE_AR=/home/user/build/tools/clang/stage2-bins/./bin/llvm-ar -DCMAKE_RANLIB=/home/user/build/tools/clang/stage2-bins/./bin/llvm-ranlib -DCMAKE_NM=/home/user/build/tools/clang/stage2-bins/./bin/llvm-nm -DCMAKE_OBJDUMP=/home/user/build/tools/clang/stage2-bins/./bin/llvm-objdump -DCMAKE_OBJCOPY=/home/user/build/tools/clang/stage2-bins/./bin/llvm-objcopy -DCMAKE_STRIP=/home/user/build/tools/clang/stage2-bins/./bin/llvm-strip -DCMAKE_READELF=/home/user/build/tools/clang/stage2-bins/./bin/llvm-readelf -DCMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-gnu -DCMAKE_CXX_COMPILER_TARGET=x86_64-unknown-linux-gnu -DCMAKE_Fortran_COMPILER_TARGET=x86_64-unknown-linux-gnu -DCMAKE_ASM_COMPILER_TARGET=x86_64-unknown-linux-gnu -DCMAKE_INSTALL_PREFIX=/home/user/out -DLLVM_BINARY_DIR=/home/user/build/tools/clang/stage2-bins -DLLVM_CONFIG_PATH=/home/user/build/tools/clang/stage2-bins/bin/llvm-config -DLLVM_ENABLE_WERROR=OFF -DLLVM_HOST_TRIPLE=x86_64-unknown-linux-gnu -DLLVM_HAVE_LINK_VERSION_SCRIPT=1 -DLLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO=OFF -DLLVM_USE_RELATIVE_PATHS_IN_FILES=OFF -DLLVM_LIT_ARGS=-sv -DLLVM_SOURCE_PREFIX= -DPACKAGE_VERSION=23.0.0git -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCOMPILER_RT_BUILD_BUILTINS=Off -DLLVM_INCLUDE_TESTS=ON -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu -DLLVM_ENABLE_PROJECTS_USED=ON -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON -DLLVM_BUILD_TOOLS=ON -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON -DCMAKE_Fortran_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON -DHAVE_LLVM_LIT=ON -DCLANG_RESOURCE_DIR= -DCOMPILER_RT_TEST_EXTERNAL_BUILTINS=ON "-DLLVM_ENABLE_RUNTIMES=compiler-rt;libcxx;libcxxabi;libunwind" -DFFI_INCLUDE_DIR= -DFFI_LIBRARY_DIR= -DCOMPILER_RT_BUILD_GWP_ASAN=OFF -DLIBCXX_HAS_MUSL_LIBC=ON -GNinja -C/home/user/build/tools/clang/stage2-bins/projects/runtimes/tmp/runtimes-cache-RELEASE.cmake -S /home/user/src/llvm-project/llvm/runtimes/../../runtimes -B /home/user/build/tools/clang/stage2-bins/runtimes/runtimes-bins && /usr/bin/cmake -E touch /home/user/build/tools/clang/stage2-bins/runtimes/runtimes-stamps/runtimes-configure
ninja: build stopped: subcommand failed.
FAILED: [code=1] tools/clang/stage2-stamps/stage2-build /home/user/build/tools/clang/stage2-stamps/stage2-build 
cd /home/user/build/tools/clang/stage2-bins && /usr/bin/cmake --build /home/user/build/tools/clang/stage2-bins/ --config RELEASE && /usr/bin/cmake -E touch /home/user/build/tools/clang/stage2-stamps/stage2-build
ninja: build stopped: subcommand failed.

At this point I think I might try the clean sysroot approach, i.e. install musl-headers, then linux-headers, compiler-rt, etc etc. I found some potentially useful sources which I’ll attempt to adapt to my needs:

I feel like I’m having to fight the build system too much, I didn’t realise that my goal was so off the beaten path, I guess because I’m using musl? :frowning:

If you want to try a different approach, I wonder if Petr Hosek’s talk on the build might be helpful: https://www.youtube.com/watch?v=Dnubzx8-E1M . I think it does say that compiler-rt can be built standalone, but there are two designated top levels from which other components can be built, llvm and runtimes. But maybe it’s different building a runtime with the compiler just built, and with a host compiler. Just to suggest the talk in case it helps.

Thanks, I’ll watch this later. I’ve actually now managed to build a standalone toolchain, and if I was to start compiling software in a chroot, I think I could stop here. But, using this toolchain on my host system is still problematic, lots of broken paths and whatnot.

It’s a work in progress.

@bdprom I was just wondering if you’ve had any further success? I keep trying to make a MUSL build of llvm clang/flang but keep failing.

If it’s possible, it would make my life much nicer since the official LLVM release tarfiles are for a glibc version much too new for the supercomputing clusters I work on (OS updates aren’t done often, and SLES 15 isn’t exactly high priority OS). I’d just love to grab a tarfile, untar it, and boom, working clang/flang!.

I tried to follow the PancakeTAS example you pointed at, but just kept running into issues.