diff mbox series

[v3,2/4] kernel-yocto-rust: use clang toolchain for riscv64 when Rust is enabled

Message ID 20260708185724.2183159-3-Harish.Sadineni@windriver.com
State Changes Requested
Headers show
Series Add Clang toolchain support for kernel builds | expand

Commit Message

Harish Sadineni July 8, 2026, 6:57 p.m. UTC
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

Acked-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-kernel/linux/linux-yocto.inc | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Randy MacLeod July 13, 2026, 5:11 p.m. UTC | #1
On 2026-07-08 14:57, Sadineni, Harish via lists.openembedded.org 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
>
> Acked-by: Bruce Ashfield<bruce.ashfield@gmail.com>
> 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..5d047b5f01 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', 'gcc', d)}"

Rather than silently switching the kernel toolchain,
check for this situation and exit with an error to force the user to 
specify the toolchain if they have enable the rust KERNEL_FEATURE .

The user should be responsible for and informed about the requirement 
rather than having them finding out some time later that
they have been silently switched from gcc to rust.

Also, if the user has already switched to using clang for the kernel for 
risvc, the no action is required.


This patch series was review in today's YP patch review meeting.
The first and last patch will be merged.

For the middle 2 commits, in addition to the change above, merge them 
together.
This ensures that the shortlog for the lld-native change also specifies 
that it's rust specific.
and it enabled the build in one commit.


../Randy


>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#240512):https://lists.openembedded.org/g/openembedded-core/message/240512
> Mute This Topic:https://lists.openembedded.org/mt/120178683/3616765
> Group Owner:openembedded-core+owner@lists.openembedded.org
> Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub [randy.macleod@windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 4e230d405a..5d047b5f01 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', 'gcc', d)}"