libclc: wire llvm-native as the host-LLVM build-dep (fixes find_package(LLVM))
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 <<NATIVE_EOF
|
||||
set(CMAKE_C_COMPILER "${HOST_CLANG}" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_CXX_COMPILER "${HOST_CLANG}" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_ASM_COMPILER "${HOST_CLANG}" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_AR "${HOST_LLVM_PREFIX}/bin/llvm-ar" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_NM "${HOST_LLVM_PREFIX}/bin/llvm-nm" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_RANLIB "${HOST_LLVM_PREFIX}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_C_FLAGS_INIT "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_INIT "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BYPASS" CACHE STRING "" FORCE)
|
||||
set(LLVM_DIR "$ENV{COOKBOOK_TOOLCHAIN}/lib/cmake/llvm" CACHE PATH "" FORCE)
|
||||
set(LLVM_DIR "${HOST_LLVM_CMAKE}" CACHE PATH "" FORCE)
|
||||
set(LIBCLC_STANDALONE_BUILD TRUE CACHE BOOL "" FORCE)
|
||||
NATIVE_EOF
|
||||
|
||||
@@ -86,7 +122,7 @@ NATIVE_EOF
|
||||
COOKBOOK_CMAKE_FLAGS+=(
|
||||
-DCMAKE_TOOLCHAIN_FILE="$(realpath native_libclc.cmake)"
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DLLVM_DIR="${COOKBOOK_TOOLCHAIN}/lib/cmake/llvm"
|
||||
-DLLVM_DIR="${HOST_LLVM_CMAKE}"
|
||||
-DLIBCLC_STANDALONE_BUILD=TRUE
|
||||
-DLIBCLC_TARGETS_TO_BUILD="r600--;amdgcn--;amdgcn--amdhsa;amdgcn-mesa-mesa3d"
|
||||
-DENABLE_RUNTIME_SUBNORMAL=OFF
|
||||
|
||||
Reference in New Issue
Block a user