diff mbox series

[10/16] kernel-devsrc: copying rust-kernel source to $kerneldir/build

Message ID 20251227113251.773795-11-Harish.Sadineni@windriver.com
State Under Review
Headers show
Series Enable rust support for linux kernel | expand

Commit Message

Harish Sadineni Dec. 27, 2025, 11:32 a.m. UTC
From: Harish Sadineni <Harish.Sadineni@windriver.com>

In sdk while running: 'make prepare' in kernel-source directory after enabling rust config,
it will throw errors since only makefile is present in rust kernel sources.

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

Comments

Bruce Ashfield Dec. 27, 2025, 3:09 p.m. UTC | #1
On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>
> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>
> In sdk while running: 'make prepare' in kernel-source directory after enabling rust config,
> it will throw errors since only makefile is present in rust kernel sources.

Can you show exactly how much of the infrastructure is needed for
make prepare to succeed ? We've gone through a lot of effort over
the years to not copy whole directories, many which have plenty
of source code just like the rust directories do.

If we can just copy the Makefiles and Kbuild files + a few elements
that are needed for regeneration, that is ideal.

Bruce

>
> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> ---
>  meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
> index 23a9093ede..1505a1d70c 100644
> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
> @@ -139,6 +139,10 @@ do_install() {
>          cd ${S}
>
>          cp -a scripts $kerneldir/build
> +
> +        if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
> +            cp -a rust ${kerneldir}/build
> +        fi
>
>          # for v6.1+ (otherwise we are missing multiple default targets)
>          cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
> --
> 2.49.0
>
Harish Sadineni Dec. 29, 2025, 11:25 a.m. UTC | #2
On 12/27/2025 8:39 PM, Bruce Ashfield wrote:
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
>> From: Harish Sadineni <Harish.Sadineni@windriver.com>
>>
>> In sdk while running: 'make prepare' in kernel-source directory after enabling rust config,
>> it will throw errors since only makefile is present in rust kernel sources.
> Can you show exactly how much of the infrastructure is needed for
> make prepare to succeed ? We've gone through a lot of effort over
> the years to not copy whole directories, many which have plenty
> of source code just like the rust directories do.
>
> If we can just copy the Makefiles and Kbuild files + a few elements
> that are needed for regeneration, that is ideal.
Without this patch:

After populating the SDK and sourcing the environment, in the kernel 
source directory I run 'make rustavailable', then 'make scripts',
and enable Rust support (RUST) in the kernel configuration. When running 
'make prepare', the build fails.

The failure is due to missing Rust infrastructure. To understand the 
minimum required set, I attempted to add files incrementally based on 
the reported errors.
This resulted in the following dependency chain:

Initial failure during make prepare:

RUSTC   L rust/core.o
EXPORTS rust/exports_core_generated.h
make[2]: *** No rule to make target 'rust/bindings/bindings_helper.h',
            needed by 'rust/bindings/bindings_generated.rs'.  Stop.

After adding rust/bindings/bindings_helper.h:

make[2]: *** No rule to make target 'rust/bindgen_parameters',
            needed by 'rust/bindings/bindings_generated.rs'.  Stop.

After adding rust/bindgen_parameters:

BINDGEN rust/bindings/bindings_generated.rs
make[2]: *** No rule to make target 'rust/helpers/helpers.c',
            needed by 'rust/bindings/bindings_helpers_generated.rs'. Stop.

After adding rust/helpers/helpers.c, bindgen fails due to additional C 
source dependencies:

rust/helpers/helpers.c:10:10: fatal error: 'auxiliary.c' file not found
rust/helpers/helpers.c:11:10: fatal error: 'blk.c' file not found


At this point, it becomes apparent that make prepare continues to pull 
in further Rust and C source dependencies(chain of dependency is very 
large),
and in practice ends up requiring most of the Rust infrastructure rather 
than just a small set of Makefiles or files.

After applying this patch total size of rust directory  is 1.8MB.
> Bruce
>
>> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
>> ---
>>   meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
>> index 23a9093ede..1505a1d70c 100644
>> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
>> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
>> @@ -139,6 +139,10 @@ do_install() {
>>           cd ${S}
>>
>>           cp -a scripts $kerneldir/build
>> +
>> +        if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
>> +            cp -a rust ${kerneldir}/build
>> +        fi
>>
>>           # for v6.1+ (otherwise we are missing multiple default targets)
>>           cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
>> --
>> 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
Bruce Ashfield Dec. 29, 2025, 12:49 p.m. UTC | #3
On Mon, Dec 29, 2025 at 7:25 AM Harish Sadineni <
Harish.Sadineni@windriver.com> wrote:

>
> On 12/27/2025 8:39 PM, Bruce Ashfield wrote:
> > CAUTION: This email comes from a non Wind River email account!
> > Do not click links or open attachments unless you recognize the sender
> and know the content is safe.
> >
> > On Sat, Dec 27, 2025 at 7:33 AM <Harish.Sadineni@windriver.com> wrote:
> >> From: Harish Sadineni <Harish.Sadineni@windriver.com>
> >>
> >> In sdk while running: 'make prepare' in kernel-source directory after
> enabling rust config,
> >> it will throw errors since only makefile is present in rust kernel
> sources.
> > Can you show exactly how much of the infrastructure is needed for
> > make prepare to succeed ? We've gone through a lot of effort over
> > the years to not copy whole directories, many which have plenty
> > of source code just like the rust directories do.
> >
> > If we can just copy the Makefiles and Kbuild files + a few elements
> > that are needed for regeneration, that is ideal.
> Without this patch:
>
> After populating the SDK and sourcing the environment, in the kernel
> source directory I run 'make rustavailable', then 'make scripts',
> and enable Rust support (RUST) in the kernel configuration. When running
> 'make prepare', the build fails.
>
> The failure is due to missing Rust infrastructure. To understand the
> minimum required set, I attempted to add files incrementally based on
> the reported errors.
> This resulted in the following dependency chain:
>
> Initial failure during make prepare:
>
> RUSTC   L rust/core.o
> EXPORTS rust/exports_core_generated.h
> make[2]: *** No rule to make target 'rust/bindings/bindings_helper.h',
>             needed by 'rust/bindings/bindings_generated.rs'.  Stop.
>
> After adding rust/bindings/bindings_helper.h:
>
> make[2]: *** No rule to make target 'rust/bindgen_parameters',
>             needed by 'rust/bindings/bindings_generated.rs'.  Stop.
>
> After adding rust/bindgen_parameters:
>
> BINDGEN rust/bindings/bindings_generated.rs
> make[2]: *** No rule to make target 'rust/helpers/helpers.c',
>             needed by 'rust/bindings/bindings_helpers_generated.rs'. Stop.
>
> After adding rust/helpers/helpers.c, bindgen fails due to additional C
> source dependencies:
>
> rust/helpers/helpers.c:10:10: fatal error: 'auxiliary.c' file not found
> rust/helpers/helpers.c:11:10: fatal error: 'blk.c' file not found
>
>
Right. This is what I've had to do for the other subsystems and so
far we've mostly avoided large copies.



>
> At this point, it becomes apparent that make prepare continues to pull
> in further Rust and C source dependencies(chain of dependency is very
> large),
> and in practice ends up requiring most of the Rust infrastructure rather
> than just a small set of Makefiles or files.
>
> After applying this patch total size of rust directory  is 1.8MB.
>

If we are making such a relatively large addition, both the commit
message and above the copy in the code .. explain in detail what
the rust directory does / generates during make prepare and what
it provides that a kernel module build requires.

Cheers,

Bruce




> > Bruce
> >
> >> Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
> >> ---
> >>   meta/recipes-kernel/linux/kernel-devsrc.bb | 4 ++++
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb
> b/meta/recipes-kernel/linux/kernel-devsrc.bb
> >> index 23a9093ede..1505a1d70c 100644
> >> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
> >> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
> >> @@ -139,6 +139,10 @@ do_install() {
> >>           cd ${S}
> >>
> >>           cp -a scripts $kerneldir/build
> >> +
> >> +        if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel',
> 'true', 'false', d)}; then
> >> +            cp -a rust ${kerneldir}/build
> >> +        fi
> >>
> >>           # for v6.1+ (otherwise we are missing multiple default
> targets)
> >>           cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :
> >> --
> >> 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/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 23a9093ede..1505a1d70c 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -139,6 +139,10 @@  do_install() {
         cd ${S}
 
         cp -a scripts $kerneldir/build
+        
+        if ${@bb.utils.contains('DISTRO_FEATURES', 'rust-kernel', 'true', 'false', d)}; then
+            cp -a rust ${kerneldir}/build
+        fi
 
         # for v6.1+ (otherwise we are missing multiple default targets)
         cp -a --parents Kbuild $kerneldir/build 2>/dev/null || :