llvm-native: pass LLVM_TABLEGEN/CLANG_TABLEGEN (not *_TABLEGEN_EXE)

Root cause of the native sub-build failure. A from-scratch LLVM build reads
the cache vars LLVM_TABLEGEN / CLANG_TABLEGEN to skip building a native
tblgen when cross-compiling (llvm/cmake/modules/TableGen.cmake: "Native
TableGen executable. Saves building one when cross-compiling"). The recipe
passed *_TABLEGEN_EXE, which that path does NOT read, so LLVM built its own
native tblgen via the CROSS_TOOLCHAIN_FLAGS_NATIVE sub-build. That native
build ran host gcc against Redox relibc headers (leaked via CMAKE_CXX_FLAGS)
and died on host/redox <stdlib.h> conflicts: __deprecated/__noreturn not a
type, duplicate div_t/ldiv_t. Passing the correct var names makes LLVM use the
redoxer toolchain's host tblgens (LLVM 21.1.2) and skip the native build.

lld21/clang21 build against a PREBUILT llvm and resolve tblgen via
find_program on their own LLVM_TABLEGEN_EXE cache var, so they stay correct.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 08:59:13 +09:00
parent 5d426d89a7
commit 872935057c
+19 -9
View File
@@ -93,20 +93,30 @@ COOKBOOK_CMAKE_FLAGS+=(
-DLLVM_ENABLE_THREADS=On
-DLLVM_INCLUDE_EXAMPLES=Off
-DLLVM_INCLUDE_TESTS=Off
# OFF on purpose: this recipe PROVIDES a host-runnable, version-matched
# tblgen via LLVM_TABLEGEN_EXE/CLANG_TABLEGEN_EXE below (the redoxer
# toolchain's LLVM 21.1.2). LLVM_OPTIMIZED_TABLEGEN=On would ignore those
# and force a redundant native sub-build (CROSS_TOOLCHAIN_FLAGS_NATIVE)
# that failed to compile <shared_mutex>. With it off, LLVM uses the
# provided tblgen and skips the native build entirely. (llvm21, which does
# NOT provide a tblgen, keeps it On and builds its own — different case.)
# OFF on purpose: this recipe PROVIDES host-runnable, version-matched
# tblgens via LLVM_TABLEGEN/CLANG_TABLEGEN below (the redoxer toolchain's
# LLVM 21.1.2). LLVM_OPTIMIZED_TABLEGEN=On would build a second optimized
# native tblgen instead of using them. Off => LLVM uses what we provide.
-DLLVM_OPTIMIZED_TABLEGEN=Off
-DLLVM_TARGET_ARCH=$ARCH
-DLLVM_TOOLS_INSTALL_DIR=bin
-DLLVM_UTILS_INSTALL_DIR=bin
-DUNIX=1
-DLLVM_TABLEGEN_EXE=${COOKBOOK_HOST_SYSROOT}/bin/llvm-tblgen
-DCLANG_TABLEGEN_EXE=${COOKBOOK_HOST_SYSROOT}/bin/clang-tblgen
# CRITICAL: the cache vars LLVM/Clang read to SKIP building a native tblgen
# when cross-compiling are LLVM_TABLEGEN / CLANG_TABLEGEN (see
# llvm/cmake/modules/TableGen.cmake: "Native TableGen executable. Saves
# building one when cross-compiling"). The *_TABLEGEN_EXE names used
# previously are NOT read by a from-scratch LLVM build, so LLVM built its
# own native tblgen via the CROSS_TOOLCHAIN_FLAGS_NATIVE sub-build — which
# ran the HOST gcc against the Redox relibc headers leaked through
# CMAKE_CXX_FLAGS and died on host/redox <stdlib.h> conflicts
# (__deprecated/__noreturn undeclared, duplicate div_t). Passing the
# correct var names makes LLVM use the provided host tblgens (LLVM 21.1.2)
# and skip the native sub-build entirely. (lld21/clang21 build against a
# PREBUILT llvm and locate tblgen via find_program on LLVM_TABLEGEN_EXE —
# a different cache var owned by those projects — so they are correct.)
-DLLVM_TABLEGEN=${COOKBOOK_HOST_SYSROOT}/bin/llvm-tblgen
-DCLANG_TABLEGEN=${COOKBOOK_HOST_SYSROOT}/bin/clang-tblgen
)
COOKBOOK_SOURCE="$COOKBOOK_SOURCE/llvm"