From: Harish Sadineni <[email protected]>
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 <[email protected]>
---
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
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#228671):
https://lists.openembedded.org/g/openembedded-core/message/228671
Mute This Topic: https://lists.openembedded.org/mt/116997866/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-