public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v2 00/15] Enable rust support for linux kernel
@ 2025-12-30 14:15 Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
                   ` (14 more replies)
  0 siblings, 15 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 UTC (permalink / raw)
  To: openembedded-core
  Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
	elmehdi.younes

From: Harish Sadineni <Harish.Sadineni@windriver.com>

v2:
- combined [PATCH 05/16][0] & [PATCH 06/16][1] from v1.
- updated commit message and added in code comments for patch "[PATCH 09/15] kernel-devsrc: copying 
  rust-kernel source to $kerneldir/build"

[0] https://lists.openembedded.org/g/openembedded-core/message/228559
[1] https://lists.openembedded.org/g/openembedded-core/message/228560

v1:
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.


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
            and Updated `kernel-yocto.bbclass` to invoke `make rustavailable` during 'do_kernel_configme', ensuring Rust readiness.
- Patch 06: Add kernel configuration support for Rust (via 'kernel-rust.scc'), enabling the Rust build options in kernel config.
- Patch 07: Fixed buildpaths errors when rust is enabled for kernel by appending --remap-path-prefix to RUST_DEBUG_REMAP
- Patch 08: Disabling ccache when rust-kernel is enabled for linux-yocto.
- Patch 09: Copy Rust kernel sources into kernel-devsrc build directory which will be required while running 'make prepare' in sdk.
- Patch 10: Added oe-selftest case for the Linux Rust sample.
- patch 11: Copying include/config/auto.conf in STAGING_KERNEL_BUILDDIR
- patch 12: Export artifacts needed for out-of-tree Rust compilation
- patch 13: Prepare out-of-tree rust module compilation
- patch 14: Added rust-out-of-tree-module recipe in meta-skeleton layer
- patch 15: 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 (8):
  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: enable Rust kernel support via rustavailable and staged
    rustlib sources
  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    |  9 +++++
 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, 141 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] 29+ messages in thread

* [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2026-01-12  0:10   ` [OE-core] " Alistair Francis
  2025-12-30 14:15 ` [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2026-01-12  0:12   ` [OE-core] " Alistair Francis
  2025-12-30 14:15 ` [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 15:58   ` [OE-core] " Richard Purdie
  2025-12-30 14:15 ` [PATCH v2 04/15] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 04/15] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (2 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 05/15] kernel-yocto: enable Rust kernel support via rustavailable and staged rustlib sources Harish.Sadineni
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 05/15] kernel-yocto: enable Rust kernel support via rustavailable and staged rustlib sources
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (3 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 04/15] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 06/15] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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 (DISTRO_FEATURES += "rust-kernel"),
additional preparation steps are required for the kernel configuration phase.

The kernel Rust build system expects the Rust standard library sources to be
available under:

${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust

These sources are required by make rustavailable, which prepares the kernel
tree for Rust integration by validating the toolchain, generating bindings,
and setting up Rust-specific infrastructure needed for building Rust kernel
components and modules.

This change adds support for Rust-enabled kernel builds by:

-Staging the Rust standard library sources into the native sysroot when
 rust-kernel is enabled.

-Extending do_kernel_configme dependencies to include rust-native,
 clang-native, and bindgen-cli-native.

-Invoking make rustavailable during do_kernel_configme() to prepare the
 kernel build environment for Rust.

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/classes-recipe/kernel-yocto.bbclass | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index e53bf15194..dda235d4d0 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -463,8 +463,20 @@ 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
+		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
@@ -506,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] 29+ messages in thread

* [PATCH v2 06/15] linux-yocto: enable Rust support in kernel configuration
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (4 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 05/15] kernel-yocto: enable Rust kernel support via rustavailable and staged rustlib sources Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 07/15] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 07/15] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (5 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 06/15] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (6 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 07/15] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2026-01-14 15:41   ` alban.moizan
  2025-12-30 14:15 ` [PATCH v2 09/15] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 09/15] kernel-devsrc: copying rust-kernel source to $kerneldir/build
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (7 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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 CONFIG_RUST is enabled, running 'make prepare' in the SDK fails
because the Rust kernel infrastructure is incomplete in the staged
kernel sources.

The Rust build system requires a wider set of interdependent sources
during make prepare, including bindgen inputs, C helper sources,
generated headers, and other support files. These are all located under
the kernel rust/ directory.

To ensure make prepare succeeds and to support building Rust-based
kernel modules from the SDK, copy the full rust/ directory into
$kerneldir/build when the rust-kernel distro feature is enabled.

Additionally, when Rust support is enabled, 'make prepare' generates
.rmeta files (crate metadata in a custom binary format) and shared
objects (.so) that are required for compiling Rust kernel modules.

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 23a9093ede..485e671962 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -139,6 +139,15 @@ do_install() {
         cd ${S}
 
         cp -a scripts $kerneldir/build
+        
+        # In sdk, when CONFIG_RUST is enabled, `make prepare` requires the full Rust
+        # kernel infrastructure. The Rust build system pulls in bindgen inputs, C helpers,
+        # generated headers, and generate crate metadata (.rmeta), and shared objects 
+        # needed for building Rust kernel modules. Copy the entire rust/ directory to avoid
+        # failures with 'make prepare'.
+        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] 29+ messages in thread

* [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (8 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 09/15] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2026-01-05  9:32   ` [OE-core] " Mathieu Dubois-Briand
  2025-12-30 14:15 ` [PATCH v2 11/15] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 11/15] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (9 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 12/15] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 12/15] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (10 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 11/15] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 13/15] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 13/15] module.bbclass: Prepare out-of-tree rust module compilation
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (11 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 12/15] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 14/15] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 15/15] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 14/15] meta-skeleton: Add rust-out-of-tree-module recipe
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (12 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 13/15] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  2025-12-30 14:15 ` [PATCH v2 15/15] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* [PATCH v2 15/15] runtime_test: Add rust-out-of-tree selftest
  2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
                   ` (13 preceding siblings ...)
  2025-12-30 14:15 ` [PATCH v2 14/15] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
@ 2025-12-30 14:15 ` Harish.Sadineni
  14 siblings, 0 replies; 29+ messages in thread
From: Harish.Sadineni @ 2025-12-30 14:15 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] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2025-12-30 14:15 ` [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
@ 2025-12-30 15:58   ` Richard Purdie
  2026-01-05 16:24     ` Harish Sadineni
  0 siblings, 1 reply; 29+ messages in thread
From: Richard Purdie @ 2025-12-30 15:58 UTC (permalink / raw)
  To: Harish.Sadineni, openembedded-core
  Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
	elmehdi.younes

On Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via lists.openembedded.org wrote:
> 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"

The commit message should mention the size of these files. Does this
make sense as a distro feature or should we just do this all the time?
Do the nativesdk components get packaged separately? If they were, we
could then make that an SDK feature instead. What happens for on target
kernel module development? Shouldn't there be a target package too?

Cheers,

Richard


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample
  2025-12-30 14:15 ` [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
@ 2026-01-05  9:32   ` Mathieu Dubois-Briand
  2026-01-08  9:39     ` Yoann Congal
  0 siblings, 1 reply; 29+ messages in thread
From: Mathieu Dubois-Briand @ 2026-01-05  9:32 UTC (permalink / raw)
  To: Harish.Sadineni, openembedded-core
  Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
	elmehdi.younes

On Tue Dec 30, 2025 at 3:15 PM CET, Harish via lists.openembedded.org Sadineni wrote:
> 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>
> ---

Hi Yoann, Harish,

Thanks for your patch.

It looks like we got a few intermittent failures here:

2026-01-02 19:40:58,816 - oe-selftest - INFO - FAIL: runtime_test.RustKernel.test_kernel_rust_sample (subunit.RemotedTestCase)
2026-01-02 19:40:58,816 - oe-selftest - INFO - ----------------------------------------------------------------------
2026-01-02 19:40:58,816 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/runtime_test.py", line 514, in test_kernel_rust_sample
    self.assertEqual(status, 1, "Loading rust_out_of_tree module failed!")
  File "/usr/lib/python3.10/unittest/case.py", line 845, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python3.10/unittest/case.py", line 838, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: 0 != 1 : Loading rust_out_of_tree module failed!

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3082
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3095

I only saw two occurrences so far, on at least 10 builds, but maybe you
can check for obvious reasons before the series get merged.

Thanks,
Mathieu

-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2025-12-30 15:58   ` [OE-core] " Richard Purdie
@ 2026-01-05 16:24     ` Harish Sadineni
  2026-01-06 18:59       ` Randy MacLeod
  0 siblings, 1 reply; 29+ messages in thread
From: Harish Sadineni @ 2026-01-05 16:24 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core
  Cc: Randy.MacLeod, Sundeep.Kokkonda, bruce.ashfield, yoann.congal,
	elmehdi.younes


On 12/30/2025 9:28 PM, Richard Purdie 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 Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via lists.openembedded.org wrote:
>> 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"
> The commit message should mention the size of these files.
Ok sure, I will add file size in v3.
> Does this make sense as a distro feature or should we just do this all the time?
This is suggestion from Bruce that we take it as distro feature.
https://lists.openembedded.org/g/openembedded-core/message/225256

In future when rust is default in kernel we can change this, But till 
then it is good to have it as a distro feature.
> Do the nativesdk components get packaged separately? If they were, we
> could then make that an SDK feature instead.
No, We are not packaging it separately.
> What happens for on target kernel module development? Shouldn't there be a target package too?
Yes, I have made the necessary changes to include Rust library for 
target as well and have tested Rust-based kernel module development on 
the target.
I will send updated patches with v3.

Thanks,
Harish
> Cheers,
>
> Richard


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2026-01-05 16:24     ` Harish Sadineni
@ 2026-01-06 18:59       ` Randy MacLeod
  2026-01-07 16:34         ` Harish Sadineni
  0 siblings, 1 reply; 29+ messages in thread
From: Randy MacLeod @ 2026-01-06 18:59 UTC (permalink / raw)
  To: Harish Sadineni
  Cc: Sundeep.Kokkonda, bruce.ashfield, yoann.congal, elmehdi.younes,
	Richard Purdie, Bruce Ashfield, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 5993 bytes --]

On 2026-01-05 11:24 a.m., Harish Sadineni wrote:
>
> On 12/30/2025 9:28 PM, Richard Purdie 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 Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via 
>> lists.openembedded.org wrote:
>>> 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"
>> The commit message should mention the size of these files.
> Ok sure, I will add file size in v3.
>> Does this make sense as a distro feature or should we just do this 
>> all the time?
> This is suggestion from Bruce that we take it as distro feature.
> https://lists.openembedded.org/g/openembedded-core/message/225256


Richard mentioned this thread in today's tech call when I asked for 
commentson the rust-kernel PR.

Yes, the high level requirement is to have a DISTRO_FEATURE  but common, 
infrastructure parts
such as this code that just copies a hopefully small number of files around,
and is part of the rust recipe, could and likely be done regardless of 
the rust-kernel DISTRO_FEATURE.

We don't want the rust recipe to change based on a kernel config unless 
we *really* have to
since that essentially doubles the testing that should be done or leaves 
a gap in testing of the
rust builds. If you do that for the kernel first, then another recipe 
later, soon you have a maintenance mess.

Also if the kernel needs these files, then it's likely that other 
software will need it as well.
You should analyze why the kernel needs these files and why other 
recipes do not. Perhaps any
kernel-like image will have the same requirement. Is there a baremetal 
image  using rust anywhere
that you can use to check on that? I looked but all I found was:
https://github.com/ahcbb6/baremetal-helloqemu-rust
Anyway, let's focus on the linux kernel's requirements for now.


So, how many files are needed and how much FS space do they use?

What are other build systems (gentoo for example) doing with their Rust 
builds to satisfy the kernel's rust requirements?

>
> In future when rust is default in kernel we can change this, But till 
> then it is good to have it as a distro feature.
>> Do the nativesdk components get packaged separately? If they were, we
>> could then make that an SDK feature instead.
> No, We are not packaging it separately.


The questions seems to be whether we should create a separate packaging 
rule.

>> What happens for on target kernel module development? Shouldn't there 
>> be a target package too?
> Yes, I have made the necessary changes to include Rust library for 
> target as well and have tested Rust-based kernel module development on 
> the target.
> I will send updated patches with v3.


Before you spend time on polishing v3 please explain what your workflow 
is, step by step,
so we can be sure that things makes sense from a high level.

../Randy


>
> Thanks,
> Harish
>> Cheers,
>>
>> Richard


-- 
# Randy MacLeod
# Wind River Linux

[-- Attachment #2: Type: text/html, Size: 10044 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2026-01-06 18:59       ` Randy MacLeod
@ 2026-01-07 16:34         ` Harish Sadineni
  2026-01-07 18:21           ` Randy MacLeod
  0 siblings, 1 reply; 29+ messages in thread
From: Harish Sadineni @ 2026-01-07 16:34 UTC (permalink / raw)
  To: Randy MacLeod, Richard Purdie
  Cc: Sundeep.Kokkonda, bruce.ashfield, yoann.congal, elmehdi.younes,
	openembedded-core


On 1/7/2026 12:29 AM, Randy MacLeod wrote:
> On 2026-01-05 11:24 a.m., Harish Sadineni wrote:
>>
>> On 12/30/2025 9:28 PM, Richard Purdie 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 Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via 
>>> lists.openembedded.org wrote:
>>>> 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"
>>> The commit message should mention the size of these files.
>> Ok sure, I will add file size in v3.
>>> Does this make sense as a distro feature or should we just do this 
>>> all the time?
>> This is suggestion from Bruce that we take it as distro feature.
>> https://lists.openembedded.org/g/openembedded-core/message/225256
>
>
> Richard mentioned this thread in today's tech call when I asked for 
> commentson the rust-kernel PR.
>
> Yes, the high level requirement is to have a DISTRO_FEATURE but 
> common, infrastructure parts
> such as this code that just copies a hopefully small number of files 
> around,
> and is part of the rust recipe, could and likely be done regardless of 
> the rust-kernel DISTRO_FEATURE.
>

Ok sure, We will remove the dependency on DISTRO_FEATURE  for copying 
the library directory from rust recipe.
>
>
> We don't want the rust recipe to change based on a kernel config 
> unless we *really* have to
> since that essentially doubles the testing that should be done or 
> leaves a gap in testing of the
> rust builds. If you do that for the kernel first, then another recipe 
> later, soon you have a maintenance mess.
>
> Also if the kernel needs these files, then it's likely that other 
> software will need it as well.
> You should analyze why the kernel needs these files and why other 
> recipes do not. Perhaps any
> kernel-like image will have the same requirement. Is there a baremetal 
> image  using rust anywhere
> that you can use to check on that? I looked but all I found was:
> https://github.com/ahcbb6/baremetal-helloqemu-rust
> Anyway, let's focus on the linux kernel's requirements for now.
>
>
> So, how many files are needed and how much FS space do they use?
>

The file size of the library directory is around 50MB.
>
>
> What are other build systems (gentoo for example) doing with their 
> Rust builds to satisfy the kernel's rust requirements?
>

I will check and update on this.
>
>
>>
>> In future when rust is default in kernel we can change this, But till 
>> then it is good to have it as a distro feature.
>>> Do the nativesdk components get packaged separately? If they were, we
>>> could then make that an SDK feature instead.
>> No, We are not packaging it separately.
>
>
> The questions seems to be whether we should create a separate 
> packaging rule.
>

Now by default it is getting packaged with nativesdk-rust, Do we need a 
separate packaging for libraries/files that being installed for rust in 
kernel support?
>
>
>>> What happens for on target kernel module development? Shouldn't 
>>> there be a target package too?
>> Yes, I have made the necessary changes to include Rust library for 
>> target as well and have tested Rust-based kernel module development 
>> on the target.
>> I will send updated patches with v3.
>
>
> Before you spend time on polishing v3 please explain what your 
> workflow is, step by step,
> so we can be sure that things makes sense from a high level.
>
We will update the rust recipe to copy the required libs to target image 
and then the below steps to be followed :
- Build the image by adding the required tools via IMAGE_INSTALL:append 
( e.g kernel-devsrc, gcc, rust, cargo, bindgen-cli etc..).
- In /usr/src/kernel, run "make rustavailable" to verify Rust support 
(This step will check all supporting tools are available for rust 
support in kernel).
- Run "make menuconfig" and enable "CONFIG_RUST".
- Run "make scripts" and "make prepare".
- Write a kernel module in Rust & build the module using "make", which 
generates the "module_name.ko" file.
- Load the module using "insmod module_name.ko".

Thanks,
Harish

> ../Randy
>
>
>>
>> Thanks,
>> Harish
>>> Cheers,
>>>
>>> Richard
>
>
> -- 
> # Randy MacLeod
> # Wind River Linux


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2026-01-07 16:34         ` Harish Sadineni
@ 2026-01-07 18:21           ` Randy MacLeod
  2026-01-07 19:03             ` Richard Purdie
  2026-01-12  0:42             ` Alistair Francis
  0 siblings, 2 replies; 29+ messages in thread
From: Randy MacLeod @ 2026-01-07 18:21 UTC (permalink / raw)
  To: Harish Sadineni, Richard Purdie, bruce.ashfield
  Cc: Sundeep.Kokkonda, yoann.congal, elmehdi.younes, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 8404 bytes --]

On 2026-01-07 11:34 a.m., Harish Sadineni wrote:
>
> On 1/7/2026 12:29 AM, Randy MacLeod wrote:
>> On 2026-01-05 11:24 a.m., Harish Sadineni wrote:
>>>
>>> On 12/30/2025 9:28 PM, Richard Purdie 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 Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via 
>>>> lists.openembedded.org wrote:
>>>>> 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"
>>>> The commit message should mention the size of these files.
>>> Ok sure, I will add file size in v3.
>>>> Does this make sense as a distro feature or should we just do this 
>>>> all the time?
>>> This is suggestion from Bruce that we take it as distro feature.
>>> https://lists.openembedded.org/g/openembedded-core/message/225256
>>
>>
>> Richard mentioned this thread in today's tech call when I asked for 
>> commentson the rust-kernel PR.
>>
>> Yes, the high level requirement is to have a DISTRO_FEATURE but 
>> common, infrastructure parts
>> such as this code that just copies a hopefully small number of files 
>> around,
>> and is part of the rust recipe, could and likely be done regardless 
>> of the rust-kernel DISTRO_FEATURE.
>>
>
> Ok sure, We will remove the dependency on DISTRO_FEATURE  for copying 
> the library directory from rust recipe.


Hold on, I said "small number of files...". See below.

>>
>>
>> We don't want the rust recipe to change based on a kernel config 
>> unless we *really* have to
>> since that essentially doubles the testing that should be done or 
>> leaves a gap in testing of the
>> rust builds. If you do that for the kernel first, then another recipe 
>> later, soon you have a maintenance mess.
>>
>> Also if the kernel needs these files, then it's likely that other 
>> software will need it as well.
>> You should analyze why the kernel needs these files and why other 
>> recipes do not. Perhaps any
>> kernel-like image will have the same requirement. Is there a 
>> baremetal image  using rust anywhere
>> that you can use to check on that? I looked but all I found was:
>> https://github.com/ahcbb6/baremetal-helloqemu-rust
>> Anyway, let's focus on the linux kernel's requirements for now.
>>
>>
>> So, how many files are needed and how much FS space do they use?
>>
>
> The file size of the library directory is around 50MB.
>
>
I've been around since the 1990s, 50 MB doesn't seem small to me but
let's see what other people think.

Also, how may files is that?

What's the content?  ls -lR if the list isn't too long.

Does the kernel build need each and every file ? How did you check?
Can we automate the generation of the list of required files by scraping 
the data from the kernel perhaps?


>>
>>
>> What are other build systems (gentoo for example) doing with their 
>> Rust builds to satisfy the kernel's rust requirements?
>>
>
> I will check and update on this.


Thanks.

>>
>>
>>>
>>> In future when rust is default in kernel we can change this, But 
>>> till then it is good to have it as a distro feature.
>>>> Do the nativesdk components get packaged separately? If they were, we
>>>> could then make that an SDK feature instead.
>>> No, We are not packaging it separately.
>>
>>
>> The questions seems to be whether we should create a separate 
>> packaging rule.
>>
>
> Now by default it is getting packaged with nativesdk-rust, Do we need 
> a separate packaging for libraries/files that being installed for rust 
> in kernel support?
>>
>>
>>>> What happens for on target kernel module development? Shouldn't 
>>>> there be a target package too?
>>> Yes, I have made the necessary changes to include Rust library for 
>>> target as well and have tested Rust-based kernel module development 
>>> on the target.
>>> I will send updated patches with v3.
>>
>>
>> Before you spend time on polishing v3 please explain what your 
>> workflow is, step by step,
>> so we can be sure that things makes sense from a high level.
>>
> We will update the rust recipe to copy the required libs to target 
> image and then the below steps to be followed :

This part we're still trying to work out...

> - Build the image by adding the required tools via 
> IMAGE_INSTALL:append ( e.g kernel-devsrc, gcc, rust, cargo, 
> bindgen-cli etc..).
>
We could create / extend a packagegroup or use:
    meta/recipes-extended/images/core-image-kernel-dev.bb

Bruce, what approach do you use / prefer ?


> - In /usr/src/kernel, run "make rustavailable" to verify Rust support 
> (This step will check all supporting tools are available for rust 
> support in kernel).
> - Run "make menuconfig" and enable "CONFIG_RUST".
> - Run "make scripts" and "make prepare".
> - Write a kernel module in Rust & build the module using "make", which 
> generates the "module_name.ko" file.
> - Load the module using "insmod module_name.ko".


The rest seems sensible to a non-kernel guy like me.

Thanks,

../Randy

>
> Thanks,
> Harish
>
>> ../Randy
>>
>>
>>>
>>> Thanks,
>>> Harish
>>>> Cheers,
>>>>
>>>> Richard
>>
>>
>> -- 
>> # Randy MacLeod
>> # Wind River Linux


-- 
# Randy MacLeod
# Wind River Linux

[-- Attachment #2: Type: text/html, Size: 14838 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2026-01-07 18:21           ` Randy MacLeod
@ 2026-01-07 19:03             ` Richard Purdie
  2026-01-12  0:42             ` Alistair Francis
  1 sibling, 0 replies; 29+ messages in thread
From: Richard Purdie @ 2026-01-07 19:03 UTC (permalink / raw)
  To: Randy MacLeod, Harish Sadineni, bruce.ashfield
  Cc: Sundeep.Kokkonda, yoann.congal, elmehdi.younes, openembedded-core

On Wed, 2026-01-07 at 13:21 -0500, Randy MacLeod wrote:
>  
> On 2026-01-07 11:34 a.m., Harish Sadineni wrote:
>  
> > On 1/7/2026 12:29 AM, Randy MacLeod wrote:On 2026-01-05 11:24 a.m.,
> > Harish Sadineni wrote:
> > >  We don't want the rust recipe to change based on a kernel config
> > > unless we *really* have to 
> > >  since that essentially doubles the testing that should be done
> > > or leaves a gap in testing of the 
> > >  rust builds. If you do that for the kernel first, then another
> > > recipe later, soon you have a maintenance mess. 
> > >  
> > >  Also if the kernel needs these files, then it's likely that
> > > other software will need it as well. 
> > >  You should analyze why the kernel needs these files and why
> > > other recipes do not. Perhaps any 
> > >  kernel-like image will have the same requirement. Is there a
> > > baremetal image  using rust anywhere 
> > >  that you can use to check on that? I looked but all I found was:
> > >  https://github.com/ahcbb6/baremetal-helloqemu-rust 
> > >  Anyway, let's focus on the linux kernel's requirements for now. 
> > >  
> > >  
> > >  So, how many files are needed and how much FS space do they use?
> >  The file size of the library directory is around 50MB. 
> > I've been around since the 1990s, 50 MB doesn't seem small to me
> > but
>  let's see what other people think.
>  
>  
> Also, how may files is that?
>  
>  What's the content?  ls -lR if the list isn't too long.
>  
>  Does the kernel build need each and every file ? How did you check? 
>  Can we automate the generation of the list of required files by
> scraping the data from the kernel perhaps?
>  
In the scheme of things, 50MB is not great but probably ok. It will be
compressed down for sstate and so on.

It does however need to be in a separate target package, that is
important.

The win here is that if you change DISTRO_FEATURES, rust/rust-native
shouldn't be rebuilding, which is worth a bit of disk usage, IMO at
least.

Cheers,

Richard


>  


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample
  2026-01-05  9:32   ` [OE-core] " Mathieu Dubois-Briand
@ 2026-01-08  9:39     ` Yoann Congal
  0 siblings, 0 replies; 29+ messages in thread
From: Yoann Congal @ 2026-01-08  9:39 UTC (permalink / raw)
  To: Mathieu Dubois-Briand
  Cc: Harish.Sadineni, openembedded-core, Randy.MacLeod,
	Sundeep.Kokkonda, bruce.ashfield, elmehdi.younes

[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

Le lun. 5 janv. 2026 à 10:32, Mathieu Dubois-Briand <
mathieu.dubois-briand@bootlin.com> a écrit :

> On Tue Dec 30, 2025 at 3:15 PM CET, Harish via lists.openembedded.org
> Sadineni wrote:
> > 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>
> > ---
>
> Hi Yoann, Harish,
>
> Thanks for your patch.
>
> It looks like we got a few intermittent failures here:
>
> 2026-01-02 19:40:58,816 - oe-selftest - INFO - FAIL:
> runtime_test.RustKernel.test_kernel_rust_sample (subunit.RemotedTestCase)
> 2026-01-02 19:40:58,816 - oe-selftest - INFO -
> ----------------------------------------------------------------------
> 2026-01-02 19:40:58,816 - oe-selftest - INFO -
> testtools.testresult.real._StringException: Traceback (most recent call
> last):
>   File
> "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/runtime_test.py",
> line 514, in test_kernel_rust_sample
>     self.assertEqual(status, 1, "Loading rust_out_of_tree module failed!")
>   File "/usr/lib/python3.10/unittest/case.py", line 845, in assertEqual
>     assertion_func(first, second, msg=msg)
>   File "/usr/lib/python3.10/unittest/case.py", line 838, in
> _baseAssertEqual
>     raise self.failureException(msg)
> AssertionError: 0 != 1 : Loading rust_out_of_tree module failed!
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3082
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/3095

Those are both from ARM hosts and, sadly, there are no logs to explain why
it failed :(
Harish, is this something you can test on your side?


> I only saw two occurrences so far, on at least 10 builds, but maybe you
> can check for obvious reasons before the series get merged.
>
> Thanks,
> Mathieu
>
> --
> Mathieu Dubois-Briand, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
>

-- 
Yoann Congal
Smile ECS

[-- Attachment #2: Type: text/html, Size: 3714 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk
  2025-12-30 14:15 ` [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
@ 2026-01-12  0:10   ` Alistair Francis
  0 siblings, 0 replies; 29+ messages in thread
From: Alistair Francis @ 2026-01-12  0:10 UTC (permalink / raw)
  To: Harish.Sadineni
  Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda,
	bruce.ashfield, yoann.congal, elmehdi.younes

On Wed, Dec 31, 2025 at 12:16 AM Sadineni, Harish via
lists.openembedded.org
<Harish.Sadineni=windriver.com@lists.openembedded.org> wrote:
>
> 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>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  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
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#228667): https://lists.openembedded.org/g/openembedded-core/message/228667
> Mute This Topic: https://lists.openembedded.org/mt/116997862/3619028
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alistair23@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS
  2025-12-30 14:15 ` [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
@ 2026-01-12  0:12   ` Alistair Francis
  0 siblings, 0 replies; 29+ messages in thread
From: Alistair Francis @ 2026-01-12  0:12 UTC (permalink / raw)
  To: Harish.Sadineni
  Cc: openembedded-core, Randy.MacLeod, Sundeep.Kokkonda,
	bruce.ashfield, yoann.congal, elmehdi.younes

On Wed, Dec 31, 2025 at 12:16 AM Sadineni, Harish via
lists.openembedded.org
<Harish.Sadineni=windriver.com@lists.openembedded.org> wrote:
>
> 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>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  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
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#228668): https://lists.openembedded.org/g/openembedded-core/message/228668
> Mute This Topic: https://lists.openembedded.org/mt/116997863/3619028
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alistair23@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2026-01-07 18:21           ` Randy MacLeod
  2026-01-07 19:03             ` Richard Purdie
@ 2026-01-12  0:42             ` Alistair Francis
  2026-01-13 12:14               ` Harish Sadineni
  1 sibling, 1 reply; 29+ messages in thread
From: Alistair Francis @ 2026-01-12  0:42 UTC (permalink / raw)
  To: randy.macleod
  Cc: Harish Sadineni, Richard Purdie, bruce.ashfield, Sundeep.Kokkonda,
	yoann.congal, elmehdi.younes, openembedded-core

On Thu, Jan 8, 2026 at 4:22 AM Randy MacLeod via
lists.openembedded.org
<randy.macleod=windriver.com@lists.openembedded.org> wrote:
>
> On 2026-01-07 11:34 a.m., Harish Sadineni wrote:
>
>
> On 1/7/2026 12:29 AM, Randy MacLeod wrote:
>
> On 2026-01-05 11:24 a.m., Harish Sadineni wrote:
>
>
> On 12/30/2025 9:28 PM, Richard Purdie 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 Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via lists.openembedded.org wrote:
>
> 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
> +}

Note you can just use the Rust bootstrap tool to install the source,
see my patch here:
https://lists.openembedded.org/g/openembedded-core/topic/patch_1_2_rust_install_the/117170671

That way you don't need to manually copy the files

> +
>   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"
>
> The commit message should mention the size of these files.
>
> Ok sure, I will add file size in v3.
>
> Does this make sense as a distro feature or should we just do this all the time?
>
> This is suggestion from Bruce that we take it as distro feature.
> https://lists.openembedded.org/g/openembedded-core/message/225256
>
>
>
> Richard mentioned this thread in today's tech call when I asked for commentson the rust-kernel PR.
>
> Yes, the high level requirement is to have a DISTRO_FEATURE but common, infrastructure parts
> such as this code that just copies a hopefully small number of files around,
> and is part of the rust recipe, could and likely be done regardless of the rust-kernel DISTRO_FEATURE.
>
>
> Ok sure, We will remove the dependency on DISTRO_FEATURE  for copying the library directory from rust recipe.
>
>
> Hold on, I said "small number of files...". See below.
>
>
>
> We don't want the rust recipe to change based on a kernel config unless we *really* have to
> since that essentially doubles the testing that should be done or leaves a gap in testing of the
> rust builds. If you do that for the kernel first, then another recipe later, soon you have a maintenance mess.
>
> Also if the kernel needs these files, then it's likely that other software will need it as well.
> You should analyze why the kernel needs these files and why other recipes do not. Perhaps any
> kernel-like image will have the same requirement. Is there a baremetal image  using rust anywhere
> that you can use to check on that? I looked but all I found was:
> https://github.com/ahcbb6/baremetal-helloqemu-rust
> Anyway, let's focus on the linux kernel's requirements for now.

The kernel needs the Rust core souce as the kernel is cross compiling
the Rust source in it's build system.

It seems unlikely that other software will do the same. It's a bit of
a niche Linux kernel thing to want to do.

>
>
> So, how many files are needed and how much FS space do they use?
>
>
> The file size of the library directory is around 50MB.
>
>
> I've been around since the 1990s, 50 MB doesn't seem small to me but
> let's see what other people think.
>
> Also, how may files is that?
>
> What's the content?  ls -lR if the list isn't too long.
>
> Does the kernel build need each and every file ? How did you check?
> Can we automate the generation of the list of required files by scraping the data from the kernel perhaps?

It's the core Rust library. Even if the kernel only uses a select
number of files, those files will pull in other files and modules.
Copying a subset of files would require editing the files to remove
imports to the missing files and seems very prone to breakage.

I agree 50MB isn't great, but it allows the rust-native package to
build the kernel without rebuliding rust-native, which seems like a
win.

>
>
>
>
> What are other build systems (gentoo for example) doing with their Rust builds to satisfy the kernel's rust requirements?
>
>
> I will check and update on this.
>
>
> Thanks.
>
>
>
>
> In future when rust is default in kernel we can change this, But till then it is good to have it as a distro feature.
>
> Do the nativesdk components get packaged separately? If they were, we
> could then make that an SDK feature instead.
>
> No, We are not packaging it separately.
>
>
>
> The questions seems to be whether we should create a separate packaging rule.
>
>
> Now by default it is getting packaged with nativesdk-rust, Do we need a separate packaging for libraries/files that being installed for rust in kernel support?

The Rust tooling actually does this (it's called rust-src) so maybe a
rust-src-native package would be the way to go

Alistair

>
>
>
> What happens for on target kernel module development? Shouldn't there be a target package too?
>
> Yes, I have made the necessary changes to include Rust library for target as well and have tested Rust-based kernel module development on the target.
> I will send updated patches with v3.
>
>
>
> Before you spend time on polishing v3 please explain what your workflow is, step by step,
> so we can be sure that things makes sense from a high level.
>
> We will update the rust recipe to copy the required libs to target image and then the below steps to be followed :
>
>
> This part we're still trying to work out...
>
> - Build the image by adding the required tools via IMAGE_INSTALL:append ( e.g kernel-devsrc, gcc, rust, cargo, bindgen-cli etc..).
>
> We could create / extend a packagegroup or use:
>    meta/recipes-extended/images/core-image-kernel-dev.bb
>
> Bruce, what approach do you use / prefer ?
>
>
> - In /usr/src/kernel, run "make rustavailable" to verify Rust support (This step will check all supporting tools are available for rust support in kernel).
> - Run "make menuconfig" and enable "CONFIG_RUST".
> - Run "make scripts" and "make prepare".
> - Write a kernel module in Rust & build the module using "make", which generates the "module_name.ko" file.
> - Load the module using "insmod module_name.ko".
>
>
> The rest seems sensible to a non-kernel guy like me.
>
> Thanks,
>
> ../Randy
>
>
> Thanks,
> Harish
>
> ../Randy
>
>
>
> Thanks,
> Harish
>
> Cheers,
>
> Richard
>
>
>
> --
> # Randy MacLeod
> # Wind River Linux
>
>
> --
> # Randy MacLeod
> # Wind River Linux
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#229026): https://lists.openembedded.org/g/openembedded-core/message/229026
> Mute This Topic: https://lists.openembedded.org/mt/116997864/3619028
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alistair23@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [OE-core] [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support
  2026-01-12  0:42             ` Alistair Francis
@ 2026-01-13 12:14               ` Harish Sadineni
  0 siblings, 0 replies; 29+ messages in thread
From: Harish Sadineni @ 2026-01-13 12:14 UTC (permalink / raw)
  To: Alistair Francis, randy.macleod
  Cc: Richard Purdie, bruce.ashfield, Sundeep.Kokkonda, yoann.congal,
	elmehdi.younes, openembedded-core


On 1/12/2026 6:12 AM, Alistair Francis 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 Thu, Jan 8, 2026 at 4:22 AM Randy MacLeod via
> lists.openembedded.org
> <randy.macleod=windriver.com@lists.openembedded.org> wrote:
>> On 2026-01-07 11:34 a.m., Harish Sadineni wrote:
>>
>>
>> On 1/7/2026 12:29 AM, Randy MacLeod wrote:
>>
>> On 2026-01-05 11:24 a.m., Harish Sadineni wrote:
>>
>>
>> On 12/30/2025 9:28 PM, Richard Purdie 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 Tue, 2025-12-30 at 06:15 -0800, Sadineni, Harish via lists.openembedded.org wrote:
>>
>> 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
>> +}
> Note you can just use the Rust bootstrap tool to install the source,
> see my patch here:
> https://lists.openembedded.org/g/openembedded-core/topic/patch_1_2_rust_install_the/117170671
>
> That way you don't need to manually copy the files
Yes, that works. However, when using the above method to install the 
sources, 'bitbake make-mod-scripts' fails with the following error:

HOSTRUSTC scripts/generate_rust_target
error: Unrecognized option: 'i'

This issue occurs because CFLAGS are being passed to HOSTRUSTC. I have 
updated the flags in the make-mod-scripts recipe to align with the flags 
used by linux-yocto.
In addition, I fixed some build path issues and packaged the Rust 
library sources separately.

We are currently testing the changes and will send v3 within the next 
couple of days.

Thanks,
Harish
>
>> +
>>    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"
>>
>> The commit message should mention the size of these files.
>>
>> Ok sure, I will add file size in v3.
>>
>> Does this make sense as a distro feature or should we just do this all the time?
>>
>> This is suggestion from Bruce that we take it as distro feature.
>> https://lists.openembedded.org/g/openembedded-core/message/225256
>>
>>
>>
>> Richard mentioned this thread in today's tech call when I asked for commentson the rust-kernel PR.
>>
>> Yes, the high level requirement is to have a DISTRO_FEATURE but common, infrastructure parts
>> such as this code that just copies a hopefully small number of files around,
>> and is part of the rust recipe, could and likely be done regardless of the rust-kernel DISTRO_FEATURE.
>>
>>
>> Ok sure, We will remove the dependency on DISTRO_FEATURE  for copying the library directory from rust recipe.
>>
>>
>> Hold on, I said "small number of files...". See below.
>>
>>
>>
>> We don't want the rust recipe to change based on a kernel config unless we *really* have to
>> since that essentially doubles the testing that should be done or leaves a gap in testing of the
>> rust builds. If you do that for the kernel first, then another recipe later, soon you have a maintenance mess.
>>
>> Also if the kernel needs these files, then it's likely that other software will need it as well.
>> You should analyze why the kernel needs these files and why other recipes do not. Perhaps any
>> kernel-like image will have the same requirement. Is there a baremetal image  using rust anywhere
>> that you can use to check on that? I looked but all I found was:
>> https://github.com/ahcbb6/baremetal-helloqemu-rust
>> Anyway, let's focus on the linux kernel's requirements for now.
> The kernel needs the Rust core souce as the kernel is cross compiling
> the Rust source in it's build system.
>
> It seems unlikely that other software will do the same. It's a bit of
> a niche Linux kernel thing to want to do.
>
>>
>> So, how many files are needed and how much FS space do they use?
>>
>>
>> The file size of the library directory is around 50MB.
>>
>>
>> I've been around since the 1990s, 50 MB doesn't seem small to me but
>> let's see what other people think.
>>
>> Also, how may files is that?
>>
>> What's the content?  ls -lR if the list isn't too long.
>>
>> Does the kernel build need each and every file ? How did you check?
>> Can we automate the generation of the list of required files by scraping the data from the kernel perhaps?
> It's the core Rust library. Even if the kernel only uses a select
> number of files, those files will pull in other files and modules.
> Copying a subset of files would require editing the files to remove
> imports to the missing files and seems very prone to breakage.
>
> I agree 50MB isn't great, but it allows the rust-native package to
> build the kernel without rebuliding rust-native, which seems like a
> win.
>
>>
>>
>>
>> What are other build systems (gentoo for example) doing with their Rust builds to satisfy the kernel's rust requirements?
>>
>>
>> I will check and update on this.
>>
>>
>> Thanks.
>>
>>
>>
>>
>> In future when rust is default in kernel we can change this, But till then it is good to have it as a distro feature.
>>
>> Do the nativesdk components get packaged separately? If they were, we
>> could then make that an SDK feature instead.
>>
>> No, We are not packaging it separately.
>>
>>
>>
>> The questions seems to be whether we should create a separate packaging rule.
>>
>>
>> Now by default it is getting packaged with nativesdk-rust, Do we need a separate packaging for libraries/files that being installed for rust in kernel support?
> The Rust tooling actually does this (it's called rust-src) so maybe a
> rust-src-native package would be the way to go
>
> Alistair
>
>>
>>
>> What happens for on target kernel module development? Shouldn't there be a target package too?
>>
>> Yes, I have made the necessary changes to include Rust library for target as well and have tested Rust-based kernel module development on the target.
>> I will send updated patches with v3.
>>
>>
>>
>> Before you spend time on polishing v3 please explain what your workflow is, step by step,
>> so we can be sure that things makes sense from a high level.
>>
>> We will update the rust recipe to copy the required libs to target image and then the below steps to be followed :
>>
>>
>> This part we're still trying to work out...
>>
>> - Build the image by adding the required tools via IMAGE_INSTALL:append ( e.g kernel-devsrc, gcc, rust, cargo, bindgen-cli etc..).
>>
>> We could create / extend a packagegroup or use:
>>     meta/recipes-extended/images/core-image-kernel-dev.bb
>>
>> Bruce, what approach do you use / prefer ?
>>
>>
>> - In /usr/src/kernel, run "make rustavailable" to verify Rust support (This step will check all supporting tools are available for rust support in kernel).
>> - Run "make menuconfig" and enable "CONFIG_RUST".
>> - Run "make scripts" and "make prepare".
>> - Write a kernel module in Rust & build the module using "make", which generates the "module_name.ko" file.
>> - Load the module using "insmod module_name.ko".
>>
>>
>> The rest seems sensible to a non-kernel guy like me.
>>
>> Thanks,
>>
>> ../Randy
>>
>>
>> Thanks,
>> Harish
>>
>> ../Randy
>>
>>
>>
>> Thanks,
>> Harish
>>
>> Cheers,
>>
>> Richard
>>
>>
>>
>> --
>> # Randy MacLeod
>> # Wind River Linux
>>
>>
>> --
>> # Randy MacLeod
>> # Wind River Linux
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#229026): https://lists.openembedded.org/g/openembedded-core/message/229026
>> Mute This Topic: https://lists.openembedded.org/mt/116997864/3619028
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alistair23@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
  2025-12-30 14:15 ` [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
@ 2026-01-14 15:41   ` alban.moizan
  0 siblings, 0 replies; 29+ messages in thread
From: alban.moizan @ 2026-01-14 15:41 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3956 bytes --]

Excuse me for the double mail, I was not yet subscribing to the mailing list, so my mail was hidden.

--------------------------

Hi everyone,

I've been investigating the issue when enabling `ccache` for kernel builds that involve Rust.

First of all, as documented in the `ccache` issue tracker [1], `ccache` is not directly compatible with Rust.
Therefore the current goal is to keep `ccache` enabled for the C portions of the kernel while bypassing it for Rust.
While an alternative like `sccache` [2], compatible with both C and Rust exists, you will see below that the underlying issue is the same, so just replacing `ccache` by `sccache` will change nothing here.

The issue (commit 235e6d49e5888ad04416219e10b6df91a738661a + this patch):

When `ccache` is enabled, `${CC}` to `${CCACHE}{CC}`, ex: `gcc` to `ccache gcc`

Then, when compiling the kernel, `scripts/Makefile.host` will give it to `rustc` with `-Clinker=$(HOSTCC)` [3], but the shell expands `$(HOSTCC)` to two words, therefore `rustc` takes `gcc` as another parameters, and it errors out. 

I attempted to resolve it by modifying the incriminated Makefile in the following ways:

Trial 1: Quoting HOSTCC in Kernel Makefile
Modify `scripts/Makefile.host` to wrap `HOSTCC` in quotes to ensure it is passed as a single string parameter:
Replace `-Clinker=$(HOSTCC)` to `-Clinker='$(HOSTCC)'`
Result: Failure, `rustc` looks for a binary path literally named `ccache gcc`, which does not exist, indeed, `-Clinker` argument value is treated by `rustc` as a real path, and not a command [4].

Trial 2: Splitting HOSTCC into Linker and Pre-link Args
Modified `scripts/Makefile.host` to force the linker to the first word of `HOSTCC` and pass subsequent words to `-Zpre-link-args`:
Replace `-Clinker=$(HOSTCC)` by `-Clinker=$(firstword $(HOSTCC)) -Zpre-link-args='$(wordlist 2,$(words $(HOSTCC)),$(HOSTCC))'`
Result: Failure, `rustc` executes the command as: "ccache" "-m64" "gcc" ....
This is invalid because in `rustc`, the target-specific pre-link arguments (from `compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs`) are added before our custom args, placing `-m64` before the `gcc` executable [5] .

Proposed Solutions
1. Kernel + Rust Patch (A): Patch the kernel Makefile (like the Trial 1) and patch `rustc` to accept a command string (with arguments) for `-Clinker` instead of a strict Path.
2. Kernel + Rust Patch (B): Patch the kernel Makefile (like the Trial 2) and patch `rustc` to use `post_link_args` instead of `pre_link_args` for target-specific values, ensuring the executable stays at the end of the command.
3. Shell Wrappers: Implement shell wrappers for CC, CXX, etc. This would allow `rustc` to call a single wrapper script, hiding `ccache` from it.
4. Kernel only: Patch the kernel Makefile to filter out `ccache` from CC (works in practice but not generic for a possible other wrapper in the future).
5. Leave as-is: disable `ccache` when rust is enabled .

Risks and Considerations
- Upstreamability: Patching rust and the kernel at the same time could take time. 
- Maintainability: While the shell wrapper approach is more flexible and solves the issue for other tools with similar limitations, it might make debugging in Yocto more difficult and requires significant changes.

I'm leaning towards the 1st or the 3rd approach, but I'd appreciate the maintainers' thoughts on which path fits the OE architecture best.

[1] https://github.com/ccache/ccache/issues/364

[2] https://github.com/mozilla/sccache

[3] https://git.yoctoproject.org/linux-yocto/tree/scripts/Makefile.host?h=v6.18.1#n94

[4] https://github.com/rust-lang/rust/blob/4931e09e3ac3182d2a00f38cccfdf68e8e385e1c/compiler/rustc_codegen_ssa/src/back/link.rs#L1419

[5] https://github.com/rust-lang/rust/blob/4931e09e3ac3182d2a00f38cccfdf68e8e385e1c/compiler/rustc_codegen_ssa/src/back/link.rs#L1870

Best regards,

Alban Moizan


[-- Attachment #2: Type: text/html, Size: 5166 bytes --]

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2026-01-14 15:41 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
2026-01-12  0:10   ` [OE-core] " Alistair Francis
2025-12-30 14:15 ` [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
2026-01-12  0:12   ` [OE-core] " Alistair Francis
2025-12-30 14:15 ` [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
2025-12-30 15:58   ` [OE-core] " Richard Purdie
2026-01-05 16:24     ` Harish Sadineni
2026-01-06 18:59       ` Randy MacLeod
2026-01-07 16:34         ` Harish Sadineni
2026-01-07 18:21           ` Randy MacLeod
2026-01-07 19:03             ` Richard Purdie
2026-01-12  0:42             ` Alistair Francis
2026-01-13 12:14               ` Harish Sadineni
2025-12-30 14:15 ` [PATCH v2 04/15] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 05/15] kernel-yocto: enable Rust kernel support via rustavailable and staged rustlib sources Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 06/15] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 07/15] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
2026-01-14 15:41   ` alban.moizan
2025-12-30 14:15 ` [PATCH v2 09/15] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
2026-01-05  9:32   ` [OE-core] " Mathieu Dubois-Briand
2026-01-08  9:39     ` Yoann Congal
2025-12-30 14:15 ` [PATCH v2 11/15] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 12/15] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 13/15] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 14/15] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 15/15] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox