Loading packaging/build-nspawn.sh +105 −107 Original line number Diff line number Diff line Loading @@ -153,13 +153,11 @@ ensure_kernel_headers() { # Phase 2b: Install LLVM toolchain + musl + libc++ + compiler-rt # ───────────────────────────────────────────────────────────── setup_toolchain() { # ── Phase 2b-1: Install LLVM, musl, and runtimes (expensive, skip if done) ── if [[ -f "$CHROOT_DIR/usr/local/musl/lib/libc++.a" ]]; then echo "==> Toolchain already set up, skipping" # Ensure kernel headers are present (may have been missed in earlier runs) echo "==> Runtimes already built, skipping LLVM/musl/runtimes build" ensure_kernel_headers return fi else echo "==> Setting up LLVM ${LLVM_VERSION} + musl + libc++ toolchain..." systemd-nspawn -D "$CHROOT_DIR" --pipe -- bash -c " Loading Loading @@ -201,8 +199,6 @@ setup_toolchain() { systemd-nspawn -D "$CHROOT_DIR" --pipe -- bash -c " set -e # Build libc++, libc++abi and libunwind against musl from LLVM source # LLVM 18 requires the unified runtimes build cd /tmp LLVM_TAG=llvmorg-${LLVM_VERSION}.1.8 if [ ! -d /tmp/llvm-project-\${LLVM_TAG} ]; then Loading @@ -211,10 +207,7 @@ setup_toolchain() { fi LLVM_SRC=/tmp/llvm-project-\${LLVM_TAG} # Clean stale build to avoid cached failures rm -rf /tmp/build-runtimes # Unified runtimes build: libunwind + libc++abi + libc++ mkdir -p /tmp/build-runtimes && cd /tmp/build-runtimes cmake \${LLVM_SRC}/runtimes -G Ninja \ -DCMAKE_C_COMPILER=clang-${LLVM_VERSION} \ Loading @@ -239,11 +232,17 @@ setup_toolchain() { -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON ninja ninja install ninja ninja install # Create musl-clang wrapper that uses libc++ and compiler-rt # Find compiler-rt lib path echo '==> Runtimes built and installed' " fi # ── Phase 2b-2: Generate wrapper compilers + toolchain file (always, cheap) ── echo "==> Generating compiler wrappers and toolchain file..." systemd-nspawn -D "$CHROOT_DIR" --pipe -- bash -c " set -e RT_PATH=\$(dirname \$(find /usr/lib/llvm-${LLVM_VERSION} -name 'libclang_rt.builtins-x86_64.a' | head -1)) CLANG_RESOURCE=\$(clang-${LLVM_VERSION} -print-resource-dir) Loading @@ -251,24 +250,24 @@ setup_toolchain() { #!/bin/sh # Detect if we are compiling (-c) or linking LINKING=1 for arg in "\\\$@"; do case "\\\$arg" in for arg in \"\\\$@\"; do case \"\\\$arg\" in -c|-S|-E|-M|-MM) LINKING=0 ;; esac done COMPILE_FLAGS="--target=x86_64-linux-musl --sysroot=/usr/local/musl -stdlib=libc++ -nostdinc++ -isystem /usr/local/musl/include/c++/v1 -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC" COMPILE_FLAGS=\"--target=x86_64-linux-musl --sysroot=/usr/local/musl -stdlib=libc++ -nostdinc++ -isystem /usr/local/musl/include/c++/v1 -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC\" if [ "\\\$LINKING" = "1" ]; then exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS \\ -fuse-ld=lld \\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\ --unwindlib=none -nostdlib \\ -lc++ -lc++abi -lunwind -lc -lclang_rt.builtins-x86_64 \\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\ "\\\$@" if [ \"\\\$LINKING\" = \"1\" ]; then exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS \\\\ -fuse-ld=lld \\\\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\\\ --unwindlib=none -nostdlib \\\\ -lc++ -lc++abi -lunwind -lc -lclang_rt.builtins-x86_64 \\\\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\\\ \"\\\$@\" else exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS "\\\$@" exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS \"\\\$@\" fi WRAPPER chmod +x /usr/local/musl/bin/musl-clang++ Loading @@ -277,30 +276,29 @@ WRAPPER #!/bin/sh # Detect if we are compiling (-c) or linking LINKING=1 for arg in "\\\$@"; do case "\\\$arg" in for arg in \"\\\$@\"; do case \"\\\$arg\" in -c|-S|-E|-M|-MM) LINKING=0 ;; esac done COMPILE_FLAGS="--target=x86_64-linux-musl --sysroot=/usr/local/musl -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC" COMPILE_FLAGS=\"--target=x86_64-linux-musl --sysroot=/usr/local/musl -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC\" if [ "\\\$LINKING" = "1" ]; then exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS \\ -fuse-ld=lld \\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\ -nostdlib -lc -lclang_rt.builtins-x86_64 \\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\ "\\\$@" if [ \"\\\$LINKING\" = \"1\" ]; then exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS \\\\ -fuse-ld=lld \\\\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\\\ -nostdlib -lc -lclang_rt.builtins-x86_64 \\\\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\\\ \"\\\$@\" else exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS "\\\$@" exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS \"\\\$@\" fi WRAPPER chmod +x /usr/local/musl/bin/musl-clang # Create CMake toolchain file that uses the wrapper compilers # Create CMake toolchain file mkdir -p /usr/local/musl/share cat > /usr/local/musl/share/musl-llvm-toolchain.cmake << CMAKE set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86_64) Loading @@ -309,13 +307,13 @@ set(CMAKE_C_COMPILER /usr/local/musl/bin/musl-clang) set(CMAKE_CXX_COMPILER /usr/local/musl/bin/musl-clang++) set(CMAKE_LINKER /usr/bin/ld.lld-${LLVM_VERSION}) set(CMAKE_FIND_ROOT_PATH /usr/local/musl /usr/local) set(CMAKE_FIND_ROOT_PATH /usr/local/musl /usr/local /usr) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) CMAKE echo '==> Toolchain setup complete' echo '==> Wrappers and toolchain file generated' " } Loading Loading
packaging/build-nspawn.sh +105 −107 Original line number Diff line number Diff line Loading @@ -153,13 +153,11 @@ ensure_kernel_headers() { # Phase 2b: Install LLVM toolchain + musl + libc++ + compiler-rt # ───────────────────────────────────────────────────────────── setup_toolchain() { # ── Phase 2b-1: Install LLVM, musl, and runtimes (expensive, skip if done) ── if [[ -f "$CHROOT_DIR/usr/local/musl/lib/libc++.a" ]]; then echo "==> Toolchain already set up, skipping" # Ensure kernel headers are present (may have been missed in earlier runs) echo "==> Runtimes already built, skipping LLVM/musl/runtimes build" ensure_kernel_headers return fi else echo "==> Setting up LLVM ${LLVM_VERSION} + musl + libc++ toolchain..." systemd-nspawn -D "$CHROOT_DIR" --pipe -- bash -c " Loading Loading @@ -201,8 +199,6 @@ setup_toolchain() { systemd-nspawn -D "$CHROOT_DIR" --pipe -- bash -c " set -e # Build libc++, libc++abi and libunwind against musl from LLVM source # LLVM 18 requires the unified runtimes build cd /tmp LLVM_TAG=llvmorg-${LLVM_VERSION}.1.8 if [ ! -d /tmp/llvm-project-\${LLVM_TAG} ]; then Loading @@ -211,10 +207,7 @@ setup_toolchain() { fi LLVM_SRC=/tmp/llvm-project-\${LLVM_TAG} # Clean stale build to avoid cached failures rm -rf /tmp/build-runtimes # Unified runtimes build: libunwind + libc++abi + libc++ mkdir -p /tmp/build-runtimes && cd /tmp/build-runtimes cmake \${LLVM_SRC}/runtimes -G Ninja \ -DCMAKE_C_COMPILER=clang-${LLVM_VERSION} \ Loading @@ -239,11 +232,17 @@ setup_toolchain() { -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON ninja ninja install ninja ninja install # Create musl-clang wrapper that uses libc++ and compiler-rt # Find compiler-rt lib path echo '==> Runtimes built and installed' " fi # ── Phase 2b-2: Generate wrapper compilers + toolchain file (always, cheap) ── echo "==> Generating compiler wrappers and toolchain file..." systemd-nspawn -D "$CHROOT_DIR" --pipe -- bash -c " set -e RT_PATH=\$(dirname \$(find /usr/lib/llvm-${LLVM_VERSION} -name 'libclang_rt.builtins-x86_64.a' | head -1)) CLANG_RESOURCE=\$(clang-${LLVM_VERSION} -print-resource-dir) Loading @@ -251,24 +250,24 @@ setup_toolchain() { #!/bin/sh # Detect if we are compiling (-c) or linking LINKING=1 for arg in "\\\$@"; do case "\\\$arg" in for arg in \"\\\$@\"; do case \"\\\$arg\" in -c|-S|-E|-M|-MM) LINKING=0 ;; esac done COMPILE_FLAGS="--target=x86_64-linux-musl --sysroot=/usr/local/musl -stdlib=libc++ -nostdinc++ -isystem /usr/local/musl/include/c++/v1 -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC" COMPILE_FLAGS=\"--target=x86_64-linux-musl --sysroot=/usr/local/musl -stdlib=libc++ -nostdinc++ -isystem /usr/local/musl/include/c++/v1 -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC\" if [ "\\\$LINKING" = "1" ]; then exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS \\ -fuse-ld=lld \\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\ --unwindlib=none -nostdlib \\ -lc++ -lc++abi -lunwind -lc -lclang_rt.builtins-x86_64 \\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\ "\\\$@" if [ \"\\\$LINKING\" = \"1\" ]; then exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS \\\\ -fuse-ld=lld \\\\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\\\ --unwindlib=none -nostdlib \\\\ -lc++ -lc++abi -lunwind -lc -lclang_rt.builtins-x86_64 \\\\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\\\ \"\\\$@\" else exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS "\\\$@" exec clang++-${LLVM_VERSION} \\\$COMPILE_FLAGS \"\\\$@\" fi WRAPPER chmod +x /usr/local/musl/bin/musl-clang++ Loading @@ -277,30 +276,29 @@ WRAPPER #!/bin/sh # Detect if we are compiling (-c) or linking LINKING=1 for arg in "\\\$@"; do case "\\\$arg" in for arg in \"\\\$@\"; do case \"\\\$arg\" in -c|-S|-E|-M|-MM) LINKING=0 ;; esac done COMPILE_FLAGS="--target=x86_64-linux-musl --sysroot=/usr/local/musl -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC" COMPILE_FLAGS=\"--target=x86_64-linux-musl --sysroot=/usr/local/musl -isystem \${CLANG_RESOURCE}/include -isystem /usr/local/musl/include -fPIC\" if [ "\\\$LINKING" = "1" ]; then exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS \\ -fuse-ld=lld \\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\ -nostdlib -lc -lclang_rt.builtins-x86_64 \\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\ "\\\$@" if [ \"\\\$LINKING\" = \"1\" ]; then exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS \\\\ -fuse-ld=lld \\\\ -L/usr/local/musl/lib -L/usr/local/lib -L\${RT_PATH} \\\\ -nostdlib -lc -lclang_rt.builtins-x86_64 \\\\ -Wl,-rpath,/usr/local/musl/lib -Wl,-rpath,/usr/local/lib \\\\ \"\\\$@\" else exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS "\\\$@" exec clang-${LLVM_VERSION} \\\$COMPILE_FLAGS \"\\\$@\" fi WRAPPER chmod +x /usr/local/musl/bin/musl-clang # Create CMake toolchain file that uses the wrapper compilers # Create CMake toolchain file mkdir -p /usr/local/musl/share cat > /usr/local/musl/share/musl-llvm-toolchain.cmake << CMAKE set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR x86_64) Loading @@ -309,13 +307,13 @@ set(CMAKE_C_COMPILER /usr/local/musl/bin/musl-clang) set(CMAKE_CXX_COMPILER /usr/local/musl/bin/musl-clang++) set(CMAKE_LINKER /usr/bin/ld.lld-${LLVM_VERSION}) set(CMAKE_FIND_ROOT_PATH /usr/local/musl /usr/local) set(CMAKE_FIND_ROOT_PATH /usr/local/musl /usr/local /usr) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) CMAKE echo '==> Toolchain setup complete' echo '==> Wrappers and toolchain file generated' " } Loading