* [PATCH 00/16] Enable rust support for linux kernel
@ 2025-12-27 11:32 Harish.Sadineni
2025-12-27 11:32 ` [PATCH 01/16] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
` (16 more replies)
0 siblings, 17 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
This patch series introduces Rust support into the linux-yocto kernel recipe
and related build infrastructure in the Yocto Project. The goal is to enable
building the Linux kernel with Rust components and provide support for building
kernel module which is written in rust and also provide support to build
rust kernel modules in sdk.
And this series adds test for Linux Rust sample and also added support for out-of-tree kernel
module written in Rust as well as associated test.
Summary of patches:
- Patch 01: Extend 'bindgen-cli' to support 'nativesdk', allowing it to be available in the SDK environment.
- Patch 02: Add required dependencies ('clang-native', 'rust-native', 'bindgen-cli-native') to the kernel to support Rust binding generation.
- Patch 03: Install the Rust standard library source ('library/') into `work-shared` and which will be later copied to
linux-yocto recipe-sysroot-native.
- Patch 04: Added 'rust-kernel' to DISTRO_FEATURES_FILTER_NATIVE and DISTRO_FEATURES_FILTER_NATIVESDK, the 'rust-kernel' feature automatically
propagates from target DISTRO_FEATURES to native/nativesdk builds
- Patch 05: Stage the Rust sources into `recipe-sysroot-native` for kernel build compatibility, making them visible during native builds.
- Patch 06: Update `kernel-yocto.bbclass` to invoke `make rustavailable` during 'do_kernel_configme', ensuring Rust readiness.
- Patch 07: Add kernel configuration support for Rust (via 'kernel-rust.scc'), enabling the Rust build options in kernel config.
- Patch 08: Fixed buildpaths errors when rust is enabled for kernel by appending --remap-path-prefix to RUST_DEBUG_REMAP
- Patch 09: Disabling ccache when rust-kernel is enabled for linux-yocto.
- Patch 10: Copy Rust kernel sources into kernel-devsrc build directory which will be required while running 'make prepare' in sdk.
- Patch 11: Added oe-selftest case for the Linux Rust sample.
- patch 12: Copying include/config/auto.conf in STAGING_KERNEL_BUILDDIR
- patch 13: Export artifacts needed for out-of-tree Rust compilation
- patch 14: Prepare out-of-tree rust module compilation
- patch 15: Added rust-out-of-tree-module recipe in meta-skeleton layer
- patch 16: Added rust-out-of-tree selftest
Patches have been build-tested successfully on:
- qemuarm64
- qemux86-64
Benchmark test-result for x86-64:
+-------------------------------+------------+-----------+-----------+-----------+
| DISTRO_FEATURES | real | user | sys | FS usage |
+-------------------------------+------------+-----------+-----------+-----------+
| rust-kernel (enabled) | 46m1.720s | 0m28.864s | 0m3.696s | 58 GB |
| rust-kernel (disabled) | 30m1.053s | 0m20.091s | 0m2.748s | 33 GB |
+-------------------------------+------------+-----------+-----------+-----------+
The increased in time & fs is due to kernel rust dependencies in
linux-yocto.
Harish Sadineni (9):
bindgen-cli: extend BBCLASSEXTEND to include nativesdk
linux-yocto: conditionally add clang/rust/bindgen-cli-native to
DEPENDS
rust: install Rust library sources for 'make rustavailable' support
bitbake.conf: Include "rust-kernel" in native/nativesdk feature
filters
kernel-yocto: stage rustlib sources for linux-yocto 'make
rustavailable' support
kernel-yocto: add rust support via "make rustavailable" in
do_kernel_configme
linux-yocto: enable Rust support in kernel configuration
kernel-yocto: Fix for buildpaths errors when rust is enabled for
kernel
kernel-devsrc: copying rust-kernel source to $kerneldir/build
Yoann Congal (7):
kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
selftest/cases/runtime_test: Add test for Linux Rust sample
kernel.bbclass: Copy include/config/auto.conf in
STAGING_KERNEL_BUILDDIR
kernel.bbclass: Export artifacts needed for out-of-tree Rust
compilation
module.bbclass: Prepare out-of-tree rust module compilation
meta-skeleton: Add rust-out-of-tree-module recipe
runtime_test: Add rust-out-of-tree selftest
.../rust-out-of-tree-module_git.bb | 18 ++++++++++
meta/classes-recipe/kernel-yocto.bbclass | 28 +++++++++++++++
meta/classes-recipe/kernel.bbclass | 19 ++++++++++
meta/classes-recipe/module.bbclass | 8 +++++
meta/conf/bitbake.conf | 4 +--
meta/lib/oeqa/selftest/cases/runtime_test.py | 35 +++++++++++++++++++
.../bindgen-cli/bindgen-cli_0.72.1.bb | 2 +-
meta/recipes-devtools/rust/rust_1.91.1.bb | 17 +++++++++
meta/recipes-kernel/linux/kernel-devsrc.bb | 4 +++
meta/recipes-kernel/linux/linux-yocto.inc | 2 ++
meta/recipes-kernel/linux/linux-yocto_6.16.bb | 1 +
meta/recipes-kernel/linux/linux-yocto_6.18.bb | 1 +
12 files changed, 136 insertions(+), 3 deletions(-)
create mode 100644 meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
--
2.49.0
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 01/16] bindgen-cli: extend BBCLASSEXTEND to include nativesdk
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 02/16] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
` (15 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
To support building Rust bindings in the SDK environment, bindgen needs to
be available for the `nativesdk` class as well.
This is required as part of making Rust available, where bindgen is a common
dependency for generating Rust FFI bindings from C headers during cross-compilation.
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb b/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb
index 2f3ec04e82..72dadfe52f 100644
--- a/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb
+++ b/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb
@@ -15,4 +15,4 @@ do_install:append:class-native() {
create_wrapper ${D}/${bindir}/bindgen LIBCLANG_PATH="${STAGING_LIBDIR_NATIVE}"
}
-BBCLASSEXTEND = "native"
+BBCLASSEXTEND = "native nativesdk"
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 02/16] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
2025-12-27 11:32 ` [PATCH 01/16] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 03/16] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
` (14 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
Conditionally add 'clang-native', 'rust-native' and 'bindgen-cli-native' to 'DEPENDS'
when rust-kernel distro feature is enabled to support Rust-based kernel modules or
features that require generating Rust FFI bindings using bindgen during the kernel
build process.
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/recipes-kernel/linux/linux-yocto.inc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index 4d0a726bb6..41b12b6f14 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -81,6 +81,8 @@ KERNEL_DEBUG ?= ""
DEPENDS += '${@bb.utils.contains_any("ARCH", [ "x86", "arm64", "powerpc" ], "elfutils-native", "", d)}'
DEPENDS += "openssl-native util-linux-native"
DEPENDS += "gmp-native libmpc-native"
+RUST_KERNEL_DEPENDS ?= "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'clang-native rust-native bindgen-cli-native', '', d)}"
+DEPENDS += "${RUST_KERNEL_DEPENDS}"
# Some options depend on CONFIG_PAHOLE_VERSION, so need to make pahole-native available before do_kernel_configme
do_kernel_configme[depends] += '${@bb.utils.contains("KERNEL_DEBUG", "True", "pahole-native:do_populate_sysroot", "", d)}'
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 03/16] rust: install Rust library sources for 'make rustavailable' support
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
2025-12-27 11:32 ` [PATCH 01/16] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
2025-12-27 11:32 ` [PATCH 02/16] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 04/16] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
` (13 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
The `make rustavailable` process (1) expects the Rust standard library source files (e.g., `lib.rs`)
to be present in the `library/` directory under `rustlib/src/rust/`.
This patch ensures the required sources are available by:
- Copying the `library/` directory from the Rust source tree into `${TMPDIR}/work-shared/rust`
during the snapshot setup.
- Installing the `library/` directory into `${SDKPATHNATIVE}/usr/lib/rustlib/src/rust` for the
`nativesdk` class, making them available in them available in sdk
1) See the kernel tree for Documentation/rust/quick-start.rst in the section: Requirements: Building
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/rust/quick-start.rst#n145
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/recipes-devtools/rust/rust_1.91.1.bb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/meta/recipes-devtools/rust/rust_1.91.1.bb b/meta/recipes-devtools/rust/rust_1.91.1.bb
index a25f65f674..7644ecf2d2 100644
--- a/meta/recipes-devtools/rust/rust_1.91.1.bb
+++ b/meta/recipes-devtools/rust/rust_1.91.1.bb
@@ -63,6 +63,16 @@ do_rust_setup_snapshot () {
done
fi
}
+
+do_rust_setup_snapshot:append:class-native () {
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+ if [ ! -d "${TMPDIR}/work-shared/rust" ]; then
+ mkdir -p ${TMPDIR}/work-shared/rust
+ cp -r ${RUSTSRC}/library ${TMPDIR}/work-shared/rust/.
+ fi
+ fi
+}
+
addtask rust_setup_snapshot after do_unpack before do_configure
addtask do_test_compile after do_configure do_rust_gen_targets
do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
@@ -314,6 +324,13 @@ rust_do_install:class-nativesdk() {
export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}"
export CC_$RUST_HOST_CC="${CCACHE}${HOST_PREFIX}gcc"
EOF
+
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+ if [ ! -d ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust ]; then
+ mkdir -p ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust
+ cp -r --no-preserve=ownership ${S}/library ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust/
+ fi
+ fi
}
FILES:${PN} += "${base_prefix}/environment-setup.d"
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 04/16] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (2 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 03/16] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 05/16] kernel-yocto: stage rustlib sources for linux-yocto 'make rustavailable' support Harish.Sadineni
` (12 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
When enabling Rust in kernel, native and nativesdk variants of rust need
to conditionally install Rust standard library sources to support 'make rustavailable'
in the kernel build system.
By adding 'rust-kernel' to DISTRO_FEATURES_FILTER_NATIVE and
DISTRO_FEATURES_FILTER_NATIVESDK, the 'rust-kernel' feature automatically
propagates from target DISTRO_FEATURES to native/nativesdk builds
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/conf/bitbake.conf | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 88f4d0df69..c0bebc3ceb 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -917,8 +917,8 @@ DISTRO_FEATURES_NATIVESDK:mingw32 = "x11 ipv6"
# Normally target distro features will not be applied to native builds:
# Native distro features on this list will use the target feature value
-DISTRO_FEATURES_FILTER_NATIVE ?= "api-documentation debuginfod opencl opengl wayland"
-DISTRO_FEATURES_FILTER_NATIVESDK ?= "api-documentation debuginfod opencl opengl wayland"
+DISTRO_FEATURES_FILTER_NATIVE ?= "api-documentation debuginfod opencl opengl rust-kernel wayland"
+DISTRO_FEATURES_FILTER_NATIVESDK ?= "api-documentation debuginfod opencl opengl rust-kernel wayland"
DISTRO_FEATURES_BACKFILL = "pulseaudio sysvinit gobject-introspection-data ldconfig"
MACHINE_FEATURES_BACKFILL = "rtc qemu-usermode"
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 05/16] kernel-yocto: stage rustlib sources for linux-yocto 'make rustavailable' support
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (3 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 04/16] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 15:03 ` Bruce Ashfield
2025-12-27 11:32 ` [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme Harish.Sadineni
` (11 subsequent siblings)
16 siblings, 1 reply; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
When building the Linux kernel with Rust support enabled (e.g., via `make rustavailable`),
the build system expects the Rust standard library sources to be available under:
${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel-yocto.bbclass | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index e53bf15194..2584cadf0d 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -465,6 +465,13 @@ do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_po
do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot"
do_kernel_configme[dirs] += "${S} ${B}"
do_kernel_configme() {
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+ if [ ! -d ${STAGING_LIBDIR_NATIVE}/rustlib/src/rust ]; then
+ mkdir -p ${STAGING_LIBDIR_NATIVE}/rustlib/src/
+ cp -r ${TMPDIR}/work-shared/rust ${STAGING_LIBDIR_NATIVE}/rustlib/src/.
+ fi
+ fi
+
do_kernel_metadata config
# translate the kconfig_mode into something that merge_config.sh
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (4 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 05/16] kernel-yocto: stage rustlib sources for linux-yocto 'make rustavailable' support Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 15:05 ` Bruce Ashfield
2025-12-27 11:32 ` [PATCH 07/16] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
` (10 subsequent siblings)
16 siblings, 1 reply; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
To enable Rust integration in the Linux kernel build, this patch:
- Adds `rust-native`, `clang-native` and `bindgen-cli-native` to `do_kernel_configme[depends]`
to ensure required tools are available for Rust support.
- Invokes `make rustavailable` inside `do_kernel_configme()` to prepare
the kernel for building Rust-based modules or core components.
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel-yocto.bbclass | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index 2584cadf0d..dda235d4d0 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -463,6 +463,11 @@ do_kernel_configme[depends] += "virtual/cross-binutils:do_populate_sysroot"
do_kernel_configme[depends] += "virtual/cross-cc:do_populate_sysroot"
do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot"
do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot"
+RUST_KERNEL_TASK_DEPENDS ?= "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' \
+ rust-native:do_populate_sysroot \
+ clang-native:do_populate_sysroot \
+ bindgen-cli-native:do_populate_sysroot', '', d)}"
+do_kernel_configme[depends] += "${RUST_KERNEL_TASK_DEPENDS}"
do_kernel_configme[dirs] += "${S} ${B}"
do_kernel_configme() {
if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
@@ -513,6 +518,10 @@ do_kernel_configme() {
echo "# Global settings from linux recipe" >> ${B}/.config
echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config
fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+ oe_runmake -C ${S} O=${B} rustavailable
+ fi
}
addtask kernel_configme before do_configure after do_patch
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 07/16] linux-yocto: enable Rust support in kernel configuration
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (5 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 08/16] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
` (9 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
Add initial support for building the Linux kernel with Rust enabled:
- Update `linux-yocto_${PV}.bb` to:
- Append `features/kernel-rust/kernel-rust.scc` to `KERNEL_FEATURES`.
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/recipes-kernel/linux/linux-yocto_6.16.bb | 1 +
meta/recipes-kernel/linux/linux-yocto_6.18.bb | 1 +
2 files changed, 2 insertions(+)
diff --git a/meta/recipes-kernel/linux/linux-yocto_6.16.bb b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
index 408f14b451..e468fdc0d7 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.16.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.16.bb
@@ -77,3 +77,4 @@ 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"
+KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' features/kernel-rust/kernel-rust.scc', '', d)}"
diff --git a/meta/recipes-kernel/linux/linux-yocto_6.18.bb b/meta/recipes-kernel/linux/linux-yocto_6.18.bb
index 562a997020..0b9e5279ee 100644
--- a/meta/recipes-kernel/linux/linux-yocto_6.18.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_6.18.bb
@@ -77,3 +77,4 @@ 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"
+KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' features/kernel-rust/kernel-rust.scc', '', d)}"
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 08/16] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (6 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 07/16] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 09/16] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
` (8 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
Fixes for buildpaths errors after enabling rust for linux-kernel
Co-authored-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel-yocto.bbclass | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index dda235d4d0..c3e1137200 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -4,6 +4,8 @@
# SPDX-License-Identifier: MIT
#
+INHERIT:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' rust-common', '', d)}"
+
# remove tasks that modify the source tree in case externalsrc is inherited
SRCTREECOVEREDTASKS += "do_validate_branches do_kernel_configcheck do_kernel_checkout do_fetch do_unpack do_patch"
PATCH_GIT_USER_EMAIL ?= "kernel-yocto@oe"
@@ -27,6 +29,11 @@ KMETA_AUDIT ?= "yes"
KMETA_AUDIT_WERROR ?= ""
KMETA_CONFIG_FEATURES ?= ""
+RUST_DEBUG_REMAP = "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', '--remap-path-prefix=${WORKDIR}=${TARGET_DBGSRC_DIR} \
+ --remap-path-prefix=${TMPDIR}/work-shared=${TARGET_DBGSRC_DIR}', '',d)}"
+KRUSTFLAGS:append = " ${RUST_DEBUG_REMAP}"
+EXTRA_OEMAKE:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' KRUSTFLAGS="${KRUSTFLAGS}"', '',d)}"
+
# returns local (absolute) path names for all valid patches in the
# src_uri
def find_patches(d,subdir):
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 09/16] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (7 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 08/16] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
` (7 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
Currently, a ccache enabled build fails with:
| HOSTRUSTC scripts/generate_rust_target
| HOSTCC scripts/kallsyms
| HOSTCC scripts/sorttable
| HOSTCC scripts/asn1_compiler
| TOUCH include/generated/gcc-plugins.h
| DESCEND objtool
| error: multiple input filenames provided (first two filenames are gcc and
.../tmp/work-shared/qemux86-64/kernel-source/scripts/generate_rust_target.rs)
when using ccache, value of "HOSTCC=cache gcc" when this value is passing
to rustc, It is thinking gcc is a input file. when ccache is not used "HOSTCC=gcc" is passed.
Disable ccache for kernel build if rust-kernel is enabled to workaround
this.
Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel-yocto.bbclass | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index c3e1137200..43b440e721 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -34,6 +34,11 @@ RUST_DEBUG_REMAP = "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', '--re
KRUSTFLAGS:append = " ${RUST_DEBUG_REMAP}"
EXTRA_OEMAKE:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' KRUSTFLAGS="${KRUSTFLAGS}"', '',d)}"
+# TODO: rust-kernel enabled kernel fails to build with:
+# | error: multiple input filenames provided (first two filenames are gcc and .../tmp/work-shared/qemux86-64/kernel-source/scripts/generate_rust_target.rs)
+# Disable ccache for kernel build if rust-kernel is enabled to workaround this.
+CCACHE_DISABLE ?= "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', '1', '0', d)}"
+
# returns local (absolute) path names for all valid patches in the
# src_uri
def find_patches(d,subdir):
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (8 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 09/16] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 15:09 ` Bruce Ashfield
2025-12-27 11:32 ` [PATCH 11/16] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
` (6 subsequent siblings)
16 siblings, 1 reply; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Harish Sadineni <Harish.Sadineni@windriver.com>
In sdk while running: 'make prepare' in kernel-source directory after enabling rust config,
it will throw errors since only makefile is present in rust kernel sources.
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 23a9093ede..1505a1d70c 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -139,6 +139,10 @@ do_install() {
cd ${S}
cp -a scripts $kerneldir/build
+
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+ cp -a rust ${kerneldir}/build
+ fi
# for v6.1+ (otherwise we are missing multiple default targets)
cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 11/16] selftest/cases/runtime_test: Add test for Linux Rust sample
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (9 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 12/16] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
` (5 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
This new case tests that the rust_mininal sample inside the kernel source
tree is buildable and works properly: check that the module can be
loaded and that it prints correctly.
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/lib/oeqa/selftest/cases/runtime_test.py | 25 ++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index d58ffa80f5..e8374606a4 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -481,3 +481,28 @@ IMAGE_INSTALL:append = " systemtap-runtime"
cmd = "crosstap -r root@192.168.7.2 -s %s/process/ syscalls_by_pid.stp" % systemtap_examples
result = runCmd(cmd)
self.assertEqual(0, result.status, 'crosstap syscalls_by_pid returned a non 0 status:%s' % result.output)
+
+@OETestTag("runqemu")
+class RustKernel(OESelftestTestCase):
+ @classmethod
+ def setUpClass(cls):
+ super(RustKernel, cls).setUpClass()
+ cls.image = "core-image-minimal"
+
+ def test_kernel_rust_sample(self):
+ import textwrap
+ self.write_config(textwrap.dedent("""
+ DISTRO_FEATURES:append = ' rust-kernel'
+ KERNEL_EXTRA_FEATURES:append = ' features/kernel-sample/kernel-rust-sample.scc'
+ CORE_IMAGE_EXTRA_INSTALL += "kernel-module-rust-minimal"
+ """))
+ bitbake(self.image)
+
+ with runqemu(self.image, runqemuparams = "nographic") as qemu:
+ qemu.run_serial("dmesg -c > /dev/null")
+ status, _ = qemu.run_serial("modprobe rust_minimal")
+ self.assertEqual(status, 1, "Loading rust_minimal module failed!")
+ _, output = qemu.run_serial("dmesg")
+ self.logger.debug(f"rust_minimal dmesg output:\n" + textwrap.indent(output, " "))
+ self.assertIn("Rust minimal sample", output, "Kernel Rust sample expected output not found in dmesg")
+
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 12/16] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (10 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 11/16] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 13/16] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
` (4 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
Linux commit aaed5c7739be ("kbuild: slim down package for building
external modules")[0] states that include/config/auto.conf is also a
file needed for out-of-tree build.
This avoids this error when building an out-of-tree Rust kernel module:
| make -C .../tmp/work-shared/qemux86-64/kernel-source M=$PWD
| make[1]: Entering directory '.../tmp/work-shared/qemux86-64/kernel-source'
| make[2]: Entering directory '.../tmp/work/qemux86_64-poky-linux/rust-out-of-tree-module/git/sources/rust-out-of-tree-module-git'
| .../tmp/work-shared/qemux86-64/kernel-source/Makefile:779: .../tmp/work-shared/qemux86-64/kernel-build-artifacts/include/config/auto.conf: No such file or directory
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=aaed5c7739be81ebdd6008aedc8befd98c88e67a
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel.bbclass | 1 +
1 file changed, 1 insertion(+)
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index f989b31c47..30a10b0801 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -570,6 +570,7 @@ do_shared_workdir () {
cp .config $kerneldir/
mkdir -p $kerneldir/include/config
cp include/config/kernel.release $kerneldir/include/config/kernel.release
+ cp include/config/auto.conf $kerneldir/include/config/auto.conf
if [ -e certs/signing_key.x509 ]; then
# The signing_key.* files are stored in the certs/ dir in
# newer Linux kernels
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 13/16] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (11 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 12/16] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 14/16] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
` (3 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
Publish artifacts from kernel compilation to allow out-of-tree Rust
compilation:
* scripts/target.json: target definition: architecture, ABI, compiler
options, ...
* rust/: the crates compiled by the kernel available to
out-of-tree-modules
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/kernel.bbclass | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 30a10b0801..dfb8604a68 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -632,6 +632,24 @@ do_shared_workdir () {
cp -r scripts/gcc-plugins ${kerneldir}/scripts
fi
+ if ${@bb.utils.contains("DISTRO_FEATURES", "rust-kernel", "true", "false", d)}; then
+ # Copy target.json file needed for out-of-tree rust modules
+ if [ -e scripts/target.json ]; then
+ bbnote "Copying scripts/target.json"
+ mkdir -p ${kerneldir}/scripts
+ cp scripts/target.json ${kerneldir}/scripts
+ else
+ bbwarn "scripts/target.json not found in compiled kernel. Out-of-tree rust modules will fail to build."
+ fi
+
+ # Copy rust/ needed by out-of-tree module (firstly for the core rust crate)
+ if [ -e rust/ ]; then
+ bbnote "Copying rust/"
+ cp -r rust ${kerneldir}/
+ else
+ bbwarn "rust/ not found in compiled kernel. Out-of-tree rust modules will fail to build."
+ fi
+ fi
}
# We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 14/16] module.bbclass: Prepare out-of-tree rust module compilation
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (12 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 13/16] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 15/16] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
` (2 subsequent siblings)
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
Conditioned to the "rust-linux" DISTRO_FEATURES:
* Add dependency to rust-native
* Remap ${S} in compiled output to avoid buildpath errors
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/classes-recipe/module.bbclass | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/meta/classes-recipe/module.bbclass b/meta/classes-recipe/module.bbclass
index 4948e995c5..7dbd4194d1 100644
--- a/meta/classes-recipe/module.bbclass
+++ b/meta/classes-recipe/module.bbclass
@@ -87,3 +87,11 @@ EXPORT_FUNCTIONS do_compile do_install
KERNEL_MODULES_META_PACKAGE = "${PN}"
FILES:${PN} = ""
ALLOW_EMPTY:${PN} = "1"
+
+# Rust module support
+DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'rust-native', '', d)}"
+
+RUST_DEBUG_REMAP ?= "--remap-path-prefix=${S}=${TARGET_DBGSRC_DIR}"
+KRUSTFLAGS:append = " ${RUST_DEBUG_REMAP}"
+EXTRA_OEMAKE:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', \
+ ' KRUSTFLAGS="${KRUSTFLAGS}"', '',d)}"
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 15/16] meta-skeleton: Add rust-out-of-tree-module recipe
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (13 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 14/16] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 11:32 ` [PATCH 16/16] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni
2025-12-27 14:59 ` [PATCH 00/16] Enable rust support for linux kernel Bruce Ashfield
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
Basic template for an out-of-tree Linux kernel module written in Rust.
Mainly to test Rust integration into the kernel.
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
.../rust-out-of-tree-module_git.bb | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
diff --git a/meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb b/meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
new file mode 100644
index 0000000000..642fa80319
--- /dev/null
+++ b/meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
@@ -0,0 +1,18 @@
+SUMMARY = "Basic template for an out-of-tree Linux kernel module written in Rust"
+HOMEPAGE = "https://github.com/Rust-for-Linux/rust-out-of-tree-module"
+
+LICENSE = "GPL-2.0-only"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+inherit module features_check
+REQUIRED_DISTRO_FEATURES = "rust-kernel"
+
+SRC_URI = "git://github.com/Rust-for-Linux/rust-out-of-tree-module.git;protocol=https;branch=main"
+SRCREV = "00b5a8ee2bf53532d115004d7636b61a54f49802"
+UPSTREAM_CHECK_COMMITS = "1"
+
+EXTRA_OEMAKE += "KDIR=${STAGING_KERNEL_DIR}"
+
+# The inherit of module.bbclass will automatically name module packages with
+# "kernel-module-" prefix as required by the oe-core build environment.
+RPROVIDES:${PN} += "kernel-module-rust-out-of-tree"
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 16/16] runtime_test: Add rust-out-of-tree selftest
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (14 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 15/16] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
@ 2025-12-27 11:32 ` Harish.Sadineni
2025-12-27 14:59 ` [PATCH 00/16] Enable rust support for linux kernel Bruce Ashfield
16 siblings, 0 replies; 25+ messages in thread
From: Harish.Sadineni @ 2025-12-27 11:32 UTC (permalink / raw)
To: openembedded-core
Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
elmehdi.younes
From: Yoann Congal <yoann.congal@smile.fr>
This new case tests that the rust-out-of-tree-module recipe compiles and
run properly: check that the dmesg output is as expected.
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
meta/lib/oeqa/selftest/cases/runtime_test.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index e8374606a4..461116601d 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -494,8 +494,11 @@ class RustKernel(OESelftestTestCase):
self.write_config(textwrap.dedent("""
DISTRO_FEATURES:append = ' rust-kernel'
KERNEL_EXTRA_FEATURES:append = ' features/kernel-sample/kernel-rust-sample.scc'
- CORE_IMAGE_EXTRA_INSTALL += "kernel-module-rust-minimal"
+ CORE_IMAGE_EXTRA_INSTALL += "kernel-module-rust-minimal kernel-module-rust-out-of-tree"
"""))
+
+ runCmd('bitbake-layers add-layer %s' % os.path.join(get_bb_var("COREBASE"), 'meta-skeleton'))
+ self.add_command_to_tearDown('bitbake-layers remove-layer */meta-skeleton')
bitbake(self.image)
with runqemu(self.image, runqemuparams = "nographic") as qemu:
@@ -506,3 +509,10 @@ class RustKernel(OESelftestTestCase):
self.logger.debug(f"rust_minimal dmesg output:\n" + textwrap.indent(output, " "))
self.assertIn("Rust minimal sample", output, "Kernel Rust sample expected output not found in dmesg")
+ qemu.run_serial("dmesg -c > /dev/null")
+ status, _ = qemu.run_serial("modprobe rust_out_of_tree")
+ self.assertEqual(status, 1, "Loading rust_out_of_tree module failed!")
+ _, output = qemu.run_serial("dmesg")
+ self.logger.debug(f"rust_out_of_tree dmesg output:\n" + textwrap.indent(output, " "))
+ self.assertIn("Rust out-of-tree sample", output, "Out-of-tree Rust sample expected output not found in dmesg")
+
--
2.49.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 00/16] Enable rust support for linux kernel
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
` (15 preceding siblings ...)
2025-12-27 11:32 ` [PATCH 16/16] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni
@ 2025-12-27 14:59 ` Bruce Ashfield
2025-12-29 10:51 ` Harish Sadineni
16 siblings, 1 reply; 25+ messages in thread
From: Bruce Ashfield @ 2025-12-27 14:59 UTC (permalink / raw)
To: Harish.Sadineni
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> This patch series introduces Rust support into the linux-yocto kernel recipe
> and related build infrastructure in the Yocto Project. The goal is to enable
> building the Linux kernel with Rust components and provide support for building
> kernel module which is written in rust and also provide support to build
> rust kernel modules in sdk.
>
> And this series adds test for Linux Rust sample and also added support for out-of-tree kernel
> module written in Rust as well as associated test.
What are the changes in this version compared to the last ?
I didn't get a chance to look at the previous series in detail, but will look
at this one. Knowing what was done in the different iterations is
helpful in guiding what I look at.
Bruce
>
> Summary of patches:
>
> - Patch 01: Extend 'bindgen-cli' to support 'nativesdk', allowing it to be available in the SDK environment.
> - Patch 02: Add required dependencies ('clang-native', 'rust-native', 'bindgen-cli-native') to the kernel to support Rust binding generation.
> - Patch 03: Install the Rust standard library source ('library/') into `work-shared` and which will be later copied to
> linux-yocto recipe-sysroot-native.
> - Patch 04: Added 'rust-kernel' to DISTRO_FEATURES_FILTER_NATIVE and DISTRO_FEATURES_FILTER_NATIVESDK, the 'rust-kernel' feature automatically
> propagates from target DISTRO_FEATURES to native/nativesdk builds
> - Patch 05: Stage the Rust sources into `recipe-sysroot-native` for kernel build compatibility, making them visible during native builds.
> - Patch 06: Update `kernel-yocto.bbclass` to invoke `make rustavailable` during 'do_kernel_configme', ensuring Rust readiness.
> - Patch 07: Add kernel configuration support for Rust (via 'kernel-rust.scc'), enabling the Rust build options in kernel config.
> - Patch 08: Fixed buildpaths errors when rust is enabled for kernel by appending --remap-path-prefix to RUST_DEBUG_REMAP
> - Patch 09: Disabling ccache when rust-kernel is enabled for linux-yocto.
> - Patch 10: Copy Rust kernel sources into kernel-devsrc build directory which will be required while running 'make prepare' in sdk.
> - Patch 11: Added oe-selftest case for the Linux Rust sample.
> - patch 12: Copying include/config/auto.conf in STAGING_KERNEL_BUILDDIR
> - patch 13: Export artifacts needed for out-of-tree Rust compilation
> - patch 14: Prepare out-of-tree rust module compilation
> - patch 15: Added rust-out-of-tree-module recipe in meta-skeleton layer
> - patch 16: Added rust-out-of-tree selftest
>
> Patches have been build-tested successfully on:
> - qemuarm64
> - qemux86-64
>
> Benchmark test-result for x86-64:
> +-------------------------------+------------+-----------+-----------+-----------+
> | DISTRO_FEATURES | real | user | sys | FS usage |
> +-------------------------------+------------+-----------+-----------+-----------+
> | rust-kernel (enabled) | 46m1.720s | 0m28.864s | 0m3.696s | 58 GB |
> | rust-kernel (disabled) | 30m1.053s | 0m20.091s | 0m2.748s | 33 GB |
> +-------------------------------+------------+-----------+-----------+-----------+
>
> The increased in time & fs is due to kernel rust dependencies in
> linux-yocto.
>
>
> Harish Sadineni (9):
> bindgen-cli: extend BBCLASSEXTEND to include nativesdk
> linux-yocto: conditionally add clang/rust/bindgen-cli-native to
> DEPENDS
> rust: install Rust library sources for 'make rustavailable' support
> bitbake.conf: Include "rust-kernel" in native/nativesdk feature
> filters
> kernel-yocto: stage rustlib sources for linux-yocto 'make
> rustavailable' support
> kernel-yocto: add rust support via "make rustavailable" in
> do_kernel_configme
> linux-yocto: enable Rust support in kernel configuration
> kernel-yocto: Fix for buildpaths errors when rust is enabled for
> kernel
> kernel-devsrc: copying rust-kernel source to $kerneldir/build
>
> Yoann Congal (7):
> kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
> selftest/cases/runtime_test: Add test for Linux Rust sample
> kernel.bbclass: Copy include/config/auto.conf in
> STAGING_KERNEL_BUILDDIR
> kernel.bbclass: Export artifacts needed for out-of-tree Rust
> compilation
> module.bbclass: Prepare out-of-tree rust module compilation
> meta-skeleton: Add rust-out-of-tree-module recipe
> runtime_test: Add rust-out-of-tree selftest
>
> .../rust-out-of-tree-module_git.bb | 18 ++++++++++
> meta/classes-recipe/kernel-yocto.bbclass | 28 +++++++++++++++
> meta/classes-recipe/kernel.bbclass | 19 ++++++++++
> meta/classes-recipe/module.bbclass | 8 +++++
> meta/conf/bitbake.conf | 4 +--
> meta/lib/oeqa/selftest/cases/runtime_test.py | 35 +++++++++++++++++++
> .../bindgen-cli/bindgen-cli_0.72.1.bb | 2 +-
> meta/recipes-devtools/rust/rust_1.91.1.bb | 17 +++++++++
> meta/recipes-kernel/linux/kernel-devsrc.bb | 4 +++
> meta/recipes-kernel/linux/linux-yocto.inc | 2 ++
> meta/recipes-kernel/linux/linux-yocto_6.16.bb | 1 +
> meta/recipes-kernel/linux/linux-yocto_6.18.bb | 1 +
> 12 files changed, 136 insertions(+), 3 deletions(-)
> create mode 100644 meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
>
> --
> 2.49.0
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 05/16] kernel-yocto: stage rustlib sources for linux-yocto 'make rustavailable' support
2025-12-27 11:32 ` [PATCH 05/16] kernel-yocto: stage rustlib sources for linux-yocto 'make rustavailable' support Harish.Sadineni
@ 2025-12-27 15:03 ` Bruce Ashfield
0 siblings, 0 replies; 25+ messages in thread
From: Bruce Ashfield @ 2025-12-27 15:03 UTC (permalink / raw)
To: Harish.Sadineni
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> When building the Linux kernel with Rust support enabled (e.g., via `make rustavailable`),
> the build system expects the Rust standard library sources to be available under:
> ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust
>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
> meta/classes-recipe/kernel-yocto.bbclass | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
> index e53bf15194..2584cadf0d 100644
> --- a/meta/classes-recipe/kernel-yocto.bbclass
> +++ b/meta/classes-recipe/kernel-yocto.bbclass
> @@ -465,6 +465,13 @@ do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_po
> do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot"
> do_kernel_configme[dirs] += "${S} ${B}"
> do_kernel_configme() {
> + if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> + if [ ! -d ${STAGING_LIBDIR_NATIVE}/rustlib/src/rust ]; then
> + mkdir -p ${STAGING_LIBDIR_NATIVE}/rustlib/src/
> + cp -r ${TMPDIR}/work-shared/rust ${STAGING_LIBDIR_NATIVE}/rustlib/src/.
> + fi
> + fi
There should be a comment both here, and in the commit message
about why this is done in the configme task. i.e. is it related to
configuration ?
Bruce
> +
> do_kernel_metadata config
>
> # translate the kconfig_mode into something that merge_config.sh
> --
> 2.49.0
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme
2025-12-27 11:32 ` [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme Harish.Sadineni
@ 2025-12-27 15:05 ` Bruce Ashfield
2025-12-29 10:59 ` Harish Sadineni
0 siblings, 1 reply; 25+ messages in thread
From: Bruce Ashfield @ 2025-12-27 15:05 UTC (permalink / raw)
To: Harish.Sadineni
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
And here's the answer to my previous question.
To me, this patch should be squashed with 05/16.
Bruce
On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> To enable Rust integration in the Linux kernel build, this patch:
>
> - Adds `rust-native`, `clang-native` and `bindgen-cli-native` to `do_kernel_configme[depends]`
> to ensure required tools are available for Rust support.
> - Invokes `make rustavailable` inside `do_kernel_configme()` to prepare
> the kernel for building Rust-based modules or core components.
>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
> meta/classes-recipe/kernel-yocto.bbclass | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
> index 2584cadf0d..dda235d4d0 100644
> --- a/meta/classes-recipe/kernel-yocto.bbclass
> +++ b/meta/classes-recipe/kernel-yocto.bbclass
> @@ -463,6 +463,11 @@ do_kernel_configme[depends] += "virtual/cross-binutils:do_populate_sysroot"
> do_kernel_configme[depends] += "virtual/cross-cc:do_populate_sysroot"
> do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot"
> do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot"
> +RUST_KERNEL_TASK_DEPENDS ?= "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' \
> + rust-native:do_populate_sysroot \
> + clang-native:do_populate_sysroot \
> + bindgen-cli-native:do_populate_sysroot', '', d)}"
> +do_kernel_configme[depends] += "${RUST_KERNEL_TASK_DEPENDS}"
> do_kernel_configme[dirs] += "${S} ${B}"
> do_kernel_configme() {
> if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> @@ -513,6 +518,10 @@ do_kernel_configme() {
> echo "# Global settings from linux recipe" >> ${B}/.config
> echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config
> fi
> +
> + if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> + oe_runmake -C ${S} O=${B} rustavailable
> + fi
> }
>
> addtask kernel_configme before do_configure after do_patch
> --
> 2.49.0
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build
2025-12-27 11:32 ` [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
@ 2025-12-27 15:09 ` Bruce Ashfield
2025-12-29 11:25 ` Harish Sadineni
0 siblings, 1 reply; 25+ messages in thread
From: Bruce Ashfield @ 2025-12-27 15:09 UTC (permalink / raw)
To: Harish.Sadineni
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> In sdk while running: 'make prepare' in kernel-source directory after enabling rust config,
> it will throw errors since only makefile is present in rust kernel sources.
Can you show exactly how much of the infrastructure is needed for
make prepare to succeed ? We've gone through a lot of effort over
the years to not copy whole directories, many which have plenty
of source code just like the rust directories do.
If we can just copy the Makefiles and Kbuild files + a few elements
that are needed for regeneration, that is ideal.
Bruce
>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
> meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
> index 23a9093ede..1505a1d70c 100644
> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
> @@ -139,6 +139,10 @@ do_install() {
> cd ${S}
>
> cp -a scripts $kerneldir/build
> +
> + if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> + cp -a rust ${kerneldir}/build
> + fi
>
> # for v6.1+ (otherwise we are missing multiple default targets)
> cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
> --
> 2.49.0
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 00/16] Enable rust support for linux kernel
2025-12-27 14:59 ` [PATCH 00/16] Enable rust support for linux kernel Bruce Ashfield
@ 2025-12-29 10:51 ` Harish Sadineni
0 siblings, 0 replies; 25+ messages in thread
From: Harish Sadineni @ 2025-12-29 10:51 UTC (permalink / raw)
To: Bruce Ashfield
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
On 12/27/2025 8:29 PM, Bruce Ashfield 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 Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>>
>> This patch series introduces Rust support into the linux-yocto kernel recipe
>> and related build infrastructure in the Yocto Project. The goal is to enable
>> building the Linux kernel with Rust components and provide support for building
>> kernel module which is written in rust and also provide support to build
>> rust kernel modules in sdk.
>>
>> And this series adds test for Linux Rust sample and also added support for out-of-tree kernel
>> module written in Rust as well as associated test.
> What are the changes in this version compared to the last ?
>
> I didn't get a chance to look at the previous series in detail, but will look
> at this one. Knowing what was done in the different iterations is
> helpful in guiding what I look at.
The previous series was RFC v4, "Enable Rust support for Linux kernel"
(https://lists.openembedded.org/g/openembedded-core/message/226623).
In addition, Yoann Congal posted RFC v2, "Kernel Rust out-of-tree module
support"
(https://lists.openembedded.org/g/openembedded-core/message/227281),
which builds on top of RFC v4.
The current patch series is a unified version that combines both efforts.
Compared to the earlier series, the main changes are:
*Kernel configuration fragments have been moved to yocto-kernel-cache.
*The kernel fragments have been removed from SRC_URI and from the files
directory previously stored under recipes-kernel/linux/files.
*Updated the "[PATCH 11/16] selftest/cases/runtime_test: Add test for
Linux Rust sample" by appending KERNEL_EXTRA_FEATURES:append = '
features/kernel-sample/kernel-rust-sample.scc' instead of adding this
directly in the linux-yocto recipe.
Thanks,
Harish
>
> Bruce
>
>> Summary of patches:
>>
>> - Patch 01: Extend 'bindgen-cli' to support 'nativesdk', allowing it to be available in the SDK environment.
>> - Patch 02: Add required dependencies ('clang-native', 'rust-native', 'bindgen-cli-native') to the kernel to support Rust binding generation.
>> - Patch 03: Install the Rust standard library source ('library/') into `work-shared` and which will be later copied to
>> linux-yocto recipe-sysroot-native.
>> - Patch 04: Added 'rust-kernel' to DISTRO_FEATURES_FILTER_NATIVE and DISTRO_FEATURES_FILTER_NATIVESDK, the 'rust-kernel' feature automatically
>> propagates from target DISTRO_FEATURES to native/nativesdk builds
>> - Patch 05: Stage the Rust sources into `recipe-sysroot-native` for kernel build compatibility, making them visible during native builds.
>> - Patch 06: Update `kernel-yocto.bbclass` to invoke `make rustavailable` during 'do_kernel_configme', ensuring Rust readiness.
>> - Patch 07: Add kernel configuration support for Rust (via 'kernel-rust.scc'), enabling the Rust build options in kernel config.
>> - Patch 08: Fixed buildpaths errors when rust is enabled for kernel by appending --remap-path-prefix to RUST_DEBUG_REMAP
>> - Patch 09: Disabling ccache when rust-kernel is enabled for linux-yocto.
>> - Patch 10: Copy Rust kernel sources into kernel-devsrc build directory which will be required while running 'make prepare' in sdk.
>> - Patch 11: Added oe-selftest case for the Linux Rust sample.
>> - patch 12: Copying include/config/auto.conf in STAGING_KERNEL_BUILDDIR
>> - patch 13: Export artifacts needed for out-of-tree Rust compilation
>> - patch 14: Prepare out-of-tree rust module compilation
>> - patch 15: Added rust-out-of-tree-module recipe in meta-skeleton layer
>> - patch 16: Added rust-out-of-tree selftest
>>
>> Patches have been build-tested successfully on:
>> - qemuarm64
>> - qemux86-64
>>
>> Benchmark test-result for x86-64:
>> +-------------------------------+------------+-----------+-----------+-----------+
>> | DISTRO_FEATURES | real | user | sys | FS usage |
>> +-------------------------------+------------+-----------+-----------+-----------+
>> | rust-kernel (enabled) | 46m1.720s | 0m28.864s | 0m3.696s | 58 GB |
>> | rust-kernel (disabled) | 30m1.053s | 0m20.091s | 0m2.748s | 33 GB |
>> +-------------------------------+------------+-----------+-----------+-----------+
>>
>> The increased in time & fs is due to kernel rust dependencies in
>> linux-yocto.
>>
>>
>> Harish Sadineni (9):
>> bindgen-cli: extend BBCLASSEXTEND to include nativesdk
>> linux-yocto: conditionally add clang/rust/bindgen-cli-native to
>> DEPENDS
>> rust: install Rust library sources for 'make rustavailable' support
>> bitbake.conf: Include "rust-kernel" in native/nativesdk feature
>> filters
>> kernel-yocto: stage rustlib sources for linux-yocto 'make
>> rustavailable' support
>> kernel-yocto: add rust support via "make rustavailable" in
>> do_kernel_configme
>> linux-yocto: enable Rust support in kernel configuration
>> kernel-yocto: Fix for buildpaths errors when rust is enabled for
>> kernel
>> kernel-devsrc: copying rust-kernel source to $kerneldir/build
>>
>> Yoann Congal (7):
>> kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
>> selftest/cases/runtime_test: Add test for Linux Rust sample
>> kernel.bbclass: Copy include/config/auto.conf in
>> STAGING_KERNEL_BUILDDIR
>> kernel.bbclass: Export artifacts needed for out-of-tree Rust
>> compilation
>> module.bbclass: Prepare out-of-tree rust module compilation
>> meta-skeleton: Add rust-out-of-tree-module recipe
>> runtime_test: Add rust-out-of-tree selftest
>>
>> .../rust-out-of-tree-module_git.bb | 18 ++++++++++
>> meta/classes-recipe/kernel-yocto.bbclass | 28 +++++++++++++++
>> meta/classes-recipe/kernel.bbclass | 19 ++++++++++
>> meta/classes-recipe/module.bbclass | 8 +++++
>> meta/conf/bitbake.conf | 4 +--
>> meta/lib/oeqa/selftest/cases/runtime_test.py | 35 +++++++++++++++++++
>> .../bindgen-cli/bindgen-cli_0.72.1.bb | 2 +-
>> meta/recipes-devtools/rust/rust_1.91.1.bb | 17 +++++++++
>> meta/recipes-kernel/linux/kernel-devsrc.bb | 4 +++
>> meta/recipes-kernel/linux/linux-yocto.inc | 2 ++
>> meta/recipes-kernel/linux/linux-yocto_6.16.bb | 1 +
>> meta/recipes-kernel/linux/linux-yocto_6.18.bb | 1 +
>> 12 files changed, 136 insertions(+), 3 deletions(-)
>> create mode 100644 meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
>>
>> --
>> 2.49.0
>>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme
2025-12-27 15:05 ` Bruce Ashfield
@ 2025-12-29 10:59 ` Harish Sadineni
0 siblings, 0 replies; 25+ messages in thread
From: Harish Sadineni @ 2025-12-29 10:59 UTC (permalink / raw)
To: Bruce Ashfield
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
On 12/27/2025 8:35 PM, Bruce Ashfield 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.
>
> And here's the answer to my previous question.
>
> To me, this patch should be squashed with 05/16.
OK Bruce, I’ll combine this patch with 05/16 and send it as v2.
Thanks,
Harish
>
> Bruce
>
> On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>>
>> To enable Rust integration in the Linux kernel build, this patch:
>>
>> - Adds `rust-native`, `clang-native` and `bindgen-cli-native` to `do_kernel_configme[depends]`
>> to ensure required tools are available for Rust support.
>> - Invokes `make rustavailable` inside `do_kernel_configme()` to prepare
>> the kernel for building Rust-based modules or core components.
>>
>> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
>> ---
>> meta/classes-recipe/kernel-yocto.bbclass | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
>> index 2584cadf0d..dda235d4d0 100644
>> --- a/meta/classes-recipe/kernel-yocto.bbclass
>> +++ b/meta/classes-recipe/kernel-yocto.bbclass
>> @@ -463,6 +463,11 @@ do_kernel_configme[depends] += "virtual/cross-binutils:do_populate_sysroot"
>> do_kernel_configme[depends] += "virtual/cross-cc:do_populate_sysroot"
>> do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot"
>> do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot"
>> +RUST_KERNEL_TASK_DEPENDS ?= "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' \
>> + rust-native:do_populate_sysroot \
>> + clang-native:do_populate_sysroot \
>> + bindgen-cli-native:do_populate_sysroot', '', d)}"
>> +do_kernel_configme[depends] += "${RUST_KERNEL_TASK_DEPENDS}"
>> do_kernel_configme[dirs] += "${S} ${B}"
>> do_kernel_configme() {
>> if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
>> @@ -513,6 +518,10 @@ do_kernel_configme() {
>> echo "# Global settings from linux recipe" >> ${B}/.config
>> echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config
>> fi
>> +
>> + if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
>> + oe_runmake -C ${S} O=${B} rustavailable
>> + fi
>> }
>>
>> addtask kernel_configme before do_configure after do_patch
>> --
>> 2.49.0
>>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build
2025-12-27 15:09 ` Bruce Ashfield
@ 2025-12-29 11:25 ` Harish Sadineni
2025-12-29 12:49 ` Bruce Ashfield
0 siblings, 1 reply; 25+ messages in thread
From: Harish Sadineni @ 2025-12-29 11:25 UTC (permalink / raw)
To: Bruce Ashfield
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
On 12/27/2025 8:39 PM, Bruce Ashfield 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 Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>>
>> In sdk while running: 'make prepare' in kernel-source directory after enabling rust config,
>> it will throw errors since only makefile is present in rust kernel sources.
> Can you show exactly how much of the infrastructure is needed for
> make prepare to succeed ? We've gone through a lot of effort over
> the years to not copy whole directories, many which have plenty
> of source code just like the rust directories do.
>
> If we can just copy the Makefiles and Kbuild files + a few elements
> that are needed for regeneration, that is ideal.
Without this patch:
After populating the SDK and sourcing the environment, in the kernel
source directory I run 'make rustavailable', then 'make scripts',
and enable Rust support (RUST) in the kernel configuration. When running
'make prepare', the build fails.
The failure is due to missing Rust infrastructure. To understand the
minimum required set, I attempted to add files incrementally based on
the reported errors.
This resulted in the following dependency chain:
Initial failure during make prepare:
RUSTC L rust/core.o
EXPORTS rust/exports_core_generated.h
make[2]: *** No rule to make target 'rust/bindings/bindings_helper.h',
needed by 'rust/bindings/bindings_generated.rs'. Stop.
After adding rust/bindings/bindings_helper.h:
make[2]: *** No rule to make target 'rust/bindgen_parameters',
needed by 'rust/bindings/bindings_generated.rs'. Stop.
After adding rust/bindgen_parameters:
BINDGEN rust/bindings/bindings_generated.rs
make[2]: *** No rule to make target 'rust/helpers/helpers.c',
needed by 'rust/bindings/bindings_helpers_generated.rs'. Stop.
After adding rust/helpers/helpers.c, bindgen fails due to additional C
source dependencies:
rust/helpers/helpers.c:10:10: fatal error: 'auxiliary.c' file not found
rust/helpers/helpers.c:11:10: fatal error: 'blk.c' file not found
At this point, it becomes apparent that make prepare continues to pull
in further Rust and C source dependencies(chain of dependency is very
large),
and in practice ends up requiring most of the Rust infrastructure rather
than just a small set of Makefiles or files.
After applying this patch total size of rust directory is 1.8MB.
> Bruce
>
>> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
>> ---
>> meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
>> index 23a9093ede..1505a1d70c 100644
>> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
>> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
>> @@ -139,6 +139,10 @@ do_install() {
>> cd ${S}
>>
>> cp -a scripts $kerneldir/build
>> +
>> + if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
>> + cp -a rust ${kerneldir}/build
>> + fi
>>
>> # for v6.1+ (otherwise we are missing multiple default targets)
>> cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
>> --
>> 2.49.0
>>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build
2025-12-29 11:25 ` Harish Sadineni
@ 2025-12-29 12:49 ` Bruce Ashfield
0 siblings, 0 replies; 25+ messages in thread
From: Bruce Ashfield @ 2025-12-29 12:49 UTC (permalink / raw)
To: Harish Sadineni
Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda, yoann.congal,
elmehdi.younes
[-- Attachment #1: Type: text/plain, Size: 4513 bytes --]
On Mon, Dec 29, 2025 at 7:25 AM Harish Sadineni <
Harish.Sadineni@windriver.com> wrote:
>
> On 12/27/2025 8:39 PM, Bruce Ashfield 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 Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
> >> From: Harish Sadineni <Harish.Sadineni@windriver.com>
> >>
> >> In sdk while running: 'make prepare' in kernel-source directory after
> enabling rust config,
> >> it will throw errors since only makefile is present in rust kernel
> sources.
> > Can you show exactly how much of the infrastructure is needed for
> > make prepare to succeed ? We've gone through a lot of effort over
> > the years to not copy whole directories, many which have plenty
> > of source code just like the rust directories do.
> >
> > If we can just copy the Makefiles and Kbuild files + a few elements
> > that are needed for regeneration, that is ideal.
> Without this patch:
>
> After populating the SDK and sourcing the environment, in the kernel
> source directory I run 'make rustavailable', then 'make scripts',
> and enable Rust support (RUST) in the kernel configuration. When running
> 'make prepare', the build fails.
>
> The failure is due to missing Rust infrastructure. To understand the
> minimum required set, I attempted to add files incrementally based on
> the reported errors.
> This resulted in the following dependency chain:
>
> Initial failure during make prepare:
>
> RUSTC L rust/core.o
> EXPORTS rust/exports_core_generated.h
> make[2]: *** No rule to make target 'rust/bindings/bindings_helper.h',
> needed by 'rust/bindings/bindings_generated.rs'. Stop.
>
> After adding rust/bindings/bindings_helper.h:
>
> make[2]: *** No rule to make target 'rust/bindgen_parameters',
> needed by 'rust/bindings/bindings_generated.rs'. Stop.
>
> After adding rust/bindgen_parameters:
>
> BINDGEN rust/bindings/bindings_generated.rs
> make[2]: *** No rule to make target 'rust/helpers/helpers.c',
> needed by 'rust/bindings/bindings_helpers_generated.rs'. Stop.
>
> After adding rust/helpers/helpers.c, bindgen fails due to additional C
> source dependencies:
>
> rust/helpers/helpers.c:10:10: fatal error: 'auxiliary.c' file not found
> rust/helpers/helpers.c:11:10: fatal error: 'blk.c' file not found
>
>
Right. This is what I've had to do for the other subsystems and so
far we've mostly avoided large copies.
>
> At this point, it becomes apparent that make prepare continues to pull
> in further Rust and C source dependencies(chain of dependency is very
> large),
> and in practice ends up requiring most of the Rust infrastructure rather
> than just a small set of Makefiles or files.
>
> After applying this patch total size of rust directory is 1.8MB.
>
If we are making such a relatively large addition, both the commit
message and above the copy in the code .. explain in detail what
the rust directory does / generates during make prepare and what
it provides that a kernel module build requires.
Cheers,
Bruce
> > Bruce
> >
> >> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> >> ---
> >> meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
> >> 1 file changed, 4 insertions(+)
> >>
> >> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb
> b/meta/recipes-kernel/linux/kernel-devsrc.bb
> >> index 23a9093ede..1505a1d70c 100644
> >> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
> >> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
> >> @@ -139,6 +139,10 @@ do_install() {
> >> cd ${S}
> >>
> >> cp -a scripts $kerneldir/build
> >> +
> >> + if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel',
> 'true', 'false', d)}; then
> >> + cp -a rust ${kerneldir}/build
> >> + fi
> >>
> >> # for v6.1+ (otherwise we are missing multiple default
> targets)
> >> cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
> >> --
> >> 2.49.0
> >>
> >
> > --
> > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > thee at its end
> > - "Use the force Harry" - Gandalf, Star Trek II
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
[-- Attachment #2: Type: text/html, Size: 7473 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2025-12-29 12:49 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-27 11:32 [PATCH 00/16] Enable rust support for linux kernel Harish.Sadineni
2025-12-27 11:32 ` [PATCH 01/16] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
2025-12-27 11:32 ` [PATCH 02/16] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
2025-12-27 11:32 ` [PATCH 03/16] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
2025-12-27 11:32 ` [PATCH 04/16] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
2025-12-27 11:32 ` [PATCH 05/16] kernel-yocto: stage rustlib sources for linux-yocto 'make rustavailable' support Harish.Sadineni
2025-12-27 15:03 ` Bruce Ashfield
2025-12-27 11:32 ` [PATCH 06/16] kernel-yocto: add rust support via "make rustavailable" in do_kernel_configme Harish.Sadineni
2025-12-27 15:05 ` Bruce Ashfield
2025-12-29 10:59 ` Harish Sadineni
2025-12-27 11:32 ` [PATCH 07/16] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
2025-12-27 11:32 ` [PATCH 08/16] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
2025-12-27 11:32 ` [PATCH 09/16] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
2025-12-27 11:32 ` [PATCH 10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
2025-12-27 15:09 ` Bruce Ashfield
2025-12-29 11:25 ` Harish Sadineni
2025-12-29 12:49 ` Bruce Ashfield
2025-12-27 11:32 ` [PATCH 11/16] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
2025-12-27 11:32 ` [PATCH 12/16] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
2025-12-27 11:32 ` [PATCH 13/16] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
2025-12-27 11:32 ` [PATCH 14/16] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
2025-12-27 11:32 ` [PATCH 15/16] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
2025-12-27 11:32 ` [PATCH 16/16] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni
2025-12-27 14:59 ` [PATCH 00/16] Enable rust support for linux kernel Bruce Ashfield
2025-12-29 10:51 ` Harish Sadineni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox