diff mbox series

[RFC,3/7] rust: install Rust standard library sources for make rustavailable support

Message ID 20251023112547.4044904-4-Harish.Sadineni@windriver.com
State New
Headers show
Series Enable rust support for linux kernel | expand

Commit Message

Harish Sadineni Oct. 23, 2025, 11:25 a.m. UTC
From: Harish Sadineni <Harish.Sadineni@windriver.com>

The `make rustavailable` process expects the Rust standard library source files (e.g., `lib.rs`) 
to be present in the `library/` directory under `rustlib/src/rust/`.

This patch ensures the required sources are available by:
- Copying the `library/` directory from the Rust source tree into `${TMPDIR}/work-shared/rust` 
  during the snapshot setup.
- Installing the `library/` directory into `${SDKPATHNATIVE}/usr/lib/rustlib/src/rust` for the 
  `nativesdk` class, making them available in the SDK.

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-devtools/rust/rust_1.90.0.bb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
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..4b9107b23d 100644
--- a/meta/recipes-devtools/rust/rust_1.90.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
@@ -54,7 +54,11 @@  do_rust_setup_snapshot () {
     # and fail without it there.
     mkdir -p ${RUSTSRC}/build/${RUST_BUILD_SYS}
     ln -sf ${WORKDIR}/rust-snapshot/ ${RUSTSRC}/build/${RUST_BUILD_SYS}/stage0
-
+    
+    if [ ! -d ${TMPDIR}/work-shared/rust ]; then    
+        mkdir -p ${TMPDIR}/work-shared/rust
+        cp -r ${RUSTSRC}/library ${TMPDIR}/work-shared/rust/.
+    fi
     # Need to use uninative's loader if enabled/present since the library paths
     # are used internally by rust and result in symbol mismatches if we don't
     if [ ! -z "${UNINATIVE_LOADER}" -a -e "${UNINATIVE_LOADER}" ]; then
@@ -288,6 +292,13 @@  rust_do_install() {
     rust_runx install
 }
 
+do_install:append:class-nativesdk () {
+    if [ ! -d ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust ]; then
+        mkdir -p ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust
+        cp -r --no-preserve=ownership  ${S}/library ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust/
+    fi
+}
+
 rust_do_install:class-nativesdk() {
     export PSEUDO_UNLOAD=1
     rust_runx install