Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2441e78

Browse files
Nicolas PitreMichal Marek
authored andcommitted
kbuild: better abstract vmlinux sequential prerequisites
When CONFIG_TRIM_UNUSED_KSYMS=y and CONFIG_BUILD_DOCSRC=y it is possible to get the following error: ERROR: "cn_del_callback" [Documentation/connector/cn_test.ko] undefined! ERROR: "cn_add_callback" [Documentation/connector/cn_test.ko] undefined! ERROR: "cn_netlink_send" [Documentation/connector/cn_test.ko] undefined! ../scripts/Makefile.modpost:91: recipe for target '__modpost' failed It is not sufficient to do "vmlinux-dirs += Documentation" as this also depends on the headers_check target, and all of this needs to be done before adjust_autoksyms.sh is executed. Let's sort this out by gathering those sequential prerequisites in a make target of their own, separate from the vmlinux target. And by doing so, the special autoksyms_recursive target is no longer needed. Signed-off-by: Nicolas Pitre <[email protected]> Acked-by: Randy Dunlap <[email protected]> Tested-by: Randy Dunlap <[email protected]>
1 parent ba79d40 commit 2441e78

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

Makefile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -926,17 +926,11 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc
926926

927927
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
928928

929-
# Final link of vmlinux
930-
cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
931-
quiet_cmd_link-vmlinux = LINK $@
932-
933-
# Include targets which we want to
934-
# execute if the rest of the kernel build went well.
935-
vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
936-
ifdef CONFIG_TRIM_UNUSED_KSYMS
937-
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
938-
"$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile autoksyms_recursive"
939-
endif
929+
# Include targets which we want to execute sequentially if the rest of the
930+
# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be
931+
# evaluated more than once.
932+
PHONY += vmlinux_prereq
933+
vmlinux_prereq: $(vmlinux-deps) FORCE
940934
ifdef CONFIG_HEADERS_CHECK
941935
$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
942936
endif
@@ -946,17 +940,22 @@ endif
946940
ifdef CONFIG_GDB_SCRIPTS
947941
$(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py
948942
endif
949-
+$(call if_changed,link-vmlinux)
950-
951-
autoksyms_recursive: $(vmlinux-deps)
943+
ifdef CONFIG_TRIM_UNUSED_KSYMS
952944
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
953-
"$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile autoksyms_recursive"
954-
PHONY += autoksyms_recursive
945+
"$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq"
946+
endif
955947

956948
# standalone target for easier testing
957949
include/generated/autoksyms.h: FORCE
958950
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh true
959951

952+
# Final link of vmlinux
953+
cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
954+
quiet_cmd_link-vmlinux = LINK $@
955+
956+
vmlinux: scripts/link-vmlinux.sh vmlinux_prereq FORCE
957+
+$(call if_changed,link-vmlinux)
958+
960959
# Build samples along the rest of the kernel
961960
ifdef CONFIG_SAMPLES
962961
vmlinux-dirs += samples

0 commit comments

Comments
 (0)