lld21/llvm-native: pin cross tblgen to version-matched redoxer toolchain

Cross-building lld/llvm needs a HOST-runnable llvm-tblgen to generate the
Options.inc opt-parser sources, and it must match the LLVM 21 source tree.
Both recipes referenced ${COOKBOOK_HOST_SYSROOT}/bin/llvm-tblgen, but the
cookbook does not export COOKBOOK_HOST_SYSROOT, so the path collapsed to the
host /bin/llvm-tblgen. On a rolling distro that is now LLVM 22, whose
-gen-opt-parser-defs backend requires a 'SubCommand' TableGen class absent
from LLVM 21's OptParser.td:

    error: The class 'SubCommand' is not defined

Default COOKBOOK_HOST_SYSROOT to the redoxer toolchain (host-runnable LLVM
21.1.2 llvm-/clang-tblgen), exactly as the sibling clang21 recipe already
does. Fixes the full-target build reaching mesa's LLVM build-deps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-31 06:16:27 +09:00
parent bcfb36633f
commit 312659fe21
2 changed files with 18 additions and 0 deletions
@@ -23,6 +23,14 @@ case "${ARCH}" in
riscv64gc) LLVM_TARGETS_TO_BUILD="RISCV";;
esac
# The *-tblgen references below must be VERSION-MATCHED to this LLVM source
# tree. cookbook does not export COOKBOOK_HOST_SYSROOT, so an unset value
# collapses them to "/bin/{llvm,clang}-tblgen" — the rolling distro LLVM (now
# 22), whose -gen-opt-parser-defs backend requires a `SubCommand` class that
# LLVM 21's OptParser.td does not define. Point at the redoxer toolchain's
# host-runnable LLVM 21.1.2 tblgen, matching the clang21/lld21 recipes.
export COOKBOOK_HOST_SYSROOT="${COOKBOOK_HOST_SYSROOT:-${HOME}/.redoxer/${TARGET}/toolchain}"
COOKBOOK_CMAKE_FLAGS+=(
-DLLVM_ENABLE_PROJECTS="clang;lld"
-DLLVM_BUILD_LLVM_DYLIB=On
+10
View File
@@ -24,6 +24,16 @@ generate_cookbook_cmake_file "$COOKBOOK_HOST_TARGET" "" "$COOKBOOK_TOOLCHAIN" na
if [ "$TARGET" = "$COOKBOOK_HOST_TARGET" ]; then
COOKBOOK_CMAKE_FLAGS+=( -DLLVM_TABLEGEN_EXE=${COOKBOOK_TOOLCHAIN}/bin/llvm-tblgen )
else
# Cross-building lld needs a HOST-runnable llvm-tblgen to generate the
# Options.inc sources, and it MUST be version-matched to the LLVM 21 source
# tree: the host's /bin/llvm-tblgen tracks the rolling distro LLVM (now 22),
# whose -gen-opt-parser-defs backend requires a `SubCommand` class that LLVM
# 21's OptParser.td does not define ("error: The class 'SubCommand' is not
# defined"). cookbook does not export COOKBOOK_HOST_SYSROOT, so the reference
# below collapsed to "/bin/llvm-tblgen" (the mismatched host tool). The
# redoxer toolchain ships a host-runnable LLVM 21.1.2 llvm-tblgen; point at it
# exactly as the sibling clang21 recipe does.
export COOKBOOK_HOST_SYSROOT="${COOKBOOK_HOST_SYSROOT:-${HOME}/.redoxer/${TARGET}/toolchain}"
COOKBOOK_CMAKE_FLAGS+=( -DLLVM_TABLEGEN_EXE=${COOKBOOK_HOST_SYSROOT}/bin/llvm-tblgen )
fi