diff mbox series

[RFC,v3,03/11] rust: install Rust library sources for 'make rustavailable' support

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

Commit Message

Harish Sadineni Nov. 19, 2025, 4:47 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 them available in sdk

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-devtools/rust/rust_1.90.0.bb | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Randy MacLeod Nov. 19, 2025, 8:04 p.m. UTC | #1
On 2025-11-19 11:47 a.m., Harish.Sadineni@windriver.com wrote:
> From: Harish Sadineni<Harish.Sadineni@windriver.com>
>
> The `make rustavailable` process expects the Rust standard library source files (e.g., `lib.rs`)
Help kernel newbies by saying:

The `make rustavailable` process (1) expects the Rust standard library source files (e.g., `lib.rs`)


and then in the footer:

1) See the kernel tree for Documentation/rust/quick-start.rst in the section: Requirements: Building

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/rust/quick-start.rst#n145


../Randy

>
> 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 them available in sdk
>
> Signed-off-by: Harish Sadineni<Harish.Sadineni@windriver.com>
> ---
>   meta/recipes-devtools/rust/rust_1.90.0.bb | 17 +++++++++++++++++
>   1 file changed, 17 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..f4cd2b923e 100644
> --- a/meta/recipes-devtools/rust/rust_1.90.0.bb
> +++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
> @@ -63,6 +63,16 @@ do_rust_setup_snapshot () {
>           done
>       fi
>   }
> +
> +do_rust_setup_snapshot:append:class-native () {
> +   if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> +         if [ ! -d "${TMPDIR}/work-shared/rust" ]; then
> +                mkdir -p ${TMPDIR}/work-shared/rust
> +                cp -r ${RUSTSRC}/library ${TMPDIR}/work-shared/rust/.
> +         fi
> +   fi
> +}
> +
>   addtask rust_setup_snapshot after do_unpack before do_configure
>   addtask do_test_compile after do_configure do_rust_gen_targets
>   do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
> @@ -314,6 +324,13 @@ rust_do_install:class-nativesdk() {
>   	export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}"
>   	export CC_$RUST_HOST_CC="${CCACHE}${HOST_PREFIX}gcc"
>   	EOF
> +
> +    if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> +           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
> +    fi
>   }
>   
>   FILES:${PN} += "${base_prefix}/environment-setup.d"
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..f4cd2b923e 100644
--- a/meta/recipes-devtools/rust/rust_1.90.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.90.0.bb
@@ -63,6 +63,16 @@  do_rust_setup_snapshot () {
         done
     fi
 }
+
+do_rust_setup_snapshot:append:class-native () {
+   if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+         if [ ! -d "${TMPDIR}/work-shared/rust" ]; then
+                mkdir -p ${TMPDIR}/work-shared/rust
+                cp -r ${RUSTSRC}/library ${TMPDIR}/work-shared/rust/.
+         fi
+   fi
+}
+
 addtask rust_setup_snapshot after do_unpack before do_configure
 addtask do_test_compile after do_configure do_rust_gen_targets
 do_rust_setup_snapshot[dirs] += "${WORKDIR}/rust-snapshot"
@@ -314,6 +324,13 @@  rust_do_install:class-nativesdk() {
 	export CARGO_TARGET_${RUST_HOST_TRIPLE}_RUNNER="\$OECORE_NATIVE_SYSROOT/lib/${SDKLOADER}"
 	export CC_$RUST_HOST_CC="${CCACHE}${HOST_PREFIX}gcc"
 	EOF
+    
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+           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
+    fi
 }
 
 FILES:${PN} += "${base_prefix}/environment-setup.d"