From e5c0ed5ef8f87871f08f14708f37d7edfc6f8141 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 28 Jul 2026 15:25:36 +0900 Subject: [PATCH] libclc: wire llvm-native as the host-LLVM build-dep (fixes find_package(LLVM)) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libclc's native build needs a COMPLETE host LLVM dev tree (host clang + llvm-as/opt/llc/llvm-link + LLVMConfig/LLVMExports.cmake + the static component libs they reference). The redoxer runtime toolchain ships only libLLVM.so + clang, so find_package(LLVM) failed on missing static libs; the cross llvm21.dev is the wrong (Redox-targeted) LLVM. - deps: clang21/llvm21(+.dev) -> llvm-native(+.dev). Using ONLY llvm-native avoids staging two conflicting usr/lib/cmake/llvm trees (host vs cross) into the same sysroot path. - script: resolve HOST_LLVM_PREFIX=$COOKBOOK_SYSROOT/usr; point CMAKE_C/CXX/ASM_COMPILER + AR/NM/RANLIB at llvm-native's host binaries and LLVM_DIR at its host cmake tree; add staged-file guards with diagnostics. Unblocks the FULL graphics stack (mesa->qt->kf6->sddm). Cook-validated when FULL reaches libclc (cooks llvm-native first — a full host LLVM build). Co-Authored-By: Claude Opus 4.8 (1M context) --- local/recipes/dev/libclc/recipe.toml | 76 ++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/local/recipes/dev/libclc/recipe.toml b/local/recipes/dev/libclc/recipe.toml index f414d4a9ad..46c8c47566 100644 --- a/local/recipes/dev/libclc/recipe.toml +++ b/local/recipes/dev/libclc/recipe.toml @@ -17,15 +17,25 @@ shallow_clone = true [build] template = "custom" -# Build depends on the HOST clang (built by clang21) and the -# LLVMConfig.cmake (provided by llvm21's install). +# libclc's *native* build needs a COMPLETE HOST LLVM dev tree: a host-runnable +# clang + llvm-as/opt/llc/llvm-link plus find_package(LLVM)'s LLVMConfig.cmake, +# LLVMExports.cmake AND the static component libs they reference. The redoxer +# runtime toolchain (COOKBOOK_TOOLCHAIN) ships only libLLVM.so + clang — its +# LLVMExports.cmake references static libs that are not present, so +# find_package(LLVM) fails ("file does not exist"). The cross llvm21.dev is the +# WRONG LLVM (its cmake/libs target Redox, not the host). +# +# llvm-native is exactly the missing piece: a native (host) LLVM/Clang/LLD 21 +# build (same redox-2025-10-03 revision as llvm21/clang21) whose .dev package +# ships usr/lib/cmake/llvm/**, libLLVM*.a and host clang/llvm-* binaries. We +# depend on it ALONE for the host toolchain — pulling in llvm21.dev too would +# stage a SECOND, conflicting usr/lib/cmake/llvm (the cross one) into the same +# sysroot path, and find_package would non-deterministically pick the wrong one. dependencies = [ - "clang21", - "llvm21", + "llvm-native", ] dev-dependencies = [ - "clang21.dev", - "llvm21.dev", + "llvm-native.dev", ] script = ''' DYNAMIC_INIT @@ -45,27 +55,53 @@ _SAVED_CXXFLAGS="${CXXFLAGS:-}" _SAVED_CPPFLAGS="${CPPFLAGS:-}" unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS +# Resolve the HOST LLVM prefix provided by llvm-native (+ .dev), staged into +# the cross sysroot by our build-dependencies. pkgar extracts packages as-is, +# so llvm-native's usr/ tree lands under ${COOKBOOK_SYSROOT}/usr/. Everything +# libclc's native build needs is under here: the host clang/llvm-* binaries +# (usr/bin), and find_package(LLVM)'s complete cmake tree + static libs +# (usr/lib/cmake/llvm, usr/lib/libLLVM*.a). +HOST_LLVM_PREFIX="${COOKBOOK_SYSROOT}/usr" +HOST_LLVM_CMAKE="${HOST_LLVM_PREFIX}/lib/cmake/llvm" + +# Pick the host clang: llvm-native installs an unprefixed `clang` symlink; fall +# back to clang-21 if only the versioned name is present. +if [ -x "${HOST_LLVM_PREFIX}/bin/clang" ]; then + HOST_CLANG="${HOST_LLVM_PREFIX}/bin/clang" +elif [ -x "${HOST_LLVM_PREFIX}/bin/clang-21" ]; then + HOST_CLANG="${HOST_LLVM_PREFIX}/bin/clang-21" +else + echo "libclc: ERROR — host clang not found under ${HOST_LLVM_PREFIX}/bin" >&2 + echo "libclc: is the 'llvm-native' build-dependency staged? ls:" >&2 + ls -la "${HOST_LLVM_PREFIX}/bin" 2>/dev/null | grep -i clang >&2 || true + exit 1 +fi +if [ ! -f "${HOST_LLVM_CMAKE}/LLVMConfig.cmake" ]; then + echo "libclc: ERROR — host LLVMConfig.cmake not found at ${HOST_LLVM_CMAKE}" >&2 + echo "libclc: is the 'llvm-native.dev' build-dependency staged?" >&2 + exit 1 +fi + # Generate a NATIVE toolchain file. We can't use cookbook_cmake # because that targets the cross sysroot; libclc needs the host. -generate_cookbook_cmake_file "${COOKBOOK_HOST_TARGET}" "" "/usr" native_libclc.cmake +generate_cookbook_cmake_file "${COOKBOOK_HOST_TARGET}" "" "${HOST_LLVM_PREFIX}" native_libclc.cmake -# Override the CMAKE_CXX_COMPILER etc. to point at the HOST clang -# that comes from the cookbook sysroot (clang21 build). The cookbook -# sysroot contains both the host Clang binary and the LLVM tools -# that libclc needs to find via LLVM_DIR. -cat >> native_libclc.cmake <<'NATIVE_EOF' -set(CMAKE_C_COMPILER "$ENV{COOKBOOK_TOOLCHAIN}/bin/clang-21" CACHE FILEPATH "" FORCE) -set(CMAKE_CXX_COMPILER "$ENV{COOKBOOK_TOOLCHAIN}/bin/clang-21" CACHE FILEPATH "" FORCE) -set(CMAKE_ASM_COMPILER "$ENV{COOKBOOK_TOOLCHAIN}/bin/clang-21" CACHE FILEPATH "" FORCE) -set(CMAKE_AR "$ENV{COOKBOOK_TOOLCHAIN}/bin/llvm-ar" CACHE FILEPATH "" FORCE) -set(CMAKE_NM "$ENV{COOKBOOK_TOOLCHAIN}/bin/llvm-nm" CACHE FILEPATH "" FORCE) -set(CMAKE_RANLIB "$ENV{COOKBOOK_TOOLCHAIN}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE) +# Override CMAKE_C/CXX/ASM_COMPILER etc. to point at llvm-native's HOST clang +# and llvm-* tools in the sysroot, and LLVM_DIR at llvm-native's complete host +# cmake tree (the whole point of depending on llvm-native). +cat >> native_libclc.cmake <