diff mbox series

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

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

Commit Message

Harish Sadineni Nov. 5, 2025, 1:09 p.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`

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.cfg      | 9 +++++++++
 meta/recipes-kernel/linux/files/rust.scc      | 1 +
 meta/recipes-kernel/linux/linux-yocto_6.16.bb | 3 +++
 3 files changed, 13 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/files/rust.cfg
 create mode 100644 meta/recipes-kernel/linux/files/rust.scc

Comments

Bruce Ashfield Nov. 5, 2025, 1:34 p.m. UTC | #1
On Wed, Nov 5, 2025 at 8:10 AM <Harish.Sadineni@windriver.com> 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`
>
> 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.cfg      | 9 +++++++++
>  meta/recipes-kernel/linux/files/rust.scc      | 1 +
>  meta/recipes-kernel/linux/linux-yocto_6.16.bb | 3 +++
>  3 files changed, 13 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..a884f3cf6b
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/rust.cfg
> @@ -0,0 +1,9 @@
> +CONFIG_RUST=y
> +CONFIG_SAMPLES_RUST=y
> +CONFIG_SAMPLE_RUST_MINIMAL=m
> +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
>

The debug, samples and core support should be in separate fragments.

Bruce



> +
> 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..33bd8a92c3 100644
> --- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> @@ -77,3 +77,6 @@ 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', '', d)}"
> +KERNEL_FEATURES:append = " ${@bb.utils.contains("DISTRO_FEATURES",
> "RUST", "rust.scc", "", d)}"
> +
> --
> 2.49.0
>
>
Gyorgy Sarvari Nov. 5, 2025, 8:39 p.m. UTC | #2
On 11/5/25 14:09, 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`
>
> 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.cfg      | 9 +++++++++
>  meta/recipes-kernel/linux/files/rust.scc      | 1 +
>  meta/recipes-kernel/linux/linux-yocto_6.16.bb | 3 +++
>  3 files changed, 13 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..a884f3cf6b
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/rust.cfg
> @@ -0,0 +1,9 @@
> +CONFIG_RUST=y
> +CONFIG_SAMPLES_RUST=y
> +CONFIG_SAMPLE_RUST_MINIMAL=m
> +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
> +
> 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..33bd8a92c3 100644
> --- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
> @@ -77,3 +77,6 @@ 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', '', d)}"
> +KERNEL_FEATURES:append = " ${@bb.utils.contains("DISTRO_FEATURES", "RUST", "rust.scc", "", d)}"

Shouldn't this check also for 'rust-kernel' instead of 'RUST'?
Harish Sadineni Nov. 6, 2025, 7:11 a.m. UTC | #3
On 11/6/2025 2:09 AM, Gyorgy Sarvari 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 11/5/25 14:09, 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`
>>
>> 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.cfg      | 9 +++++++++
>>   meta/recipes-kernel/linux/files/rust.scc      | 1 +
>>   meta/recipes-kernel/linux/linux-yocto_6.16.bb | 3 +++
>>   3 files changed, 13 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..a884f3cf6b
>> --- /dev/null
>> +++ b/meta/recipes-kernel/linux/files/rust.cfg
>> @@ -0,0 +1,9 @@
>> +CONFIG_RUST=y
>> +CONFIG_SAMPLES_RUST=y
>> +CONFIG_SAMPLE_RUST_MINIMAL=m
>> +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
>> +
>> 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..33bd8a92c3 100644
>> --- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
>> +++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
>> @@ -77,3 +77,6 @@ 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', '', d)}"
>> +KERNEL_FEATURES:append = " ${@bb.utils.contains("DISTRO_FEATURES", "RUST", "rust.scc", "", d)}"
> Shouldn't this check also for 'rust-kernel' instead of 'RUST'?
Yes it should be 'rust-kernel' thanks for pointing it, we got missed it 
while updating RFC we will correct it while sending v3.

Thanks
Harish
>
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..a884f3cf6b
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/rust.cfg
@@ -0,0 +1,9 @@ 
+CONFIG_RUST=y
+CONFIG_SAMPLES_RUST=y
+CONFIG_SAMPLE_RUST_MINIMAL=m
+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
+
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..33bd8a92c3 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
@@ -77,3 +77,6 @@  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', '', d)}"
+KERNEL_FEATURES:append = " ${@bb.utils.contains("DISTRO_FEATURES", "RUST", "rust.scc", "", d)}"
+