libclc: fix native host-build toolchain wiring (4 layers; 1 structural gap remains)
The native (host) libclc build was broken at multiple layers; fixed:
1. native_libclc.cmake used literal ${COOKBOOK_SYSROOT} in a single-quoted
heredoc -> CMake saw it empty -> /bin/clang-21. Use $ENV{...} so CMake reads
the env at configure time.
2. Pointed the host compiler at the SYSROOT clang (a Redox-target binary, can't
run on the host). Use $ENV{COOKBOOK_TOOLCHAIN}/bin/clang-21 (host clang,
defaults to x86_64-unknown-linux-gnu).
3. The cross-env restore (LDFLAGS with Redox -L paths + --static) ran BEFORE the
native cmake/ninja, polluting the host link. Moved it to AFTER the build.
4. -DLLVM_DIR overrode the toolchain file with the Redox sysroot LLVM. Point it
at ${COOKBOOK_TOOLCHAIN}.
Compiler detection now passes ('skipped'/OK). REMAINING structural blocker:
find_package(LLVM) loads the toolchain's LLVMExports.cmake but that references
LLVM dev files not shipped in the runtime toolchain -> needs a complete HOST
LLVM dev tree (llvm21 host dev output) for the libclc host build.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -54,18 +54,18 @@ generate_cookbook_cmake_file "${COOKBOOK_HOST_TARGET}" "" "/usr" native_libclc.c
|
||||
# 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 "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_CXX_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_ASM_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_AR "${COOKBOOK_SYSROOT}/bin/llvm-ar" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_NM "${COOKBOOK_SYSROOT}/bin/llvm-nm" CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_RANLIB "${COOKBOOK_SYSROOT}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE)
|
||||
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)
|
||||
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 "${COOKBOOK_SYSROOT}/lib/cmake/llvm" CACHE PATH "" FORCE)
|
||||
set(LLVM_DIR "$ENV{COOKBOOK_TOOLCHAIN}/lib/cmake/llvm" CACHE PATH "" FORCE)
|
||||
set(LIBCLC_STANDALONE_BUILD TRUE CACHE BOOL "" FORCE)
|
||||
NATIVE_EOF
|
||||
|
||||
@@ -86,7 +86,7 @@ NATIVE_EOF
|
||||
COOKBOOK_CMAKE_FLAGS+=(
|
||||
-DCMAKE_TOOLCHAIN_FILE="$(realpath native_libclc.cmake)"
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DLLVM_DIR="${COOKBOOK_SYSROOT}/lib/cmake/llvm"
|
||||
-DLLVM_DIR="${COOKBOOK_TOOLCHAIN}/lib/cmake/llvm"
|
||||
-DLIBCLC_STANDALONE_BUILD=TRUE
|
||||
-DLIBCLC_TARGETS_TO_BUILD="r600--;amdgcn--;amdgcn--amdhsa;amdgcn-mesa-mesa3d"
|
||||
-DENABLE_RUNTIME_SUBNORMAL=OFF
|
||||
@@ -99,14 +99,6 @@ COOKBOOK_CMAKE_FLAGS+=(
|
||||
-Wno-dev
|
||||
)
|
||||
|
||||
# Restore the cross-compile environment (libclc install is the only
|
||||
# step that uses the host toolchain; if subsequent install steps
|
||||
# are added to the recipe, they'd want the cross env).
|
||||
export LDFLAGS="$_SAVED_LDFLAGS"
|
||||
export CFLAGS="$_SAVED_CFLAGS"
|
||||
export CXXFLAGS="$_SAVED_CXXFLAGS"
|
||||
export CPPFLAGS="$_SAVED_CPPFLAGS"
|
||||
|
||||
# Source dir is the path_in_repo subdir of the cloned llvm-project. This
|
||||
# cookbook does not extract path_in_repo into COOKBOOK_SOURCE — it clones the
|
||||
# whole llvm-project there — so CMake was pointed at the repo root and failed
|
||||
@@ -129,6 +121,14 @@ if [ -d "${COOKBOOK_STAGE}/stage" ]; then
|
||||
rm -rf "${COOKBOOK_STAGE}/stage"
|
||||
fi
|
||||
|
||||
# Restore the cross-compile env for any subsequent (cross) steps. The native
|
||||
# cmake/ninja above MUST run with the clean (unset) env, so this restore is
|
||||
# placed AFTER the build, not before it.
|
||||
export LDFLAGS="$_SAVED_LDFLAGS"
|
||||
export CFLAGS="$_SAVED_CFLAGS"
|
||||
export CXXFLAGS="$_SAVED_CXXFLAGS"
|
||||
export CPPFLAGS="$_SAVED_CPPFLAGS"
|
||||
|
||||
# Mesa's clc tool expects the .bc files at <libexecdir>/clc where
|
||||
# libexecdir is <prefix>/share/clc (per the libclc.pc.in template).
|
||||
# The cmake install above places them at $COOKBOOK_STAGE/usr/share/clc
|
||||
|
||||
Reference in New Issue
Block a user