From c775ea25395306133168b1f8fca9349e965aa166 Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 31 Jul 2026 14:19:58 +0300 Subject: [PATCH] llvm21: host libLLVM must keep rustc's CPU targets (X86;AArch64;RISCV) + GPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The host libLLVM.so (COOKBOOK_HOST_SYSROOT=/usr branch) lives in the redoxer toolchain and is dynamically linked by rustc's librustc_driver. Building it as X86;AMDGPU;NVPTX only dropped AArch64/RISCV, so after the AMDGPU splice rustc failed to load with 'undefined symbol: LLVMInitializeAArch64AsmPrinter' — breaking every Rust compile in the tree. Build the host LLVM with all CPU targets rustc emits (X86;AArch64;RISCV) PLUS the GPU backends (AMDGPU;NVPTX). The Redox-target llvm21 stays X86;AMDGPU;NVPTX (Redox is amd64-only, no need to bloat the shipped libLLVM with foreign CPU backends). Fixes a latent regression from 80d20db8/a6999912. --- recipes/dev/llvm21/recipe.toml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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