[PATCH v3 04/16] kernel-yocto: enable Rust kernel support via 'make rustavailable'.

Harish.Sadineni
2026-01-20T17:54:28Z

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

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

-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 | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index e53bf15194..4323c4c80a 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -463,8 +463,14 @@ 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() {
+
do_kernel_metadata config

# translate the kconfig_mode into something that merge_config.sh
@@ -506,6 +512,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