diff --git a/recipes/dev/llvm21/recipe.toml b/recipes/dev/llvm21/recipe.toml index e487917ebd..80e05b07c1 100644 --- a/recipes/dev/llvm21/recipe.toml +++ b/recipes/dev/llvm21/recipe.toml @@ -85,8 +85,19 @@ case "${ARCH}" in riscv64gc) LLVM_TARGETS_TO_BUILD="RISCV;AMDGPU;NVPTX";; esac -if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then - LLVM_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX" +# Host LLVM build (TARGET == the host triple): this produces the libLLVM.so that +# lives in the redoxer toolchain and is DYNAMICALLY LINKED by rustc's +# librustc_driver. rustc is a multi-target cross compiler and references the +# AsmPrinter/target symbols for every CPU backend it can emit (X86, AArch64, +# RISCV), so the shared libLLVM MUST retain all three or rustc fails to load +# ("undefined symbol: LLVMInitializeAArch64AsmPrinter"). We additionally add the +# GPU backends (AMDGPU for Mesa radeonsi/radv now, NVPTX for future NVIDIA) that +# get spliced into the toolchain. Net: the host libLLVM carries every CPU target +# rustc needs PLUS the GPU backends — amd64-only still holds (these are codegen +# backends, not host platforms). NB: detect the host build via TARGET, not +# COOKBOOK_HOST_SYSROOT (which is NOT "/usr" for host:llvm21). +if [ "${TARGET}" = "${COOKBOOK_HOST_TARGET}" ]; then + LLVM_TARGETS_TO_BUILD="X86;AArch64;RISCV;AMDGPU;NVPTX" fi # This just build the LLVM library and tools just enough for Rust, to build the rest of LLVM see