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.
Unified · Split
| @@ -502,7 +502,7 @@ AFLAGS_MODULE = · 501 unmodified lines | |||
| 502 | LDFLAGS_MODULE = | 502 | LDFLAGS_MODULE = |
| 503 | CFLAGS_KERNEL = | 503 | CFLAGS_KERNEL = |
| 504 | AFLAGS_KERNEL = | 504 | AFLAGS_KERNEL = |
| 505 | LDFLAGS_vmlinux = | 505 | export LDFLAGS_vmlinux = |
| 506 | 506 | ||
| 507 | # Use USERINCLUDE when you must reference the UAPI directories only. | 507 | # Use USERINCLUDE when you must reference the UAPI directories only. |
| 508 | USERINCLUDE := \ | 508 | USERINCLUDE := \ |
| @@ -1160,17 +1160,9 @@ vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS) · 651 unmodified lines | |||
| 1160 | vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o | 1160 | vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o |
| 1161 | @: | 1161 | @: |
| 1162 | 1162 | ||
| 1163 | ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) | 1163 | PHONY += vmlinux |
| 1164 | 1164 | vmlinux: vmlinux.o $(KBUILD_LDS) modpost | |
| 1165 | # Final link of vmlinux with optional arch pass after final link | 1165 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux |
| 1166 | cmd_link-vmlinux = \ | ||
| 1167 | $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ | ||
| 1168 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) | ||
| 1169 | |||
| 1170 | vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE | ||
| 1171 | +$(call if_changed_dep,link-vmlinux) | ||
| 1172 | |||
| 1173 | targets += vmlinux | ||
| 1174 | 1166 | ||
| 1175 | # The actual objects are generated when descending, | 1167 | # The actual objects are generated when descending, |
| 1176 | # make sure no implicit rule kicks in | 1168 | # make sure no implicit rule kicks in |
| @@ -1501,7 +1493,7 @@ endif # CONFIG_MODULES · 324 unmodified lines | |||
| 1501 | # Directories & files removed with 'make clean' | 1493 | # Directories & files removed with 'make clean' |
| 1502 | CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ | 1494 | CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ |
| 1503 | modules.builtin modules.builtin.modinfo modules.nsdeps \ | 1495 | modules.builtin modules.builtin.modinfo modules.nsdeps \ |
| 1504 | compile_commands.json .thinlto-cache .vmlinux.objs | 1496 | compile_commands.json .thinlto-cache .vmlinux.objs .vmlinux.export.c |
| 1505 | 1497 | ||
| 1506 | # Directories & files removed with 'make mrproper' | 1498 | # Directories & files removed with 'make mrproper' |
| 1507 | MRPROPER_FILES += include/config include/generated \ | 1499 | MRPROPER_FILES += include/config include/generated \ |
| @@ -1,18 +1,37 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0-only | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | 2 | ||
| 3 | PHONY := __default | ||
| 4 | __default: vmlinux | ||
| 5 | |||
| 3 | include include/config/auto.conf | 6 | include include/config/auto.conf |
| 4 | include $(srctree)/scripts/Kbuild.include | 7 | include $(srctree)/scripts/Kbuild.include |
| 5 | 8 | ||
| 6 | # for c_flags | 9 | # for c_flags |
| 7 | include $(srctree)/scripts/Makefile.lib | 10 | include $(srctree)/scripts/Makefile.lib |
| 8 | 11 | ||
| 12 | targets := | ||
| 13 | |||
| 9 | quiet_cmd_cc_o_c = CC $@ | 14 | quiet_cmd_cc_o_c = CC $@ |
| 10 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | 15 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
| 11 | 16 | ||
| 12 | %.o: %.c FORCE | 17 | %.o: %.c FORCE |
| 13 | $(call if_changed_dep,cc_o_c) | 18 | $(call if_changed_dep,cc_o_c) |
| 14 | 19 | ||
| 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) | ||
| 16 | 35 | ||
| 17 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. | 36 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. |
| 18 | # --------------------------------------------------------------------------- | 37 | # --------------------------------------------------------------------------- |
| @@ -199,7 +199,6 @@ cleanup() · 198 unmodified lines | |||
| 199 | rm -f System.map | 199 | rm -f System.map |
| 200 | rm -f vmlinux | 200 | rm -f vmlinux |
| 201 | rm -f vmlinux.map | 201 | rm -f vmlinux.map |
| 202 | rm -f .vmlinux.export.c | ||
| 203 | } | 202 | } |
| 204 | 203 | ||
| 205 | # Use "make V=1" to debug this script | 204 | # Use "make V=1" to debug this script |
| @@ -214,10 +213,6 @@ if [ "$1" = "clean" ]; then · 8 unmodified lines | |||
| 214 | exit 0 | 213 | exit 0 |
| 215 | fi | 214 | fi |
| 216 | 215 | ||
| 217 | if is_enabled CONFIG_MODULES; then | ||
| 218 | ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux" .vmlinux.export.o | ||
| 219 | fi | ||
| 220 | |||
| 221 | ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init init/version-timestamp.o | 216 | ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init init/version-timestamp.o |
| 222 | 217 | ||
| 223 | btf_vmlinux_bin_o="" | 218 | btf_vmlinux_bin_o="" |