llvm21: host libLLVM must keep rustc's CPU targets (X86;AArch64;RISCV) + GPU

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.
This commit is contained in:
2026-07-31 14:19:58 +03:00
parent e4c78b3d18
commit c775ea2539
+13 -2
View File
@@ -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