[PATCH] kbuild: Add top-level target for building gen_init_cpio

Nicolas Schier posted 1 patch 2 months, 1 week ago
Makefile                 | 6 ++++++
scripts/Makefile.package | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)
[PATCH] kbuild: Add top-level target for building gen_init_cpio
Posted by Nicolas Schier 2 months, 1 week ago
Add a top-level target for building gen_init_cpio to prevent re-entering
kbuild for 'modules-cpio-pkg'.

The recently introduced target 'modules-cpio-pkg' depends on
gen_init_cpio but there is no simple way to add this dependency as a
prerequisite that can be built in parallel to other recipes.

Introducing the top-level target, enables fixing this and also prepares
a possible move of gen_init_cpio from usr/ to scripts/.

Signed-off-by: Nicolas Schier <nsc@kernel.org>
---
This is based on the patch set from
https://lore.kernel.org/linux-kbuild/20251125-cpio-modules-pkg-v2-0-aa8277d89682@pengutronix.de
---
 Makefile                 | 6 ++++++
 scripts/Makefile.package | 1 -
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 17cfa11ca716..d5750e5bd633 100644
--- a/Makefile
+++ b/Makefile
@@ -1383,6 +1383,10 @@ ifdef CONFIG_HEADERS_INSTALL
 prepare: headers
 endif
 
+PHONY += usr_gen_init_cpio
+usr_gen_init_cpio: scripts_basic
+	$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
+
 PHONY += scripts_unifdef
 scripts_unifdef: scripts_basic
 	$(Q)$(MAKE) $(build)=scripts scripts/unifdef
@@ -1635,6 +1639,8 @@ distclean: mrproper
 # Packaging of the kernel to various formats
 # ---------------------------------------------------------------------------
 
+modules-cpio-pkg: usr_gen_init_cpio
+
 %src-pkg: FORCE
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
 %pkg: include/config/kernel.release FORCE
diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 83bfcf7cb09f..0ec946f9b905 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -201,7 +201,6 @@ quiet_cmd_cpio = CPIO    $@
       cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
 
 modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio
-	$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
 	$(call cmd,cpio)
 
 PHONY += modules-cpio-pkg

---
base-commit: cb6649f6217c0331b885cf787f1d175963e2a1d2
change-id: 20251128-kbuild-add-top-level-target-for-building-gen_init_cpio-6401e0ee0710
prerequisite-message-id: 20251125-cpio-modules-pkg-v2-0-aa8277d89682@pengutronix.de
prerequisite-patch-id: 9132e567c46357daaf2bd728ff18bfda1c51a9cb
prerequisite-patch-id: 0dfe03db654169d314d3baaba8536a9bfc9bcc70

Best regards,
-- 
Nicolas
Re: [PATCH] kbuild: Add top-level target for building gen_init_cpio
Posted by Nathan Chancellor 1 month, 3 weeks ago
On Fri, 28 Nov 2025 21:01:55 +0100, Nicolas Schier wrote:
> Add a top-level target for building gen_init_cpio to prevent re-entering
> kbuild for 'modules-cpio-pkg'.
> 
> The recently introduced target 'modules-cpio-pkg' depends on
> gen_init_cpio but there is no simple way to add this dependency as a
> prerequisite that can be built in parallel to other recipes.
> 
> [...]

Applied to

  https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next

Thanks!

[1/1] kbuild: Add top-level target for building gen_init_cpio
      https://git.kernel.org/kbuild/c/f8e05c10631e6

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped or
reverted.

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>
Re: [PATCH] kbuild: Add top-level target for building gen_init_cpio
Posted by Nathan Chancellor 2 months, 1 week ago
On Fri, Nov 28, 2025 at 09:01:55PM +0100, Nicolas Schier wrote:
> Add a top-level target for building gen_init_cpio to prevent re-entering
> kbuild for 'modules-cpio-pkg'.
> 
> The recently introduced target 'modules-cpio-pkg' depends on
> gen_init_cpio but there is no simple way to add this dependency as a
> prerequisite that can be built in parallel to other recipes.
> 
> Introducing the top-level target, enables fixing this and also prepares
> a possible move of gen_init_cpio from usr/ to scripts/.
> 
> Signed-off-by: Nicolas Schier <nsc@kernel.org>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

Do you want to take this for a late 6.19 features pull request or should
I pick it up during the 6.20 cycle?

> ---
>  Makefile                 | 6 ++++++
>  scripts/Makefile.package | 1 -
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 17cfa11ca716..d5750e5bd633 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1383,6 +1383,10 @@ ifdef CONFIG_HEADERS_INSTALL
>  prepare: headers
>  endif
>  
> +PHONY += usr_gen_init_cpio
> +usr_gen_init_cpio: scripts_basic
> +	$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
> +
>  PHONY += scripts_unifdef
>  scripts_unifdef: scripts_basic
>  	$(Q)$(MAKE) $(build)=scripts scripts/unifdef
> @@ -1635,6 +1639,8 @@ distclean: mrproper
>  # Packaging of the kernel to various formats
>  # ---------------------------------------------------------------------------
>  
> +modules-cpio-pkg: usr_gen_init_cpio
> +
>  %src-pkg: FORCE
>  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
>  %pkg: include/config/kernel.release FORCE
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 83bfcf7cb09f..0ec946f9b905 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -201,7 +201,6 @@ quiet_cmd_cpio = CPIO    $@
>        cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $<
>  
>  modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio
> -	$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
>  	$(call cmd,cpio)
>  
>  PHONY += modules-cpio-pkg
> 
> ---
> base-commit: cb6649f6217c0331b885cf787f1d175963e2a1d2
> change-id: 20251128-kbuild-add-top-level-target-for-building-gen_init_cpio-6401e0ee0710
> prerequisite-message-id: 20251125-cpio-modules-pkg-v2-0-aa8277d89682@pengutronix.de
> prerequisite-patch-id: 9132e567c46357daaf2bd728ff18bfda1c51a9cb
> prerequisite-patch-id: 0dfe03db654169d314d3baaba8536a9bfc9bcc70
> 
> Best regards,
> -- 
> Nicolas
>