diff mbox series

[RFC,v3,07/11] linux-yocto: enable Rust support in kernel configuration

Message ID 20251119164804.256364-8-Harish.Sadineni@windriver.com
State New
Headers show
Series Enable rust support for linux kernel | expand

Commit Message

Harish Sadineni Nov. 19, 2025, 4:47 p.m. UTC
From: Harish Sadineni <Harish.Sadineni@windriver.com>

Add initial support for building the Linux kernel with Rust enabled:

- Introduce `rust.cfg rust-samples.cfg rust-debug.cfg` to set Rust-related kernel config options, including:
  - `CONFIG_RUST=y`
  - Rust sample modules and developer checks (overflow/debug assertions)

- Update `linux-yocto_${PV}.bb` to:
  - Append `rust.scc rust-samples.scc` to `SRC_URI` and `KERNEL_FEATURES`

when sending non-RFC version, we will send kernel-config-fragment to the yocto-kenrel-cache

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-kernel/linux/files/rust-debug.cfg   | 1 +
 meta/recipes-kernel/linux/files/rust-debug.scc   | 3 +++
 meta/recipes-kernel/linux/files/rust-samples.cfg | 4 ++++
 meta/recipes-kernel/linux/files/rust-samples.scc | 3 +++
 meta/recipes-kernel/linux/files/rust.cfg         | 3 +++
 meta/recipes-kernel/linux/files/rust.scc         | 3 +++
 meta/recipes-kernel/linux/linux-yocto_6.16.bb    | 2 ++
 meta/recipes-kernel/linux/linux-yocto_6.17.bb    | 2 ++
 8 files changed, 21 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/files/rust-debug.cfg
 create mode 100644 meta/recipes-kernel/linux/files/rust-debug.scc
 create mode 100644 meta/recipes-kernel/linux/files/rust-samples.cfg
 create mode 100644 meta/recipes-kernel/linux/files/rust-samples.scc
 create mode 100644 meta/recipes-kernel/linux/files/rust.cfg
 create mode 100644 meta/recipes-kernel/linux/files/rust.scc
diff mbox series

Patch

diff --git a/meta/recipes-kernel/linux/files/rust-debug.cfg b/meta/recipes-kernel/linux/files/rust-debug.cfg
new file mode 100644
index 0000000000..d9aeeb4e91
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust-debug.cfg
@@ -0,0 +1 @@ 
+CONFIG_RUST_DEBUG_ASSERTIONS=y
diff --git a/meta/recipes-kernel/linux/files/rust-debug.scc b/meta/recipes-kernel/linux/files/rust-debug.scc
new file mode 100644
index 0000000000..ef0ef3af6e
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust-debug.scc
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: MIT
+
+kconf non-hardware rust-debug.cfg
diff --git a/meta/recipes-kernel/linux/files/rust-samples.cfg b/meta/recipes-kernel/linux/files/rust-samples.cfg
new file mode 100644
index 0000000000..c6cc803702
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust-samples.cfg
@@ -0,0 +1,4 @@ 
+CONFIG_SAMPLES_RUST=y
+CONFIG_SAMPLE_RUST_MINIMAL=m
+CONFIG_SAMPLE_RUST_PRINT=y
+CONFIG_SAMPLE_RUST_HOSTPROGS=y
diff --git a/meta/recipes-kernel/linux/files/rust-samples.scc b/meta/recipes-kernel/linux/files/rust-samples.scc
new file mode 100644
index 0000000000..476cc92f93
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust-samples.scc
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: MIT
+
+kconf non-hardware rust-samples.cfg
diff --git a/meta/recipes-kernel/linux/files/rust.cfg b/meta/recipes-kernel/linux/files/rust.cfg
new file mode 100644
index 0000000000..105eb0a14d
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust.cfg
@@ -0,0 +1,3 @@ 
+CONFIG_RUST=y
+CONFIG_RUST_OVERFLOW_CHECKS=y
+CONFIG_RUST_BUILD_ASSERT_ALLOW=y
diff --git a/meta/recipes-kernel/linux/files/rust.scc b/meta/recipes-kernel/linux/files/rust.scc
new file mode 100644
index 0000000000..51d9de1673
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust.scc
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: MIT
+
+kconf non-hardware rust.cfg
diff --git a/meta/recipes-kernel/linux/linux-yocto_6.16.bb b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
index 2188c7fed2..37cada11a5 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
@@ -77,3 +77,5 @@  KERNEL_FEATURES:append:powerpc64le = " arch/powerpc/powerpc-debug.scc"
 # Check again during next major version upgrade
 KERNEL_FEATURES:remove:riscv32 = "features/debug/debug-kernel.scc"
 INSANE_SKIP:kernel-vmlinux:qemuppc64 = "textrel"
+SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' file://rust.scc file://rust-samples.scc file://rust-debug.scc', '', d)}"
+KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' rust.scc rust-samples.scc rust-debug.scc', '', d)}"
diff --git a/meta/recipes-kernel/linux/linux-yocto_6.17.bb b/meta/recipes-kernel/linux/linux-yocto_6.17.bb
index 5d10a17e70..f63405a3a0 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.17.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.17.bb
@@ -77,3 +77,5 @@  KERNEL_FEATURES:append:powerpc64le = " arch/powerpc/powerpc-debug.scc"
 # Check again during next major version upgrade
 KERNEL_FEATURES:remove:riscv32 = "features/debug/debug-kernel.scc"
 INSANE_SKIP:kernel-vmlinux:qemuppc64 = "textrel"
+SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' file://rust.scc file://rust-samples.scc file://rust-debug.scc', '', d)}"
+KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' rust.scc rust-samples.scc rust-debug.scc', '', d)}"