Skip to content

Commit 7a342e6

Browse files
committed
kbuild: move modules.builtin(.modinfo) rules to Makefile.vmlinux_o
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]>
1 parent 637a642 commit 7a342e6

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,13 @@ targets += vmlinux.a
11531153
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
11541154
$(call if_changed,ar_vmlinux.a)
11551155

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

1160+
vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o
1161+
@:
1162+
11591163
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
11601164

11611165
# Final link of vmlinux with optional arch pass after final link

scripts/Makefile.vmlinux_o

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

33
PHONY := __default
4-
__default: vmlinux.o
4+
__default: vmlinux.o modules.builtin.modinfo modules.builtin
55

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

6363
targets += vmlinux.o
6464

65+
# module.builtin.modinfo
66+
# ---------------------------------------------------------------------------
67+
68+
OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
69+
70+
targets += modules.builtin.modinfo
71+
modules.builtin.modinfo: vmlinux.o FORCE
72+
$(call if_changed,objcopy)
73+
74+
# module.builtin
75+
# ---------------------------------------------------------------------------
76+
77+
# The second line aids cases where multiple modules share the same object.
78+
79+
quiet_cmd_modules_builtin = GEN $@
80+
cmd_modules_builtin = \
81+
tr '\0' '\n' < $< | \
82+
sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
83+
tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
84+
85+
targets += modules.builtin
86+
modules.builtin: modules.builtin.modinfo FORCE
87+
$(call if_changed,modules_builtin)
88+
6589
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
6690
# ---------------------------------------------------------------------------
6791

scripts/link-vmlinux.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,6 @@ if [ "$1" = "clean" ]; then
214214
exit 0
215215
fi
216216

217-
info MODINFO modules.builtin.modinfo
218-
${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
219-
info GEN modules.builtin
220-
# The second line aids cases where multiple modules share the same object.
221-
tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.file=//p' |
222-
tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.builtin
223-
224217
if is_enabled CONFIG_MODULES; then
225218
${MAKE} -f "${srctree}/scripts/Makefile.vmlinux" .vmlinux.export.o
226219
fi

0 commit comments

Comments
 (0)