On 2025-11-19 11:47 a.m., [email protected] wrote:
From: Harish Sadineni<[email protected]>

v3:
- Addressed v2 review feedback regarding adding dependencies to a variable and 
assigning them using (?=).
- Moved staging of Rust libraries for the Linux-Yocto 'make rustavailable' step 
from linux-yocto.inc
   to kernel-yocto.bbclass.
- Made copying of the Rust library directory into tmp/work-shared optional and 
performed only when
   building rust-native when rust-kernel is present in DISTRO_FEATURES.
- Split rust.cfg into three separate config fragments: rust.cfg, 
rust-samples.cfg, and rust-debug.cfg.
- Disabled ccache for Linux-Yocto builds when rust-kernel is present in 
DISTRO_FEATURES
- Added an oe-selftest case for the Linux Rust sample


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: Added 'rust-kernel' to DISTRO_FEATURES_FILTER_NATIVE and 
DISTRO_FEATURES_FILTER_NATIVESDK, the 'rust-kernel' feature automatically
            propagates from target DISTRO_FEATURES to native/nativesdk builds
- Patch 5: Stage the Rust sources into `recipe-sysroot-native` for kernel build 
compatibility, making them visible during native builds.
- Patch 6: Update `kernel-yocto.bbclass` to invoke `make rustavailable` during 
'do_kernel_configme', ensuring Rust readiness.
- Patch 7: Add kernel configuration support for Rust (via 'rust.cfg' and 
'rust.scc'), enabling the Rust build options in kernel config.
- Patch 8: Fixed buildpaths errors when rust is enabled for kernel by appending 
--remap-path-prefix to RUST_DEBUG_REMAP
- Patch 9: Disabling ccache when rust-kernel is enabled for linux-yocto.
- Patch 10: Copy Rust kernel sources into kernel-devsrc build directory which 
will be required while running 'make prepare' in sdk.
- Patch 11: Added an oe-selftest case for the Linux Rust sample.

Benchmark test-result for x86-64:

For bitbake core-image-minimal
+-------------------------------+------------+-----------+-----------+-----------+
| DISTRO_FEATURES               |   real     |   user    |    sys    |  FS 
usage |
+-------------------------------+------------+-----------+-----------+-----------+
| rust-kernel (enabled)         | 46m1.720s  | 0m28.864s | 0m3.696s  |   58 GB  
 |
| rust-kernel (disabled)        | 30m1.053s  | 0m20.091s | 0m2.748s  |   33 GB  
 |
+-------------------------------+------------+-----------+-----------+-----------+
Thanks for reporting on the time and space bloat.

The increased in time & fs usage is due to kernel rust dependencies in
linux-yocto. These will get solved by using pre-built binaries from
meta-rust-bin (WIP).
We haven't decided if let alone how we're going to ensure that a
quick kernel build with rust enabled is still fairly quick.

We can look into meta-rust-bin as I suggested but we should be
evaluating it and sharing the pros and cons rather than thinking that

this approach will solve the "rust takes forever to build" problem.


WIP:

- I am  working on try to use make use of prebuilt binaries for rust and cargo 
using meta-rust-bin layer which is having compatability issues
   with oe-core master branch.
- rust-out-of-tree kernel module recipe and selftest is in progress (by Yoann 
Congal)

Test results:
- tested with oe-selftest case for the Linux Rust sample for  x86_64 and arm64.
- tested with rust-out-of-tree kernel module in sdk for x86_64 and arm64.

Very nice work Harish.

One more thing that isn't a requirement for being able to support linux-yocto with rust enabled but

at some point, we want to test that self-hosted rust-enabled kernel development works.

As a non-urgent, unless Bruce demands it, task could you try installing:

   packagegroup-core-buildessential.bb
   packagegroup-rust-sdk-target.bb

and then on target, clone a kernel tree and try manually compiling
a rust-enabled kernel (module)?

Thanks,

../Randy



If everthing is fine, Can we send this as patch?.

Harish Sadineni (9):
   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
   bitbake.conf: Include "rust-kernel" in native/nativesdk feature
     filters
   kernel-yocto: 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

Yoann Congal (2):
   kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
   selftest/cases/runtime_test: Add test for Linux Rust sample

  meta/classes-recipe/kernel-yocto.bbclass      | 28 +++++++++++++++++++
  meta/conf/bitbake.conf                        |  4 +--
  meta/lib/oeqa/selftest/cases/runtime_test.py  | 24 ++++++++++++++++
  .../bindgen-cli/bindgen-cli_0.72.1.bb         |  2 +-
  meta/recipes-devtools/rust/rust_1.90.0.bb     | 17 +++++++++++
  .../recipes-kernel/linux/files/rust-debug.cfg |  1 +
  .../recipes-kernel/linux/files/rust-debug.scc |  3 ++
  .../linux/files/rust-samples.cfg              |  4 +++
  .../linux/files/rust-samples.scc              |  3 ++
  meta/recipes-kernel/linux/files/rust.cfg      |  3 ++
  meta/recipes-kernel/linux/files/rust.scc      |  3 ++
  meta/recipes-kernel/linux/kernel-devsrc.bb    |  4 +++
  meta/recipes-kernel/linux/linux-yocto.inc     |  2 ++
  meta/recipes-kernel/linux/linux-yocto_6.16.bb |  2 ++
  meta/recipes-kernel/linux/linux-yocto_6.17.bb |  2 ++
  15 files changed, 99 insertions(+), 3 deletions(-)
  create mode 100644 meta/recipes-kernel/linux/files/rust-debug.cfg
  create mode 100644 meta/recipes-kernel/linux/files/rust-debug.scc
  create mode 100644 meta/recipes-kernel/linux/files/rust-samples.cfg
  create mode 100644 meta/recipes-kernel/linux/files/rust-samples.scc
  create mode 100644 meta/recipes-kernel/linux/files/rust.cfg
  create mode 100644 meta/recipes-kernel/linux/files/rust.scc


--
# Randy MacLeod
# Wind River Linux
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#226599): 
https://lists.openembedded.org/g/openembedded-core/message/226599
Mute This Topic: https://lists.openembedded.org/mt/116376802/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to