* [PATCH 1/4] kernel-arch: Add clang toolchain support
@ 2026-07-06 11:29 Harish.Sadineni
2026-07-06 11:29 ` [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled Harish.Sadineni
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Harish.Sadineni @ 2026-07-06 11:29 UTC (permalink / raw)
To: openembedded-core; +Cc: Sundeep.Kokkonda, raj.khem, tgamblin
From: Harish Sadineni <Harish.Sadineni@windriver.com>
Convert the existing GCC tool definitions to use the `:toolchain-gcc`
override so they only apply when `TOOLCHAIN = "gcc"` (the default).
Introduce new definitions for `:toolchain-clang` that use clang,
ld.lld, llvm-ar, llvm-objcopy, and llvm-strip, allowing the kernel
to be built with the LLVM/Clang toolchain.
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel-arch.bbclass | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass
index 7aea9cd3e8..6ebc0f13ea 100644
--- a/meta/classes-recipe/kernel-arch.bbclass
+++ b/meta/classes-recipe/kernel-arch.bbclass
@@ -71,14 +71,25 @@ HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
TARGET_OBJCOPY_KERNEL_ARCH ?= ""
HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
-KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \
+KERNEL_CC:toolchain-gcc = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \
-fuse-ld=bfd ${DEBUG_PREFIX_MAP} \
-ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \
-ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \
"
-KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
-KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
-KERNEL_OBJCOPY = "${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"
+KERNEL_LD:toolchain-gcc = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
+KERNEL_AR:toolchain-gcc = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
+KERNEL_OBJCOPY:toolchain-gcc = "${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"
# Code in package.py can't handle options on KERNEL_STRIP
-KERNEL_STRIP = "${HOST_PREFIX}strip"
+KERNEL_STRIP:toolchain-gcc = "${HOST_PREFIX}strip"
+
+
+KERNEL_CC:toolchain-clang = "${CCACHE}clang ${HOST_CC_KERNEL_ARCH} \
+ ${DEBUG_PREFIX_MAP} \
+ -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \
+ -ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \
+"
+KERNEL_LD:toolchain-clang = "ld.lld ${HOST_LD_KERNEL_ARCH}"
+KERNEL_AR:toolchain-clang = "llvm-ar ${HOST_AR_KERNEL_ARCH}"
+KERNEL_OBJCOPY:toolchain-clang = "llvm-objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"
+KERNEL_STRIP:toolchain-clang = "llvm-strip"
TOOLCHAIN = "gcc"
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled 2026-07-06 11:29 [PATCH 1/4] kernel-arch: Add clang toolchain support Harish.Sadineni @ 2026-07-06 11:29 ` Harish.Sadineni 2026-07-07 7:37 ` [OE-core] " Mathieu Dubois-Briand 2026-07-06 11:29 ` [PATCH 3/4] kernel-yocto-rust: Add lld-native to DEPENDS Harish.Sadineni 2026-07-06 11:29 ` [PATCH 4/4] kernel-yocto: Set CLANG_FLAGS for kernel config checks when using clang Harish.Sadineni 2 siblings, 1 reply; 6+ messages in thread From: Harish.Sadineni @ 2026-07-06 11:29 UTC (permalink / raw) To: openembedded-core; +Cc: Sundeep.Kokkonda, raj.khem, tgamblin From: Harish Sadineni <Harish.Sadineni@windriver.com> Enable LLVM/Clang toolchain for riscv64 kernel builds when Rust support is enabled, as Rust is only supported with LLVM toolchains for this architecture. This aligns with upstream kernel Rust architecture requirements as documented in: https://docs.kernel.org/rust/arch-support.html Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com> --- meta/recipes-kernel/linux/linux-yocto.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc index 4e230d405a..ee0d5abaeb 100644 --- a/meta/recipes-kernel/linux/linux-yocto.inc +++ b/meta/recipes-kernel/linux/linux-yocto.inc @@ -91,3 +91,7 @@ do_devshell:prepend() { d.setVar("HOSTPKG_CONFIG", "pkg-config-native") d.appendVar("OE_TERMINAL_EXPORTS", " HOSTPKG_CONFIG") } + +# For riscv64, Rust support in kernel only works with LLVM/Clang only. +# https://docs.kernel.org/rust/arch-support.html +TOOLCHAIN:riscv64 = "${@bb.utils.contains('KERNEL_FEATURES', 'rust', 'clang', '', d)}" -- 2.49.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [OE-core] [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled 2026-07-06 11:29 ` [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled Harish.Sadineni @ 2026-07-07 7:37 ` Mathieu Dubois-Briand 2026-07-07 8:35 ` Harish Sadineni 0 siblings, 1 reply; 6+ messages in thread From: Mathieu Dubois-Briand @ 2026-07-07 7:37 UTC (permalink / raw) To: Harish.Sadineni, openembedded-core; +Cc: Sundeep.Kokkonda, raj.khem, tgamblin On Mon Jul 6, 2026 at 1:29 PM CEST, Harish via lists.openembedded.org Sadineni wrote: > From: Harish Sadineni <Harish.Sadineni@windriver.com> > > Enable LLVM/Clang toolchain for riscv64 kernel builds when Rust support > is enabled, as Rust is only supported with LLVM toolchains for this > architecture. > > This aligns with upstream kernel Rust architecture requirements as > documented in: > https://docs.kernel.org/rust/arch-support.html > > Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com> > --- Hi Harish, Thanks for your patch. > meta/recipes-kernel/linux/linux-yocto.inc | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc > index 4e230d405a..ee0d5abaeb 100644 > --- a/meta/recipes-kernel/linux/linux-yocto.inc > +++ b/meta/recipes-kernel/linux/linux-yocto.inc > @@ -91,3 +91,7 @@ do_devshell:prepend() { > d.setVar("HOSTPKG_CONFIG", "pkg-config-native") > d.appendVar("OE_TERMINAL_EXPORTS", " HOSTPKG_CONFIG") > } > + > +# For riscv64, Rust support in kernel only works with LLVM/Clang only. > +# https://docs.kernel.org/rust/arch-support.html > +TOOLCHAIN:riscv64 = "${@bb.utils.contains('KERNEL_FEATURES', 'rust', 'clang', '', d)}" So I believe this is wrong, as you are setting TOOLCHAIN to nothing if rust is not in KERNEL_FEATURES. This is failing on the autobuilder with: Parsing recipes...ERROR: ParseError at /srv/pokybuild/yocto-worker/qemuriscv64/build/layers/openembedded-core/meta/classes-global/base.bbclass:36: Could not inherit file classes/toolchain/.bbclass ERROR: Parsing halted due to errors, see error messages above https://autobuilder.yoctoproject.org/valkyrie/#/builders/45/builds/1836 Can you have a look at the issue? Thanks, Mathieu -- Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OE-core] [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled 2026-07-07 7:37 ` [OE-core] " Mathieu Dubois-Briand @ 2026-07-07 8:35 ` Harish Sadineni 0 siblings, 0 replies; 6+ messages in thread From: Harish Sadineni @ 2026-07-07 8:35 UTC (permalink / raw) To: Mathieu Dubois-Briand, openembedded-core Cc: Sundeep.Kokkonda, raj.khem, tgamblin [-- Attachment #1: Type: text/plain, Size: 2312 bytes --] On 07-07-2026 01:07 pm, Mathieu Dubois-Briand wrote: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > On Mon Jul 6, 2026 at 1:29 PM CEST, Harish via lists.openembedded.org Sadineni wrote: >> From: Harish Sadineni<Harish.Sadineni@windriver.com> >> >> Enable LLVM/Clang toolchain for riscv64 kernel builds when Rust support >> is enabled, as Rust is only supported with LLVM toolchains for this >> architecture. >> >> This aligns with upstream kernel Rust architecture requirements as >> documented in: >> https://docs.kernel.org/rust/arch-support.html >> >> Signed-off-by: Harish Sadineni<Harish.Sadineni@windriver.com> >> --- > Hi Harish, > > Thanks for your patch. > >> meta/recipes-kernel/linux/linux-yocto.inc | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc >> index 4e230d405a..ee0d5abaeb 100644 >> --- a/meta/recipes-kernel/linux/linux-yocto.inc >> +++ b/meta/recipes-kernel/linux/linux-yocto.inc >> @@ -91,3 +91,7 @@ do_devshell:prepend() { >> d.setVar("HOSTPKG_CONFIG", "pkg-config-native") >> d.appendVar("OE_TERMINAL_EXPORTS", " HOSTPKG_CONFIG") >> } >> + >> +# For riscv64, Rust support in kernel only works with LLVM/Clang only. >> +#https://docs.kernel.org/rust/arch-support.html >> +TOOLCHAIN:riscv64 ="${@bb.utils.contains('KERNEL_FEATURES', 'rust', 'clang', '', d)}" > So I believe this is wrong, as you are setting TOOLCHAIN to nothing if > rust is not in KERNEL_FEATURES. > > This is failing on the autobuilder with: > Parsing recipes...ERROR: ParseError at /srv/pokybuild/yocto-worker/qemuriscv64/build/layers/openembedded-core/meta/classes-global/base.bbclass:36: Could not inherit file classes/toolchain/.bbclass > ERROR: Parsing halted due to errors, see error messages above > > https://autobuilder.yoctoproject.org/valkyrie/#/builders/45/builds/1836 > > Can you have a look at the issue? Hi Mathieu, Thanks for catching this and for sharing the autobuilder failure. I will send a new version shortly. Thanks, Harish > > Thanks, > Mathieu > > -- > Mathieu Dubois-Briand, Bootlin > Embedded Linux and Kernel engineering > https://bootlin.com > [-- Attachment #2: Type: text/html, Size: 3813 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] kernel-yocto-rust: Add lld-native to DEPENDS 2026-07-06 11:29 [PATCH 1/4] kernel-arch: Add clang toolchain support Harish.Sadineni 2026-07-06 11:29 ` [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled Harish.Sadineni @ 2026-07-06 11:29 ` Harish.Sadineni 2026-07-06 11:29 ` [PATCH 4/4] kernel-yocto: Set CLANG_FLAGS for kernel config checks when using clang Harish.Sadineni 2 siblings, 0 replies; 6+ messages in thread From: Harish.Sadineni @ 2026-07-06 11:29 UTC (permalink / raw) To: openembedded-core; +Cc: Sundeep.Kokkonda, raj.khem, tgamblin From: Harish Sadineni <Harish.Sadineni@windriver.com> Add lld-native to DEPENDS, As lld linker is required while building kernel with clang. Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com> --- meta/classes-recipe/kernel-yocto-rust.bbclass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/classes-recipe/kernel-yocto-rust.bbclass b/meta/classes-recipe/kernel-yocto-rust.bbclass index 49f2bfc1ae..1badb37476 100644 --- a/meta/classes-recipe/kernel-yocto-rust.bbclass +++ b/meta/classes-recipe/kernel-yocto-rust.bbclass @@ -25,3 +25,6 @@ do_kernel_configme:append () { # More details in: https://lists.openembedded.org/g/openembedded-core/message/229336 # Disable ccache for kernel build if kernel rust support is enabled to workaround this. CCACHE_DISABLE ?= "1" + +DEPENDS:append:riscv64 = " lld-native" +RUST_KERNEL_TASK_DEPENDS:append:riscv64 = " lld-native:do_populate_sysroot" -- 2.49.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] kernel-yocto: Set CLANG_FLAGS for kernel config checks when using clang 2026-07-06 11:29 [PATCH 1/4] kernel-arch: Add clang toolchain support Harish.Sadineni 2026-07-06 11:29 ` [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled Harish.Sadineni 2026-07-06 11:29 ` [PATCH 3/4] kernel-yocto-rust: Add lld-native to DEPENDS Harish.Sadineni @ 2026-07-06 11:29 ` Harish.Sadineni 2 siblings, 0 replies; 6+ messages in thread From: Harish.Sadineni @ 2026-07-06 11:29 UTC (permalink / raw) To: openembedded-core; +Cc: Sundeep.Kokkonda, raj.khem, tgamblin From: Harish Sadineni <Harish.Sadineni@windriver.com> When building with `TOOLCHAIN = "clang"`, the kernel's configuration check (do_kernel_configcheck) fails with: kconfiglib.KconfigError: scripts/Kconfig.include:51: Sorry, this assembler is not supported. Fix by setting `CLANG_FLAGS = "-fintegrated-as"` in the environment when `TOOLCHAIN` contains "clang". This variable is used by the kernel build system (via scripts/Kconfig.include) to pass additional flags to clang during config checks, ensuring the assembler test passes. Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com> --- meta/classes-recipe/kernel-yocto.bbclass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass index e7fdeb5d4b..cda9ffcf9c 100644 --- a/meta/classes-recipe/kernel-yocto.bbclass +++ b/meta/classes-recipe/kernel-yocto.bbclass @@ -603,6 +603,9 @@ python do_kernel_configcheck() { env['STRIP'] = d.getVar('KERNEL_STRIP') env['ARCH'] = d.getVar('ARCH') env['srctree'] = s + toolchain = d.getVar('TOOLCHAIN') + if 'clang' in toolchain: + env['CLANG_FLAGS'] = " -fintegrated-as" try: configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8') -- 2.49.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-07 8:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-06 11:29 [PATCH 1/4] kernel-arch: Add clang toolchain support Harish.Sadineni 2026-07-06 11:29 ` [PATCH 2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled Harish.Sadineni 2026-07-07 7:37 ` [OE-core] " Mathieu Dubois-Briand 2026-07-07 8:35 ` Harish Sadineni 2026-07-06 11:29 ` [PATCH 3/4] kernel-yocto-rust: Add lld-native to DEPENDS Harish.Sadineni 2026-07-06 11:29 ` [PATCH 4/4] kernel-yocto: Set CLANG_FLAGS for kernel config checks when using clang Harish.Sadineni
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.