diff mbox series

[RFC,6/7] linux-yocto: enable Rust support in kernel configuration

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

Commit Message

Harish Sadineni Oct. 23, 2025, 11:25 a.m. UTC
From: Harish Sadineni <Harish.Sadineni@windriver.com>

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

- Introduce `rust.cfg` to set Rust-related kernel config options, including:
  - `CONFIG_RUST`, `CONFIG_HAVE_RUST`, and `CONFIG_RUST_IS_AVAILABLE`
  - Rust sample modules and developer checks (overflow/debug assertions)
  - Disable BTF and module versioning for compatibility

- Add `rust.scc` to include `rust.cfg` via `kconf` in the kernel feature stack

- Update `linux-yocto_${PV}.bb` to:
  - Append `rust.scc` to `SRC_URI` and `KERNEL_FEATURES`
  - Suppress `buildpaths` QA warning due to Rust path inclusion during builds

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-kernel/linux/files/rust.cfg      | 20 +++++++++++++++++++
 meta/recipes-kernel/linux/files/rust.scc      |  1 +
 meta/recipes-kernel/linux/linux-yocto_6.16.bb |  4 ++++
 3 files changed, 25 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/files/rust.cfg
 create mode 100644 meta/recipes-kernel/linux/files/rust.scc

Comments

El Mehdi YOUNES Oct. 23, 2025, 3:10 p.m. UTC | #1
Hi Harish,

Le 23/10/2025 à 13:25, Harish.Sadineni@windriver.com a écrit :
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> Add initial support for building the Linux kernel with Rust enabled:
>
> - Introduce `rust.cfg` to set Rust-related kernel config options, including:
>    - `CONFIG_RUST`, `CONFIG_HAVE_RUST`, and `CONFIG_RUST_IS_AVAILABLE`
>    - Rust sample modules and developer checks (overflow/debug assertions)
>    - Disable BTF and module versioning for compatibility
>
> - Add `rust.scc` to include `rust.cfg` via `kconf` in the kernel feature stack
>
> - Update `linux-yocto_${PV}.bb` to:
>    - Append `rust.scc` to `SRC_URI` and `KERNEL_FEATURES`
>    - Suppress `buildpaths` QA warning due to Rust path inclusion during builds
>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
>   meta/recipes-kernel/linux/files/rust.cfg      | 20 +++++++++++++++++++
>   meta/recipes-kernel/linux/files/rust.scc      |  1 +
>   meta/recipes-kernel/linux/linux-yocto_6.16.bb |  4 ++++
>   3 files changed, 25 insertions(+)
>   create mode 100644 meta/recipes-kernel/linux/files/rust.cfg
>   create mode 100644 meta/recipes-kernel/linux/files/rust.scc
>
> diff --git a/meta/recipes-kernel/linux/files/rust.cfg b/meta/recipes-kernel/linux/files/rust.cfg
> new file mode 100644
> index 0000000000..293438e8e0
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/rust.cfg
> @@ -0,0 +1,20 @@
> +CONFIG_RUST=y
> +CONFIG_SAMPLES_RUST=y
> +CONFIG_SAMPLE_RUST_MINIMAL=y
> +CONFIG_SAMPLE_RUST_PRINT=y
> +CONFIG_SAMPLE_RUST_HOSTPROGS=y
> +CONFIG_RUST_DEBUG_ASSERTIONS=y
> +CONFIG_RUST_OVERFLOW_CHECKS=y
> +CONFIG_RUST_BUILD_ASSERT_ALLOW=y
> +# Disable module versioning
> +CONFIG_MODVERSIONS=n
> +
> +# Disable BTF debug info
> +CONFIG_DEBUG_INFO_BTF=n
> +
> +# Rust availability
> +CONFIG_RUST_IS_AVAILABLE=y
> +
> +# Indicate Rust support present
> +CONFIG_HAVE_RUST=y

Since Patch 5 correctly adds the 'make rustavailable' check

during 'do_kernel_configme', shouldn't we let the kernel's build system

determine these values automatically based on the actual toolchain 
readiness?

> +
> diff --git a/meta/recipes-kernel/linux/files/rust.scc b/meta/recipes-kernel/linux/files/rust.scc
> new file mode 100644
> index 0000000000..4686d9ce5e
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/rust.scc
> @@ -0,0 +1 @@
> +kconf 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..fda964e78d 100644
> --- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> @@ -77,3 +77,7 @@ 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"
> +INSANE_SKIP:kernel-vmlinux = "buildpaths"
> +INSANE_SKIP:kernel-dbg = "buildpaths"
> +SRC_URI += "file://rust.scc"
> +KERNEL_FEATURES += "rust.scc"
Randy MacLeod Nov. 4, 2025, 5:43 p.m. UTC | #2
On 2025-10-23 7:25 a.m., Sadineni, Harish via lists.openembedded.org wrote:
> From: Harish Sadineni<Harish.Sadineni@windriver.com>
>
> Add initial support for building the Linux kernel with Rust enabled:
>
> - Introduce `rust.cfg` to set Rust-related kernel config options, including:
>    - `CONFIG_RUST`, `CONFIG_HAVE_RUST`, and `CONFIG_RUST_IS_AVAILABLE`
>    - Rust sample modules and developer checks (overflow/debug assertions)
>    - Disable BTF and module versioning for compatibility
>
> - Add `rust.scc` to include `rust.cfg` via `kconf` in the kernel feature stack
>
> - Update `linux-yocto_${PV}.bb` to:
>    - Append `rust.scc` to `SRC_URI` and `KERNEL_FEATURES`
>    - Suppress `buildpaths` QA warning due to Rust path inclusion during builds
>
> Signed-off-by: Harish Sadineni<Harish.Sadineni@windriver.com>
> ---
>   meta/recipes-kernel/linux/files/rust.cfg      | 20 +++++++++++++++++++
>   meta/recipes-kernel/linux/files/rust.scc      |  1 +
This is fine for an RFC but at some point, when Bruce asks for an 
non-RFC version,
I expect that you will need to move this to the yocto-kenrel-cache, 
perhaps under:

https://git.yoctoproject.org/yocto-kernel-cache/tree/cfg

Take a look at the yocto-kernel-cache repo and docs:
https://docs.yoctoproject.org/kernel-dev/advanced.html
if you haven't already.

>   meta/recipes-kernel/linux/linux-yocto_6.16.bb |  4 ++++
>   3 files changed, 25 insertions(+)
>   create mode 100644 meta/recipes-kernel/linux/files/rust.cfg
>   create mode 100644 meta/recipes-kernel/linux/files/rust.scc
>
> diff --git a/meta/recipes-kernel/linux/files/rust.cfg b/meta/recipes-kernel/linux/files/rust.cfg
> new file mode 100644
> index 0000000000..293438e8e0
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/rust.cfg
> @@ -0,0 +1,20 @@
> +CONFIG_RUST=y
> +CONFIG_SAMPLES_RUST=y
> +CONFIG_SAMPLE_RUST_MINIMAL=y
> +CONFIG_SAMPLE_RUST_PRINT=y
> +CONFIG_SAMPLE_RUST_HOSTPROGS=y
> +CONFIG_RUST_DEBUG_ASSERTIONS=y
> +CONFIG_RUST_OVERFLOW_CHECKS=y
> +CONFIG_RUST_BUILD_ASSERT_ALLOW=y
> +# Disable module versioning
> +CONFIG_MODVERSIONS=n
> +
> +# Disable BTF debug info
> +CONFIG_DEBUG_INFO_BTF=n
> +
> +# Rust availability
> +CONFIG_RUST_IS_AVAILABLE=y
> +
> +# Indicate Rust support present
> +CONFIG_HAVE_RUST=y


You'll have to review this list to divide it up into:
   1. a minimal rust.cfg and perhaps
   2. a rust-samples.cfg
   3. a rust-debug.cfg  if that's really what 
CONFIG_RUST_DEBUG_ASSERTIONS and friends are doing: 
https://cateee.net/lkddb/web-lkddb/RUST_DEBUG_ASSERTIONS.html Also, 
you'll need to explain and justify each option or set of options more 
clearly in the commit log.


As Bruce said, the next steps are:
1. Rust being optional and off by default 2. Rust binary / prebuilt 
components to minimize the overhead and dependencies of rust and related 
tools on the kernel.

Anyway, this is a super start and I understand you have a v2 almost 
ready that makes kenrel rust-support be optional so send that now and 
we'll see what the next step after that is.


Thanks,

../Randy

> +
> diff --git a/meta/recipes-kernel/linux/files/rust.scc b/meta/recipes-kernel/linux/files/rust.scc
> new file mode 100644
> index 0000000000..4686d9ce5e
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/rust.scc
> @@ -0,0 +1 @@
> +kconf 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..fda964e78d 100644
> --- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> @@ -77,3 +77,7 @@ 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"
> +INSANE_SKIP:kernel-vmlinux = "buildpaths"
> +INSANE_SKIP:kernel-dbg = "buildpaths"
> +SRC_URI +="file://rust.scc"
> +KERNEL_FEATURES += "rust.scc"
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#225242):https://lists.openembedded.org/g/openembedded-core/message/225242
> Mute This Topic:https://lists.openembedded.org/mt/115908712/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/files/rust.cfg b/meta/recipes-kernel/linux/files/rust.cfg
new file mode 100644
index 0000000000..293438e8e0
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust.cfg
@@ -0,0 +1,20 @@ 
+CONFIG_RUST=y
+CONFIG_SAMPLES_RUST=y
+CONFIG_SAMPLE_RUST_MINIMAL=y
+CONFIG_SAMPLE_RUST_PRINT=y
+CONFIG_SAMPLE_RUST_HOSTPROGS=y
+CONFIG_RUST_DEBUG_ASSERTIONS=y
+CONFIG_RUST_OVERFLOW_CHECKS=y
+CONFIG_RUST_BUILD_ASSERT_ALLOW=y
+# Disable module versioning
+CONFIG_MODVERSIONS=n
+
+# Disable BTF debug info
+CONFIG_DEBUG_INFO_BTF=n
+
+# Rust availability
+CONFIG_RUST_IS_AVAILABLE=y
+
+# Indicate Rust support present
+CONFIG_HAVE_RUST=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..4686d9ce5e
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust.scc
@@ -0,0 +1 @@ 
+kconf 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..fda964e78d 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
@@ -77,3 +77,7 @@  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"
+INSANE_SKIP:kernel-vmlinux = "buildpaths"
+INSANE_SKIP:kernel-dbg = "buildpaths"
+SRC_URI += "file://rust.scc"
+KERNEL_FEATURES += "rust.scc"