diff mbox series

[RFC,v2,3/8] rust: install Rust library sources for 'make rustavailable' support

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

Commit Message

Harish Sadineni Nov. 5, 2025, 1:09 p.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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Yoann Congal Nov. 6, 2025, 8:49 p.m. UTC | #1
Le 05/11/2025 à 14:09, Sadineni, Harish via lists.openembedded.org a écrit :
> 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 | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/meta/recipes-devtools/rust/rust_1.90.0.bb b/meta/recipes-devtools/rust/rust_1.90.0.bb
> index e7f3985332..857d679e2b 100644
> --- a/meta/recipes-devtools/rust/rust_1.90.0.bb
> +++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
> @@ -54,6 +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
> @@ -318,6 +323,13 @@ rust_do_install:class-nativesdk() {
>  
>  FILES:${PN} += "${base_prefix}/environment-setup.d"
>  
> +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  ${RUSTSRC}/library ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust/
> +    fi

Why not just adding this code to the "rust_do_install:class-nativesdk()"
function defined just above?

> +}
> +
>  EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt"
>  rust_do_install:class-target() {
>      export PSEUDO_UNLOAD=1
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#225761): https://lists.openembedded.org/g/openembedded-core/message/225761
> Mute This Topic: https://lists.openembedded.org/mt/116133830/4316185
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [yoann.congal@smile.fr]
> -=-=-=-=-=-=-=-=-=-=-=-
>
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 e7f3985332..857d679e2b 100644
--- a/meta/recipes-devtools/rust/rust_1.90.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
@@ -54,6 +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
@@ -318,6 +323,13 @@  rust_do_install:class-nativesdk() {
 
 FILES:${PN} += "${base_prefix}/environment-setup.d"
 
+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  ${RUSTSRC}/library ${D}${SDKPATHNATIVE}/usr/lib/rustlib/src/rust/
+    fi
+}
+
 EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt"
 rust_do_install:class-target() {
     export PSEUDO_UNLOAD=1