Re: [PATCH 2/2] kbuild: Move gen_init_cpio and gen_initramfs.sh to scripts/
From: Thomas Weißschuh
Date: Mon Mar 09 2026 - 09:43:03 EST
On Mon, Mar 09, 2026 at 08:56:30AM +0100, Nicolas Schier wrote:
> get_init_cpio and gen_initramfs.sh are part of kbuild and required for
"gen_init_cpio"
> all kernel builds. Move it to scripts/ to be more clear about their
> importance.
As far as I can see, gen_init_cpio is currently only built and used if
CONFIG_BLK_DEV_INITRD is enabled. So "required for all kernel builds"
sounds wrong.
This on-demand build can probably be preserved like this:
hostprogs += gen_init_cpio
always-$(CONFIG_BLK_DEV_INITRD) += gen_init_cpio
> Link: https://lore.kernel.org/all/aSdrCFkUQup3qb-q@xxxxxxxxxxxxxxxx/
> Signed-off-by: Nicolas Schier <nsc@xxxxxxxxxx>
> ---
>
> Nathan, could this go through kbuild-fixes even though it is not really
> a fix? Introducing a top-level Makefile target 'usr_gen_init_cpio'
> in v7.0 and renaming it to 'scripts/gen_init_cpio` in v7.1 doesn't sound
> good to me.
> ---
> MAINTAINERS | 1 +
> Makefile | 10 +++++-----
> scripts/.gitignore | 1 +
> scripts/Makefile | 2 ++
> {usr => scripts}/gen_init_cpio.c | 0
> {usr => scripts}/gen_initramfs.sh | 2 +-
> scripts/remove-stale-files | 2 ++
> usr/.gitignore | 4 +++-
> usr/Makefile | 4 +---
> 9 files changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 55af015174a5..0e374c92941f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13833,6 +13833,7 @@ F: scripts/basic/
> F: scripts/clang-tools/
> F: scripts/container
> F: scripts/dummy-tools/
> +F: scripts/gen_init*
> F: scripts/include/
> F: scripts/install.sh
> F: scripts/mk*
> diff --git a/Makefile b/Makefile
> index 0e788ce45457..7798863002ac 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -296,7 +296,7 @@ no-dot-config-targets := $(clean-targets) \
> $(version_h) headers headers_% archheaders archscripts \
> %asm-generic kernelversion %src-pkg dt_binding_check \
> outputmakefile rustavailable rustfmt rustfmtcheck \
> - usr_gen_init_cpio \
> + scripts/gen_init_cpio \
> run-command
> no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \
> image_name
> @@ -1437,9 +1437,9 @@ 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/gen_init_cpio
> +scripts/gen_init_cpio: scripts_basic
> + $(Q)$(MAKE) $(build)=scripts scripts/gen_init_cpio
The other proxy targets for scripts/ use the 'scripts_' prefix.
Why is this one different?
(...)
> diff --git a/scripts/Makefile b/scripts/Makefile
> index 0941e5ce7b57..039863cd064e 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -52,6 +52,8 @@ ifdef CONFIG_BUILDTIME_MCOUNT_SORT
> HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
> endif
>
> +hostprogs-always-y += gen_init_cpio
> +
> # The following programs are only built on demand
> hostprogs += unifdef gen_packed_field_checks
(...)