Hi all,

Please ignore this v3, some unintended changes got included in patch 4.
I'll resend a corrected v3 shortly.

Thanks,
Harish

On 08-07-2026 08:48 pm, Sadineni, Harish via lists.openembedded.org wrote:
From: Harish Sadineni <[email protected]>

v2 -> v3:
- Guard against TOOLCHAIN being unset: use d.getVar('TOOLCHAIN') or ''
   instead of d.getVar('TOOLCHAIN') directly (suggested by Bruce Ashfield).

v1 -> v2:
- TOOLCHAIN:riscv64 now explicitly falls back to "gcc" instead of ""
   when rust is not in KERNEL_FEATURES, avoiding an empty TOOLCHAIN value.

This series adds LLVM/Clang toolchain support for kernel builds, defaulting to 
GCC
but enabling Clang automatically for riscv64 when Rust is enabled.

-Convert existing GCC tool definitions (KERNEL_CC, KERNEL_LD, KERNEL_AR, etc.)
  to use the :toolchain-gcc override, so they only apply when TOOLCHAIN = "gcc"
  the existing default behavior is preserved as a no-op.
-Introduce parallel :toolchain-clang definitions using clang, ld.lld, llvm-ar, 
llvm-objcopy,
  and llvm-strip, making it possible to build the kernel with the LLVM/Clang 
toolchain.
-Automatically select the Clang toolchain for riscv64 kernel builds when Rust 
support is enabled,
  since upstream kernel Rust support on riscv64 requires LLVM/clang (per 
https://docs.kernel.org/rust/arch-support.html).
  GCC remains the default everywhere else, including riscv64 without Rust.
-Add lld-native to DEPENDS, since the lld linker is required when building the 
kernel with Clang.
-Fix a config-check failure under Clang: do_kernel_configcheck was erroring out 
with
  kconfiglib.KconfigError: ... Sorry, this assembler is not supported (from 
scripts/Kconfig.include).
  Resolved by setting CLANG_FLAGS = "-fintegrated-as" whenever TOOLCHAIN contains 
"clang"
  this flag is picked up by the kernel build system during config checks so the 
assembler test passes.

Harish Sadineni (4):
   kernel-arch: Add clang toolchain support
   kernel-yocto-rust: use clang toolchain for riscv64 when Rust is
     enabled
   kernel-yocto-rust: Add lld-native to DEPENDS
   kernel-yocto: Set CLANG_FLAGS for kernel config checks when using
     clang

  meta/classes-recipe/kernel-arch.bbclass       | 23 +++++++++++++++----
  meta/classes-recipe/kernel-yocto-rust.bbclass |  3 +++
  meta/classes-recipe/kernel-yocto.bbclass      |  3 +++
  meta/recipes-kernel/linux/linux-yocto.inc     |  4 ++++
  4 files changed, 28 insertions(+), 5 deletions(-)




-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#240506): 
https://lists.openembedded.org/g/openembedded-core/message/240506
Mute This Topic: https://lists.openembedded.org/mt/120174988/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to