From 312659fe21b795641f319c55d36b5e15858f60ce Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 31 Jul 2026 06:16:27 +0900 Subject: [PATCH] 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 --- local/recipes/dev/llvm-native/recipe.toml | 8 ++++++++ recipes/dev/lld21/recipe.toml | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/local/recipes/dev/llvm-native/recipe.toml b/local/recipes/dev/llvm-native/recipe.toml index 4719875a3f..b356a3b39e 100644 --- a/local/recipes/dev/llvm-native/recipe.toml +++ b/local/recipes/dev/llvm-native/recipe.toml @@ -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 diff --git a/recipes/dev/lld21/recipe.toml b/recipes/dev/lld21/recipe.toml index ec354e59fb..22d55351b8 100644 --- a/recipes/dev/lld21/recipe.toml +++ b/recipes/dev/lld21/recipe.toml @@ -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