]> www.infradead.org Git - users/willy/xarray.git/commitdiff
kbuild: apply fixdep logic to link-vmlinux.sh
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Fri, 5 Mar 2021 10:02:12 +0000 (11:02 +0100)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 24 Apr 2021 20:12:32 +0000 (05:12 +0900)
The patch adding CONFIG_VMLINUX_MAP revealed a small defect in the
build system: link-vmlinux.sh takes decisions based on CONFIG_*
options, but changing one of those does not always lead to vmlinux
being linked again.

For most of the CONFIG_* knobs referenced previously, this has
probably been hidden by those knobs also affecting some object file,
hence indirectly also vmlinux.

But CONFIG_VMLINUX_MAP is only handled inside link-vmlinux.sh, and
changing CONFIG_VMLINUX_MAP=n to CONFIG_VMLINUX_MAP=y does not cause
the build system to re-link (and hence have vmlinux.map
emitted). Since that map file is mostly a debugging aid, this is
merely a nuisance which is easily worked around by just deleting
vmlinux and building again.

But one could imagine other (possibly future) CONFIG options that
actually do affect the vmlinux binary but which are not captured
through some object file dependency.

To fix this, make link-vmlinux.sh emit a .vmlinux.d file in the same
format as the dependency files generated by gcc, and apply the fixdep
logic to that. I've tested that this correctly works with both in-tree
and out-of-tree builds.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Makefile
scripts/link-vmlinux.sh

index 80c82155ebb6f527cf074e1ff4c37718d9e827fb..03e3ee982f14cf298a25ae8a86b20fe422b5e016 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1213,7 +1213,7 @@ cmd_link-vmlinux =                                                 \
        $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
-       +$(call if_changed,link-vmlinux)
+       +$(call if_changed_dep,link-vmlinux)
 
 targets := vmlinux
 
index 855fd4e6f03e6b80f9bfbd8c41d805facdfa81ac..e9516bdfcc6fa6fb3a49a8de649bc413c64645e3 100755 (executable)
@@ -312,6 +312,7 @@ cleanup()
        rm -f vmlinux
        rm -f vmlinux.map
        rm -f vmlinux.o
+       rm -f .vmlinux.d
 }
 
 on_exit()
@@ -449,3 +450,6 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
                exit 1
        fi
 fi
+
+# For fixdep
+echo "vmlinux: $0" > .vmlinux.d