| Message ID | 20251105130942.833204-1-Harish.Sadineni@windriver.com |
|---|---|
| Headers | show |
| Series | Enable rust support for linux kernel | expand |
Hello, Le 05/11/2025 à 14:09, Sadineni, Harish via lists.openembedded.org a écrit : > From: Harish Sadineni <Harish.Sadineni@windriver.com> > > v2: > - Addressed Bruce review comments for Making rust support for linux kernel as optional via distro feature. > - Fixed buildpaths errors by appending --remap-path-prefix to RUST_DEBUG_REMAP > - Removed unnecessary flags from rust.cfg > > 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 inside sdk. > > Summary of changes: > > - Patch 1: Extend 'bindgen-cli' to support 'nativesdk', allowing it to be available in the SDK environment. > - Patch 2: Add required dependencies ('clang-native', 'rust-native', 'bindgen-cli-native') to the kernel to support Rust binding generation. > - Patch 3: Install the Rust standard library source ('library/') into `work-shared` and which will be later copied to > linux-yocto recipe-sysroot-native. > - Patch 4: Stage the Rust sources into `recipe-sysroot-native` for kernel build compatibility, making them visible during native builds. > - Patch 5: Update `kernel-yocto.bbclass` to invoke `make rustavailable` during 'do_kernel_configme', ensuring Rust readiness. > - Patch 6: Add kernel configuration support for Rust (via 'rust.cfg' and 'rust.scc'), enabling the Rust build options in kernel config. > - Patch 7: Fixed buildpaths errors when rust is enabled for kernel by appending --remap-path-prefix to RUST_DEBUG_REMAP > - patch 8: Copy Rust kernel sources into kernel-devsrc build directory which will be required while running 'make prepare' in sdk. > > Harish Sadineni (8): > bindgen-cli: extend BBCLASSEXTEND to include nativesdk > linux-yocto: add clang-native,rust-native and bindgen-cli-native to > DEPENDS > rust: install Rust library sources for 'make rustavailable' support > rust: stage rustlib sources for linux-yocto make rustavailable support > kernel-yocto: add rust support via make rustavailable in > do_kernel_configme > 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 soucre to $kerneldir/build > > meta/classes-recipe/kernel-yocto.bbclass | 16 ++++++++++++++++ > .../bindgen-cli/bindgen-cli_0.72.1.bb | 2 +- > meta/recipes-devtools/rust/rust_1.90.0.bb | 12 ++++++++++++ > meta/recipes-kernel/linux/files/rust.cfg | 9 +++++++++ > meta/recipes-kernel/linux/files/rust.scc | 1 + > meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++ > meta/recipes-kernel/linux/linux-yocto.inc | 9 +++++++++ > meta/recipes-kernel/linux/linux-yocto_6.16.bb | 3 +++ > 8 files changed, 55 insertions(+), 1 deletion(-) > create mode 100644 meta/recipes-kernel/linux/files/rust.cfg > create mode 100644 meta/recipes-kernel/linux/files/rust.scc I made some comments inline in the patches. I've tested the series with the rust samples inside the kernel sources: In a basic(*) Yocto/Poky master build: In local.conf: DISTRO_FEATURES:append = ' rust-kernel' CORE_IMAGE_EXTRA_INSTALL += "kernel-module-rust-minimal" Then, bitbake core-image-minimal runqemu kvm snapshot nographic serial root@qemux86-64:~# modprobe rust_minimal [ 9.394264] rust_minimal: Rust minimal sample (init) [ 9.394915] rust_minimal: Am I built-in? false => Samples are working. Nice! (*) I lied, my setup is not entirely basic: I use ccache. With ccache, I get this error: | error: multiple input filenames provided (first two filenames are gcc and .../tmp/work-shared/qemux86-64/kernel-source/scripts/generate_rust_target.rs) So I had to add in local.conf: CCACHE_DISABLE:pn-linux-yocto = "1" Can you integrate in your patch series the fix El Mehdi did for this? In meta/recipes-kernel/linux/linux-yocto.inc, he added +# TODO: Kernel rust code compilation breaks under ccache, disable it for now +CCACHE_DISABLE ?= "${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', '1', '', d)}" Obviously, we will need to investigate why that break and fix it but in the meantime, that mean that your RFC is testable in more configuration Thanks! Regards,
From: Harish Sadineni <Harish.Sadineni@windriver.com> v2: - Addressed Bruce review comments for Making rust support for linux kernel as optional via distro feature. - Fixed buildpaths errors by appending --remap-path-prefix to RUST_DEBUG_REMAP - Removed unnecessary flags from rust.cfg 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 inside sdk. Summary of changes: - Patch 1: Extend 'bindgen-cli' to support 'nativesdk', allowing it to be available in the SDK environment. - Patch 2: Add required dependencies ('clang-native', 'rust-native', 'bindgen-cli-native') to the kernel to support Rust binding generation. - Patch 3: Install the Rust standard library source ('library/') into `work-shared` and which will be later copied to linux-yocto recipe-sysroot-native. - Patch 4: Stage the Rust sources into `recipe-sysroot-native` for kernel build compatibility, making them visible during native builds. - Patch 5: Update `kernel-yocto.bbclass` to invoke `make rustavailable` during 'do_kernel_configme', ensuring Rust readiness. - Patch 6: Add kernel configuration support for Rust (via 'rust.cfg' and 'rust.scc'), enabling the Rust build options in kernel config. - Patch 7: Fixed buildpaths errors when rust is enabled for kernel by appending --remap-path-prefix to RUST_DEBUG_REMAP - patch 8: Copy Rust kernel sources into kernel-devsrc build directory which will be required while running 'make prepare' in sdk. Harish Sadineni (8): bindgen-cli: extend BBCLASSEXTEND to include nativesdk linux-yocto: add clang-native,rust-native and bindgen-cli-native to DEPENDS rust: install Rust library sources for 'make rustavailable' support rust: stage rustlib sources for linux-yocto make rustavailable support kernel-yocto: add rust support via make rustavailable in do_kernel_configme 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 soucre to $kerneldir/build meta/classes-recipe/kernel-yocto.bbclass | 16 ++++++++++++++++ .../bindgen-cli/bindgen-cli_0.72.1.bb | 2 +- meta/recipes-devtools/rust/rust_1.90.0.bb | 12 ++++++++++++ meta/recipes-kernel/linux/files/rust.cfg | 9 +++++++++ meta/recipes-kernel/linux/files/rust.scc | 1 + meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++ meta/recipes-kernel/linux/linux-yocto.inc | 9 +++++++++ meta/recipes-kernel/linux/linux-yocto_6.16.bb | 3 +++ 8 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-kernel/linux/files/rust.cfg create mode 100644 meta/recipes-kernel/linux/files/rust.scc