Skip to content

cmake: zephyr: Define LLVM_USE_LLD for the llvm variant - #1162

Open
tpambor wants to merge 1 commit into
zephyrproject-rtos:mainfrom
tpambor:llvm-use-lld-kconfig
Open

cmake: zephyr: Define LLVM_USE_LLD for the llvm variant#1162
tpambor wants to merge 1 commit into
zephyrproject-rtos:mainfrom
tpambor:llvm-use-lld-kconfig

Conversation

@tpambor

@tpambor tpambor commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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/llvm 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: <internal>:(.symtab) is being placed in '.symtab'
  ld.lld: warning: <internal>:(.shstrtab) is being placed in '.shstrtab'
  ld.lld: warning: <internal>:(.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.

Fixes zephyrproject-rtos/zephyr#96389

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: <internal>:(.symtab) is being placed in '.symtab'
  ld.lld: warning: <internal>:(.shstrtab) is being placed in '.shstrtab'
  ld.lld: warning: <internal>:(.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 <tim.pambor@codewrights.de>
@tpambor
tpambor force-pushed the llvm-use-lld-kconfig branch from 44893a0 to 349f64a Compare September 13, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linking with lld generates warnings

1 participant