Skip to content

Commit

Permalink
kbuild: move modules.builtin(.modinfo) rules to Makefile.vmlinux_o
Browse files Browse the repository at this point in the history
Do not build modules.builtin(.modinfo) as a side-effect of vmlinux.

There are no good reason to rebuild them just because any of vmlinux's
prerequistes (vmlinux.lds, .vmlinux.export.c, etc.) has been updated.

Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
masahir0y committed Oct 2, 2022
1 parent 637a642 commit 7a342e6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1153,9 +1153,13 @@ targets += vmlinux.a
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
$(call if_changed,ar_vmlinux.a)

vmlinux.o: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
PHONY += vmlinux_o
vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o

vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o
@:

ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)

# Final link of vmlinux with optional arch pass after final link
Expand Down
26 changes: 25 additions & 1 deletion scripts/Makefile.vmlinux_o
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only

PHONY := __default
__default: vmlinux.o
__default: vmlinux.o modules.builtin.modinfo modules.builtin

include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
Expand Down Expand Up @@ -62,6 +62,30 @@ vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE

targets += vmlinux.o

# module.builtin.modinfo
# ---------------------------------------------------------------------------

OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary

targets += modules.builtin.modinfo
modules.builtin.modinfo: vmlinux.o FORCE
$(call if_changed,objcopy)

# module.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 prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------

Expand Down
7 changes: 0 additions & 7 deletions scripts/link-vmlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,6 @@ if [ "$1" = "clean" ]; then
exit 0
fi

info MODINFO modules.builtin.modinfo
${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
info GEN modules.builtin
# The second line aids cases where multiple modules share the same object.
tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.file=//p' |
tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.builtin

if is_enabled CONFIG_MODULES; then
${MAKE} -f "${srctree}/scripts/Makefile.vmlinux" .vmlinux.export.o
fi
Expand Down

0 comments on commit 7a342e6

Please sign in to comment.