[PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped

Masahiro Yamada posted 4 patches 6 months, 2 weeks ago
[PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
Posted by Masahiro Yamada 6 months, 2 weeks ago
Currently, we assume all the data for modules.builtin.modinfo are
available in vmlinux.o.

This makes it impossible for modpost, which is invoked after vmlinux.o,
to add additional module info.

This commit moves the modules.builtin.modinfo rule after modpost.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.vmlinux   | 28 +++++++++++++++++++++++++++-
 scripts/Makefile.vmlinux_o | 26 +-------------------------
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
index e2ceeb9e168d..45597068f11f 100644
--- a/scripts/Makefile.vmlinux
+++ b/scripts/Makefile.vmlinux
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 PHONY := __default
-__default: vmlinux
+__default:
 
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
@@ -96,6 +96,32 @@ targets += vmlinux
 vmlinux: vmlinux.unstripped FORCE
 	$(call if_changed,strip_relocs)
 
+# modules.builtin.modinfo
+# ---------------------------------------------------------------------------
+
+OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
+
+targets += modules.builtin.modinfo
+modules.builtin.modinfo: vmlinux.unstripped FORCE
+	$(call if_changed,objcopy)
+
+# modules.builtin
+# ---------------------------------------------------------------------------
+
+__default: modules.builtin
+
+# The second line aids cases where multiple modules share the same object.
+
+quiet_cmd_modules_builtin = GEN     $@
+      cmd_modules_builtin = \
+	tr '\0' '\n' < $< | \
+	sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
+	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
+
+targets += modules.builtin
+modules.builtin: modules.builtin.modinfo FORCE
+	$(call if_changed,modules_builtin)
+
 # modules.builtin.ranges
 # ---------------------------------------------------------------------------
 ifdef CONFIG_BUILTIN_MODULE_RANGES
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index b024ffb3e201..23c8751285d7 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 PHONY := __default
-__default: vmlinux.o modules.builtin.modinfo modules.builtin
+__default: vmlinux.o
 
 include include/config/auto.conf
 include $(srctree)/scripts/Kbuild.include
@@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 
 targets += vmlinux.o
 
-# modules.builtin.modinfo
-# ---------------------------------------------------------------------------
-
-OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
-
-targets += modules.builtin.modinfo
-modules.builtin.modinfo: vmlinux.o FORCE
-	$(call if_changed,objcopy)
-
-# modules.builtin
-# ---------------------------------------------------------------------------
-
-# The second line aids cases where multiple modules share the same object.
-
-quiet_cmd_modules_builtin = GEN     $@
-      cmd_modules_builtin = \
-	tr '\0' '\n' < $< | \
-	sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
-	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
-
-targets += modules.builtin
-modules.builtin: modules.builtin.modinfo FORCE
-	$(call if_changed,modules_builtin)
-
 # Add FORCE to the prerequisites of a target to force it to be always rebuilt.
 # ---------------------------------------------------------------------------
 
-- 
2.43.0
Re: [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
Posted by Alexey Gladkov 6 months, 1 week ago
On Fri, Jun 06, 2025 at 01:10:26PM +0900, Masahiro Yamada wrote:
> Currently, we assume all the data for modules.builtin.modinfo are
> available in vmlinux.o.
> 
> This makes it impossible for modpost, which is invoked after vmlinux.o,
> to add additional module info.
> 
> This commit moves the modules.builtin.modinfo rule after modpost.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/Makefile.vmlinux   | 28 +++++++++++++++++++++++++++-
>  scripts/Makefile.vmlinux_o | 26 +-------------------------
>  2 files changed, 28 insertions(+), 26 deletions(-)
> 
> diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
> index e2ceeb9e168d..45597068f11f 100644
> --- a/scripts/Makefile.vmlinux
> +++ b/scripts/Makefile.vmlinux
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
>  PHONY := __default
> -__default: vmlinux
> +__default:

I found the problem. The problem I was talking about earlier [1] is caused
by this hunk. If I revert it, everything will work.

[1] https://lore.kernel.org/all/aEWhwur_W6UwDsx_@example.org/

>  include include/config/auto.conf
>  include $(srctree)/scripts/Kbuild.include
> @@ -96,6 +96,32 @@ targets += vmlinux
>  vmlinux: vmlinux.unstripped FORCE
>  	$(call if_changed,strip_relocs)
>  
> +# modules.builtin.modinfo
> +# ---------------------------------------------------------------------------
> +
> +OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
> +
> +targets += modules.builtin.modinfo
> +modules.builtin.modinfo: vmlinux.unstripped FORCE
> +	$(call if_changed,objcopy)
> +
> +# modules.builtin
> +# ---------------------------------------------------------------------------
> +
> +__default: modules.builtin
> +
> +# The second line aids cases where multiple modules share the same object.
> +
> +quiet_cmd_modules_builtin = GEN     $@
> +      cmd_modules_builtin = \
> +	tr '\0' '\n' < $< | \
> +	sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
> +	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
> +
> +targets += modules.builtin
> +modules.builtin: modules.builtin.modinfo FORCE
> +	$(call if_changed,modules_builtin)
> +
>  # modules.builtin.ranges
>  # ---------------------------------------------------------------------------
>  ifdef CONFIG_BUILTIN_MODULE_RANGES
> diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
> index b024ffb3e201..23c8751285d7 100644
> --- a/scripts/Makefile.vmlinux_o
> +++ b/scripts/Makefile.vmlinux_o
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
>  PHONY := __default
> -__default: vmlinux.o modules.builtin.modinfo modules.builtin
> +__default: vmlinux.o
>  
>  include include/config/auto.conf
>  include $(srctree)/scripts/Kbuild.include
> @@ -73,30 +73,6 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
>  
>  targets += vmlinux.o
>  
> -# modules.builtin.modinfo
> -# ---------------------------------------------------------------------------
> -
> -OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
> -
> -targets += modules.builtin.modinfo
> -modules.builtin.modinfo: vmlinux.o FORCE
> -	$(call if_changed,objcopy)
> -
> -# modules.builtin
> -# ---------------------------------------------------------------------------
> -
> -# The second line aids cases where multiple modules share the same object.
> -
> -quiet_cmd_modules_builtin = GEN     $@
> -      cmd_modules_builtin = \
> -	tr '\0' '\n' < $< | \
> -	sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
> -	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
> -
> -targets += modules.builtin
> -modules.builtin: modules.builtin.modinfo FORCE
> -	$(call if_changed,modules_builtin)
> -
>  # Add FORCE to the prerequisites of a target to force it to be always rebuilt.
>  # ---------------------------------------------------------------------------
>  
> -- 
> 2.43.0
> 

-- 
Rgrds, legion
Re: [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
Posted by kernel test robot 6 months, 2 weeks ago
Hi Masahiro,

kernel test robot noticed the following build errors:

[auto build test ERROR on masahiroy-kbuild/for-next]
[also build test ERROR on masahiroy-kbuild/fixes linus/master v6.15 next-20250606]
[cannot apply to herbert-cryptodev-2.6/master herbert-crypto-2.6/master arnd-asm-generic/master mcgrof/modules-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Masahiro-Yamada/module-remove-meaningless-name-parameter-from-__MODULE_INFO/20250606-121255
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
patch link:    https://lore.kernel.org/r/20250606041029.614348-5-masahiroy%40kernel.org
patch subject: [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-buildonly-randconfig-004-20250606 (https://download.01.org/0day-ci/archive/20250606/202506061718.9bJ7PyNy-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250606/202506061718.9bJ7PyNy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202506061718.9bJ7PyNy-lkp@intel.com/

All errors (new ones prefixed by >>):

>> make[4]: *** No rule to make target 'vmlinux', needed by 'arch/x86/boot/compressed/vmlinux.bin'.
   make[4]: Target 'arch/x86/boot/compressed/vmlinux' not remade because of errors.

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki