Files
RedBear-OS/recipes/dev/lld21/recipe.toml
T
vasilito 312659fe21 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>
2026-07-31 06:16:27 +09:00

76 lines
2.2 KiB
TOML

[package]
name = "lld21"
version = "0.1.0"
[source]
same_as = "../llvm21"
[build]
template = "custom"
dependencies = [
"llvm21",
"zstd",
]
dev-dependencies = [
"llvm21.dev",
"llvm21.runtime",
]
script = """
DYNAMIC_INIT
ARCH="$(echo "${TARGET}" | cut -d - -f1)"
generate_cookbook_cmake_file "$COOKBOOK_HOST_TARGET" "" "$COOKBOOK_TOOLCHAIN" native.cmake
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
COOKBOOK_CMAKE_FLAGS+=(
-DLLVM_ROOT="${COOKBOOK_SYSROOT}"
-DCROSS_TOOLCHAIN_FLAGS_NATIVE="-DCMAKE_TOOLCHAIN_FILE=$(realpath native.cmake)"
-DLLVM_USE_STATIC_ZSTD=On
# the shared options from llvm
-DCMAKE_CXX_FLAGS="--std=gnu++11"
-DBUILD_SHARED_LIBS=False
-DLLVM_BUILD_EXAMPLES=Off
-DLLVM_BUILD_TESTS=Off
-DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET}"
-DLLVM_ENABLE_LTO=Off
-DLLVM_ENABLE_RTTI=On
-DLLVM_ENABLE_THREADS=On
-DLLVM_INCLUDE_EXAMPLES=Off
-DLLVM_INCLUDE_TESTS=Off
-DLLVM_OPTIMIZED_TABLEGEN=On
-DLLVM_TARGET_ARCH=$ARCH
-DLLVM_TOOLS_INSTALL_DIR=bin
-DLLVM_UTILS_INSTALL_DIR=bin
-DUNIX=1
)
COOKBOOK_SOURCE="$COOKBOOK_SOURCE/lld"
cookbook_cmake
"""
[[optional-packages]]
name = "dev"
dependencies = []
files = [
"usr/include/lld*/**",
"usr/lib/liblld*.a",
"usr/lib/cmake/lld/**",
]