From 349f64afe95d0a40ad11652ef5096a1ae790eb56 Mon Sep 17 00:00:00 2001 From: Tim Pambor Date: Wed, 2 Sep 2026 10:11:35 +0200 Subject: [PATCH] cmake: zephyr: Define LLVM_USE_LLD for the llvm variant The llvm toolchain description hardcodes 'set(LINKER lld)' in cmake/zephyr/llvm/generic.cmake, but nothing ever told Kconfig about it. Zephyr's linker scripts wrap the output section descriptions for .symtab, .strtab and .shstrtab in '#if defined(CONFIG_LLVM_USE_LLD)', because lld models these as synthetic input sections that have to be placed by the linker script, while GNU ld creates them internally after script processing. That symbol is declared only in Zephyr's cmake/toolchain/host/llvm/Kconfig, which is not sourced for the 'zephyr' variant. CONFIG_LLVM_USE_LLD was therefore never set with ZEPHYR_TOOLCHAIN_VARIANT set to zephyr/llvm, and every link reported the sections as orphans: ld.lld: warning: :(.symtab) is being placed in '.symtab' ld.lld: warning: :(.shstrtab) is being placed in '.shstrtab' ld.lld: warning: :(.strtab) is being placed in '.strtab' Define the symbol in the SDK's Kconfig. No choice is needed, as lld is the only linker this variant can use. Assisted-by: Claude:opus-5 Signed-off-by: Tim Pambor --- cmake/zephyr/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/zephyr/Kconfig b/cmake/zephyr/Kconfig index 16341bf2..0396486c 100644 --- a/cmake/zephyr/Kconfig +++ b/cmake/zephyr/Kconfig @@ -23,6 +23,13 @@ config PICOLIBC_DEFAULT help Zephyr SDK >=0.17.1 always uses Picolibc +config LLVM_USE_LLD + def_bool y + depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr" + depends on "$(TOOLCHAIN_VARIANT_COMPILER)" = "llvm" + help + Zephyr SDK always uses lld with llvm + # libstdc++ is built without exception support in -Os mode choice COMPILER_OPTIMIZATIONS default SPEED_OPTIMIZATIONS if ("$(TOOLCHAIN_VARIANT_COMPILER)" != "llvm") && CPP_EXCEPTIONS