]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
kbuild: move vmlinux.o rule to the top Makefile
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 24 Sep 2022 18:19:12 +0000 (03:19 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 28 Sep 2022 19:42:34 +0000 (04:42 +0900)
Move the build rules of vmlinux.o out of scripts/link-vmlinux.sh to
clearly separate 1) pre-modpost, 2) modpost, 3) post-modpost stages.
This will make further refactoring possible.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Makefile
scripts/link-vmlinux.sh

index dac4ca2b900cb5521940e512b63b0090402efcda..21c41a03d98d07c75bae2d0ae46c85710b86f337 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1118,8 +1118,6 @@ endif
 export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 
-vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
-
 # Recurse until adjust_autoksyms.sh is satisfied
 PHONY += autoksyms_recursive
 ifdef CONFIG_TRIM_UNUSED_KSYMS
@@ -1142,6 +1140,9 @@ quiet_cmd_autoksyms_h = GEN     $@
 $(autoksyms_h):
        $(call cmd,autoksyms_h)
 
+vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
+
 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
 
 # Final link of vmlinux with optional arch pass after final link
@@ -1149,14 +1150,14 @@ cmd_link-vmlinux =                                                 \
        $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)";    \
        $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
-vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
+vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
        +$(call if_changed_dep,link-vmlinux)
 
 targets := vmlinux
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
-$(sort $(vmlinux-deps)): . ;
+$(sort $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)): . ;
 
 filechk_kernel.release = \
        echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
index 161bca64e8aac374dece369f79e0ac093d67fc6b..07486f90d5e232664b4b5dc0af2acd94dc34ea0d 100755 (executable)
@@ -214,9 +214,6 @@ if [ "$1" = "clean" ]; then
        exit 0
 fi
 
-#link vmlinux.o
-${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
-
 # modpost vmlinux.o to check for section mismatches
 ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1