diff mbox series

[RFC,v2,4/8] rust: stage rustlib sources for linux-yocto make rustavailable support

Message ID 20251105130942.833204-5-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>

When building the Linux kernel with Rust support enabled (e.g., via `make rustavailable`),
 the build system expects the Rust standard library sources to be available under:

 ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
 meta/recipes-kernel/linux/linux-yocto.inc | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Bruce Ashfield Nov. 5, 2025, 1:32 p.m. UTC | #1
On Wed, Nov 5, 2025 at 8:10 AM <Harish.Sadineni@windriver.com> wrote:

> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> When building the Linux kernel with Rust support enabled (e.g., via `make
> rustavailable`),
>  the build system expects the Rust standard library sources to be
> available under:
>
>
If that call is happening at configure time (in configme), then it would
better to have
this preparation step in the same location versus separate before do_patch.

Bruce



>  ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust
>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
>  meta/recipes-kernel/linux/linux-yocto.inc | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
> b/meta/recipes-kernel/linux/linux-yocto.inc
> index e2ffd96b59..05219d166e 100644
> --- a/meta/recipes-kernel/linux/linux-yocto.inc
> +++ b/meta/recipes-kernel/linux/linux-yocto.inc
> @@ -71,6 +71,14 @@ do_install:append(){
>                 rm -rf ${STAGING_KERNEL_DIR}/${KMETA}
>         fi
>  }
> +do_patch:append(){
> +       if
> ${@bb.utils.contains('DISTRO_FEATURES','rust-kernel','true','false',d)};
> then
> +               if [ ! -d ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust
> ]; then
> +                       mkdir -p
> ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust/
> +                       cp -r ${TMPDIR}/work-shared/rust
> ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/.
> +               fi
> +        fi
> +}
>
>  # enable kernel-sample for oeqa/runtime/cases's ksample.py test
>  KERNEL_FEATURES:append:qemuall = "
> features/kernel-sample/kernel-sample.scc"
> --
> 2.49.0
>
>
Randy MacLeod Nov. 5, 2025, 5:03 p.m. UTC | #2
On 2025-11-05 8:32 a.m., Bruce Ashfield wrote:
>
>
> On Wed, Nov 5, 2025 at 8:10 AM <Harish.Sadineni@windriver.com> wrote:
>
>     From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
>     When building the Linux kernel with Rust support enabled (e.g.,
>     via `make rustavailable`),
>      the build system expects the Rust standard library sources to be
>     available under:
>
>
> If that call is happening at configure time (in configme), then it 
> would better to have
> this preparation step in the same location versus separate before 
> do_patch.
>
> Bruce
>
>      ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust
>
Don't use /usr/lib directly, pick one of:

❯ rg STAGING_.*NATIVE.*= meta/conf/bitbake.conf
422:STAGING_DIR_NATIVE = "${RECIPE_SYSROOT_NATIVE}"
423:STAGING_BINDIR_NATIVE = "${STAGING_DIR_NATIVE}${bindir_native}"
426:STAGING_LIBDIR_NATIVE = "${STAGING_DIR_NATIVE}${libdir_native}"
427:STAGING_LIBEXECDIR_NATIVE = "${STAGING_DIR_NATIVE}${libexecdir_native}"
428:STAGING_BASE_LIBDIR_NATIVE = 
"${STAGING_DIR_NATIVE}${base_libdir_native}"
429:STAGING_SBINDIR_NATIVE = "${STAGING_DIR_NATIVE}${sbindir_native}"
430:STAGING_INCDIR_NATIVE = "${STAGING_DIR_NATIVE}${includedir_native}"
431:STAGING_ETCDIR_NATIVE = "${STAGING_DIR_NATIVE}${sysconfdir_native}"
432:STAGING_DATADIR_NATIVE = "${STAGING_DIR_NATIVE}${datadir_native}"

657: -ffile-prefix-map=${STAGING_DIR_NATIVE}= \


Same comment anywhere that you have ${VAR}/usr/foo/bar/baz hardcoded.

../Randy



>
>     Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
>     ---
>      meta/recipes-kernel/linux/linux-yocto.inc
>     <https://urldefense.com/v3/__http://linux-yocto.inc__;!!AjveYdw8EvQ!aQ1fra7eKRFm-_YXYz7UyG_3CWtTHXzhxMr5phBTi_YQ46IB27rIgqcyW8RJk9RxCbHBesM2rarbvOLRkywoZ9mfu8xuBA$>
>     | 8 ++++++++
>      1 file changed, 8 insertions(+)
>
>     diff --git a/meta/recipes-kernel/linux/linux-yocto.inc
>     <https://urldefense.com/v3/__http://linux-yocto.inc__;!!AjveYdw8EvQ!aQ1fra7eKRFm-_YXYz7UyG_3CWtTHXzhxMr5phBTi_YQ46IB27rIgqcyW8RJk9RxCbHBesM2rarbvOLRkywoZ9mfu8xuBA$>
>     b/meta/recipes-kernel/linux/linux-yocto.inc
>     <https://urldefense.com/v3/__http://linux-yocto.inc__;!!AjveYdw8EvQ!aQ1fra7eKRFm-_YXYz7UyG_3CWtTHXzhxMr5phBTi_YQ46IB27rIgqcyW8RJk9RxCbHBesM2rarbvOLRkywoZ9mfu8xuBA$>
>     index e2ffd96b59..05219d166e 100644
>     --- a/meta/recipes-kernel/linux/linux-yocto.inc
>     <https://urldefense.com/v3/__http://linux-yocto.inc__;!!AjveYdw8EvQ!aQ1fra7eKRFm-_YXYz7UyG_3CWtTHXzhxMr5phBTi_YQ46IB27rIgqcyW8RJk9RxCbHBesM2rarbvOLRkywoZ9mfu8xuBA$>
>     +++ b/meta/recipes-kernel/linux/linux-yocto.inc
>     <https://urldefense.com/v3/__http://linux-yocto.inc__;!!AjveYdw8EvQ!aQ1fra7eKRFm-_YXYz7UyG_3CWtTHXzhxMr5phBTi_YQ46IB27rIgqcyW8RJk9RxCbHBesM2rarbvOLRkywoZ9mfu8xuBA$>
>     @@ -71,6 +71,14 @@ do_install:append(){
>                     rm -rf ${STAGING_KERNEL_DIR}/${KMETA}
>             fi
>      }
>     +do_patch:append(){
>     +       if
>     ${@bb.utils.contains('DISTRO_FEATURES','rust-kernel','true','false',d)};
>     then
>     +               if [ ! -d
>     ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust ]; then
>     +                       mkdir -p
>     ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust/
>     +                       cp -r ${TMPDIR}/work-shared/rust
>     ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/.
>     +               fi
>     +        fi
>     +}
>
>      # enable kernel-sample for oeqa/runtime/cases's ksample.py
>     <https://urldefense.com/v3/__http://ksample.py__;!!AjveYdw8EvQ!aQ1fra7eKRFm-_YXYz7UyG_3CWtTHXzhxMr5phBTi_YQ46IB27rIgqcyW8RJk9RxCbHBesM2rarbvOLRkywoZ9m53T-LsA$>
>     test
>      KERNEL_FEATURES:append:qemuall = "
>     features/kernel-sample/kernel-sample.scc"
>     -- 
>     2.49.0
>
>
>
> -- 
> - Thou shalt not follow the NULL pointer, for chaos and madness await 
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
>
diff mbox series

Patch

diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc
index e2ffd96b59..05219d166e 100644
--- a/meta/recipes-kernel/linux/linux-yocto.inc
+++ b/meta/recipes-kernel/linux/linux-yocto.inc
@@ -71,6 +71,14 @@  do_install:append(){
 		rm -rf ${STAGING_KERNEL_DIR}/${KMETA}
 	fi
 }
+do_patch:append(){
+       if ${@bb.utils.contains('DISTRO_FEATURES','rust-kernel','true','false',d)}; then
+               if [ ! -d ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust ]; then
+                       mkdir -p ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/rust/
+                       cp -r ${TMPDIR}/work-shared/rust ${STAGING_DIR_NATIVE}/usr/lib/rustlib/src/.
+               fi
+        fi
+}
 
 # enable kernel-sample for oeqa/runtime/cases's ksample.py test
 KERNEL_FEATURES:append:qemuall = " features/kernel-sample/kernel-sample.scc"