Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2441e78b authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Michal Marek
Browse files

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: default avatarNicolas Pitre <nico@linaro.org>
Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
parent ba79d401
Loading
Loading
Loading
Loading
+15 −16
Original line number Original line Diff line number Diff line
@@ -926,17 +926,11 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc


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


# Final link of vmlinux
# Include targets which we want to execute sequentially if the rest of the
      cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be
quiet_cmd_link-vmlinux = LINK    $@
# evaluated more than once.

PHONY += vmlinux_prereq
# Include targets which we want to
vmlinux_prereq: $(vmlinux-deps) FORCE
# execute if the rest of the kernel build went well.
vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
ifdef CONFIG_TRIM_UNUSED_KSYMS
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
	  "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile autoksyms_recursive"
endif
ifdef CONFIG_HEADERS_CHECK
ifdef CONFIG_HEADERS_CHECK
	$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
	$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
endif
endif
@@ -946,17 +940,22 @@ endif
ifdef CONFIG_GDB_SCRIPTS
ifdef CONFIG_GDB_SCRIPTS
	$(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py
	$(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py
endif
endif
	+$(call if_changed,link-vmlinux)
ifdef CONFIG_TRIM_UNUSED_KSYMS

autoksyms_recursive: $(vmlinux-deps)
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
	  "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile autoksyms_recursive"
	  "$(MAKE) KBUILD_MODULES=1 -f $(srctree)/Makefile vmlinux_prereq"
PHONY += autoksyms_recursive
endif


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


# Final link of vmlinux
      cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
quiet_cmd_link-vmlinux = LINK    $@

vmlinux: scripts/link-vmlinux.sh vmlinux_prereq FORCE
	+$(call if_changed,link-vmlinux)

# Build samples along the rest of the kernel
# Build samples along the rest of the kernel
ifdef CONFIG_SAMPLES
ifdef CONFIG_SAMPLES
vmlinux-dirs += samples
vmlinux-dirs += samples