History

kbuild: rebuild .vmlinux.export.o when its prerequisite is updated

When include/linux/export-internal.h is updated, .vmlinux.export.o must be rebuilt, but it does not happen because its rule is hidden behind scripts/link-vmlinux.sh. Move it out of the shell script, so that Make can see the dependency between vmlinux and .vmlinux.export.o. Move the vmlinux rule to scripts/Makefile.vmlinux.

Masahiro Yamada committed 4 years ago

Commit 5d4aeff1 parent 7a342e63 files · +25 −19Browse files

Showing the changes to scripts (2 of 3 files). Show all

Unified · Split

2 files
  1. scripts/Makefile.vmlinux +20 −1
  2. scripts/link-vmlinux.sh +0 −5
scripts/Makefile.vmlinux+20−1
@@ -1,18 +1,37 @@
11 # SPDX-License-Identifier: GPL-2.0-only
22
3+PHONY := __default
4+__default: vmlinux
5+
36 include include/config/auto.conf
47 include $(srctree)/scripts/Kbuild.include
58
69 # for c_flags
710 include $(srctree)/scripts/Makefile.lib
811
12+targets :=
13+
914 quiet_cmd_cc_o_c = CC $@
1015 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
1116
1217 %.o: %.c FORCE
1318 $(call if_changed_dep,cc_o_c)
1419
15−targets := $(MAKECMDGOALS)
20+ifdef CONFIG_MODULES
21+targets += .vmlinux.export.o
22+vmlinux: .vmlinux.export.o
23+endif
24+
25+ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
26+
27+# Final link of vmlinux with optional arch pass after final link
28+cmd_link_vmlinux = \
29+ $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
30+ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
31+
32+targets += vmlinux
33+vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
34+ +$(call if_changed_dep,link_vmlinux)
1635
1736 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
1837 # ---------------------------------------------------------------------------
scripts/link-vmlinux.sh+0−5
@@ -199,7 +199,6 @@ cleanup() · 198 unmodified lines
199199 rm -f System.map
200200 rm -f vmlinux
201201 rm -f vmlinux.map
202− rm -f .vmlinux.export.c
203202 }
204203
205204 # Use "make V=1" to debug this script
@@ -214,10 +213,6 @@ if [ "$1" = "clean" ]; then · 8 unmodified lines
214213 exit 0
215214 fi
216215
217−if is_enabled CONFIG_MODULES; then
218− ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux" .vmlinux.export.o
219−fi
220−
221216 ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init init/version-timestamp.o
222217
223218 btf_vmlinux_bin_o=""