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