diff mbox series

[RFC,3/4] rust-native: Conditionally install sources for kernel builds

Message ID 20251104171611.2227798-4-elmehdi.younes@smile.fr
State New
Headers show
Series Add rust-for-linux option for linux-yocto | expand

Commit Message

El Mehdi YOUNES Nov. 4, 2025, 5:16 p.m. UTC
The Linux kernel build, when Rust is enabled, requires the Rust
standard library sources (core, alloc, etc.) to be present in the
rust-native toolchain. Without these sources, the 'make rustavailable'
check fails, and Rust support cannot be enabled.

This patch adds the logic to install these sources.
The action is gated by the 'rust-kernel' DISTRO_FEATURES flag.

NOTE: For this conditional logic, the native build
environment must be made aware of the 'rust-kernel' feature.
Therefore, 'DISTRO_FEATURES_FILTER_NATIVE' (defined in
meta/conf/bitbake.conf) must be modified (e.g., in local.conf)
to include 'rust-kernel'.

Signed-off-by: El Mehdi YOUNES <elmehdi.younes@smile.fr>
---
 meta/recipes-devtools/rust/rust_1.90.0.bb | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/rust_1.90.0.bb b/meta/recipes-devtools/rust/rust_1.90.0.bb
index 0319d73b93..e3d68e6d93 100644
--- a/meta/recipes-devtools/rust/rust_1.90.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
@@ -425,3 +425,11 @@  RUSTLIB_DEP:class-nativesdk = ""
 INSANE_SKIP:${PN} = "staticdev"
 
 BBCLASSEXTEND = "native nativesdk"
+
+do_install:append:class-native() {
+        if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+            install -d ${D}${libdir}/rustlib/src/rust
+            cp -r ${S}/library/ ${D}${libdir}/rustlib/src/rust/
+        fi
+}
+FILES:${PN}:append:class-native = " ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', ' ${libdir}/rustlib/src/rust', '', d)}"