* [RFC PATCH 1/5] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation
2025-11-19 19:55 [RFC PATCH 0/5] Kernel Rust out-of-tree module support Yoann Congal
@ 2025-11-19 19:55 ` Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 2/5] module.bbclass: Prepare out-of-tree rust module compilation Yoann Congal
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Yoann Congal @ 2025-11-19 19:55 UTC (permalink / raw)
To: openembedded-core; +Cc: Yoann Congal
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>
---
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 003a155e794..a9a25b9819a 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -631,6 +631,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
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH 2/5] module.bbclass: Prepare out-of-tree rust module compilation
2025-11-19 19:55 [RFC PATCH 0/5] Kernel Rust out-of-tree module support Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 1/5] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Yoann Congal
@ 2025-11-19 19:55 ` Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 3/5] meta-skeleton: Add rust-out-of-tree-module recipe Yoann Congal
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Yoann Congal @ 2025-11-19 19:55 UTC (permalink / raw)
To: openembedded-core; +Cc: Yoann Congal
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>
---
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 4948e995c5d..7dbd4194d17 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)}"
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH 3/5] meta-skeleton: Add rust-out-of-tree-module recipe
2025-11-19 19:55 [RFC PATCH 0/5] Kernel Rust out-of-tree module support Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 1/5] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 2/5] module.bbclass: Prepare out-of-tree rust module compilation Yoann Congal
@ 2025-11-19 19:55 ` Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 4/5] rust-out-of-tree-module: Add myself as maintainer Yoann Congal
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Yoann Congal @ 2025-11-19 19:55 UTC (permalink / raw)
To: openembedded-core; +Cc: Yoann Congal
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>
---
.../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 00000000000..642fa80319a
--- /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"
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH 4/5] rust-out-of-tree-module: Add myself as maintainer
2025-11-19 19:55 [RFC PATCH 0/5] Kernel Rust out-of-tree module support Yoann Congal
` (2 preceding siblings ...)
2025-11-19 19:55 ` [RFC PATCH 3/5] meta-skeleton: Add rust-out-of-tree-module recipe Yoann Congal
@ 2025-11-19 19:55 ` Yoann Congal
2025-11-19 19:55 ` [RFC PATCH 5/5] runtime_test: Add rust-out-of-tree selftest Yoann Congal
2025-12-01 9:48 ` [OE-core] [RFC PATCH 0/5] Kernel Rust out-of-tree module support Mathieu Dubois-Briand
5 siblings, 0 replies; 8+ messages in thread
From: Yoann Congal @ 2025-11-19 19:55 UTC (permalink / raw)
To: openembedded-core; +Cc: Yoann Congal
From: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
meta/conf/distro/include/maintainers.inc | 1 +
1 file changed, 1 insertion(+)
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index 6c3174cbb72..7204a5e5992 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -774,6 +774,7 @@ RECIPE_MAINTAINER:pn-ruby = "Ross Burton <ross.burton@arm.com>"
RECIPE_MAINTAINER:pn-run-postinsts = "Ross Burton <ross.burton@arm.com>"
RECIPE_MAINTAINER:pn-rust = "Randy MacLeod <Randy.MacLeod@windriver.com>"
RECIPE_MAINTAINER:pn-rust-cross-canadian-${TRANSLATED_TARGET_ARCH} = "Randy MacLeod <Randy.MacLeod@windriver.com>"
+RECIPE_MAINTAINER:pn-rust-out-of-tree-module = "Yoann Congal <yoann.congal@smile.fr>"
RECIPE_MAINTAINER:pn-rxvt-unicode = "Unassigned <unassigned@yoctoproject.org>"
RECIPE_MAINTAINER:pn-sassc = "Simone Weiß <simone.p.weiss@posteo.com>"
RECIPE_MAINTAINER:pn-sato-screenshot = "Ross Burton <ross.burton@arm.com>"
^ permalink raw reply related [flat|nested] 8+ messages in thread* [RFC PATCH 5/5] runtime_test: Add rust-out-of-tree selftest
2025-11-19 19:55 [RFC PATCH 0/5] Kernel Rust out-of-tree module support Yoann Congal
` (3 preceding siblings ...)
2025-11-19 19:55 ` [RFC PATCH 4/5] rust-out-of-tree-module: Add myself as maintainer Yoann Congal
@ 2025-11-19 19:55 ` Yoann Congal
2025-12-01 9:48 ` [OE-core] [RFC PATCH 0/5] Kernel Rust out-of-tree module support Mathieu Dubois-Briand
5 siblings, 0 replies; 8+ messages in thread
From: Yoann Congal @ 2025-11-19 19:55 UTC (permalink / raw)
To: openembedded-core; +Cc: Yoann Congal
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>
---
meta/lib/oeqa/selftest/cases/runtime_test.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index 66cb112a7c1..a6f75c1e29f 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -493,7 +493,7 @@ class RustKernel(OESelftestTestCase):
import textwrap
self.write_config(textwrap.dedent("""
DISTRO_FEATURES:append = ' rust-kernel'
- CORE_IMAGE_EXTRA_INSTALL += "kernel-module-rust-minimal"
+ CORE_IMAGE_EXTRA_INSTALL += "kernel-module-rust-minimal kernel-module-rust-out-of-tree"
"""))
bitbake(self.image)
@@ -505,3 +505,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")
+
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [OE-core] [RFC PATCH 0/5] Kernel Rust out-of-tree module support
2025-11-19 19:55 [RFC PATCH 0/5] Kernel Rust out-of-tree module support Yoann Congal
` (4 preceding siblings ...)
2025-11-19 19:55 ` [RFC PATCH 5/5] runtime_test: Add rust-out-of-tree selftest Yoann Congal
@ 2025-12-01 9:48 ` Mathieu Dubois-Briand
2025-12-04 8:15 ` Yoann Congal
5 siblings, 1 reply; 8+ messages in thread
From: Mathieu Dubois-Briand @ 2025-12-01 9:48 UTC (permalink / raw)
To: yoann.congal, openembedded-core
On Wed Nov 19, 2025 at 8:55 PM CET, Yoann Congal via lists.openembedded.org wrote:
> As followup of Harish Sadineni's RFC series "Enable rust support for
> linux kernel" [0] (and to increase its test coverage), this series add
> support for out-of-tree kernel module written in Rust as well as
> associated test.
>
> [0]: https://lists.openembedded.org/g/openembedded-core/message/226560
>
> Yoann Congal (5):
> 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
> rust-out-of-tree-module: Add myself as maintainer
> runtime_test: Add rust-out-of-tree selftest
>
> .../rust-out-of-tree-module_git.bb | 18 ++++++++++++++++++
> meta/classes-recipe/kernel.bbclass | 18 ++++++++++++++++++
> meta/classes-recipe/module.bbclass | 8 ++++++++
> meta/conf/distro/include/maintainers.inc | 1 +
> meta/lib/oeqa/selftest/cases/runtime_test.py | 9 ++++++++-
> 5 files changed, 53 insertions(+), 1 deletion(-)
> create mode 100644 meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
Hi Yoann,
I ran a few RFC series on the autobuilder, and I suspect this one of
these two issues, during oe-selftests.
First issues:
2025-11-29 08:23:13,186 - oe-selftest - INFO - 2: 6/31 214/648 (110.21s) (0 failed) (distrodata.Distrodata.test_maintainers)
2025-11-29 08:23:13,186 - 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/distrodata.py", line 115, in test_maintainers
self.fail("""
File "/usr/lib/python3.12/unittest/case.py", line 715, in fail
raise self.failureException(msg)
AssertionError:
Unable to find recipes for the following entries in maintainers.inc:
rust-out-of-tree-module
I saw you added something, but for some reason the test is not happy.
Second issues:
ERROR: core-image-minimal-1.0-r0 do_rootfs: Could not invoke dnf. Command '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/rootfs/etc/yum.repos.d --installroot=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/rootfs --setopt=logdir=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/temp --repofrompath=oe-repo,/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/oe-rootfs-repo --nogpgcheck install kernel-module-rust-minimal kernel-module-rust-out-of-tree packagegroup-core-boot run-postinsts ssh-pregen-hostkeys' returned 1:
...
No match for argument: kernel-module-rust-out-of-tree
Error: Unable to find a match: kernel-module-rust-out-of-tree
kernel-module-rust-out-of-tree is neither a recipe nor a generated package.
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2915
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2777
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2672
Thanks,
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [OE-core] [RFC PATCH 0/5] Kernel Rust out-of-tree module support
2025-12-01 9:48 ` [OE-core] [RFC PATCH 0/5] Kernel Rust out-of-tree module support Mathieu Dubois-Briand
@ 2025-12-04 8:15 ` Yoann Congal
0 siblings, 0 replies; 8+ messages in thread
From: Yoann Congal @ 2025-12-04 8:15 UTC (permalink / raw)
To: Mathieu Dubois-Briand, openembedded-core
Le 01/12/2025 à 10:48, Mathieu Dubois-Briand a écrit :
> On Wed Nov 19, 2025 at 8:55 PM CET, Yoann Congal via lists.openembedded.org wrote:
>> As followup of Harish Sadineni's RFC series "Enable rust support for
>> linux kernel" [0] (and to increase its test coverage), this series add
>> support for out-of-tree kernel module written in Rust as well as
>> associated test.
>>
>> [0]: https://lists.openembedded.org/g/openembedded-core/message/226560
>>
>> Yoann Congal (5):
>> 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
>> rust-out-of-tree-module: Add myself as maintainer
>> runtime_test: Add rust-out-of-tree selftest
>>
>> .../rust-out-of-tree-module_git.bb | 18 ++++++++++++++++++
>> meta/classes-recipe/kernel.bbclass | 18 ++++++++++++++++++
>> meta/classes-recipe/module.bbclass | 8 ++++++++
>> meta/conf/distro/include/maintainers.inc | 1 +
>> meta/lib/oeqa/selftest/cases/runtime_test.py | 9 ++++++++-
>> 5 files changed, 53 insertions(+), 1 deletion(-)
>> create mode 100644 meta-skeleton/recipes-kernel/rust-out-of-tree-module/rust-out-of-tree-module_git.bb
>
> Hi Yoann,
>
> I ran a few RFC series on the autobuilder, and I suspect this one of
> these two issues, during oe-selftests.
>
> First issues:
>
> 2025-11-29 08:23:13,186 - oe-selftest - INFO - 2: 6/31 214/648 (110.21s) (0 failed) (distrodata.Distrodata.test_maintainers)
> 2025-11-29 08:23:13,186 - 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/distrodata.py", line 115, in test_maintainers
> self.fail("""
> File "/usr/lib/python3.12/unittest/case.py", line 715, in fail
> raise self.failureException(msg)
> AssertionError:
> Unable to find recipes for the following entries in maintainers.inc:
> rust-out-of-tree-module
>
> I saw you added something, but for some reason the test is not happy.
>
> Second issues:
>
> ERROR: core-image-minimal-1.0-r0 do_rootfs: Could not invoke dnf. Command '/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/rootfs/etc/yum.repos.d --installroot=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/rootfs --setopt=logdir=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/temp --repofrompath=oe-repo,/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-179319/tmp/work/qemuarm64-poky-linux/core-image-minimal/1.0/oe-rootfs-repo --nogpgcheck install kernel-module-rust-minimal kernel-module-rust-out-of-tree packagegroup-core-boot run-postinsts ssh-pregen-hostkeys' returned 1:
> ...
> No match for argument: kernel-module-rust-out-of-tree
> Error: Unable to find a match: kernel-module-rust-out-of-tree
> kernel-module-rust-out-of-tree is neither a recipe nor a generated package.
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2915
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2777
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2672
It appears that meta-skeleton:
* is not covered by maintainers.inc
* is not included by default during this selftest (I had it in my local
config)
I will fix these in v2.
Thanks!
> Thanks,
> Mathieu
>
--
Yoann Congal
Smile ECS
^ permalink raw reply [flat|nested] 8+ messages in thread