Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Fix fixdep dependencies

The tools version of fixdep has broken dependencies. It doesn't get
rebuilt if the host compiler or headers change.

Build fixdep with the tools kbuild infrastructure, so fixdep runs on
itself. Due to the recursive dependency, its dependency file is
incomplete the very first time it gets built. In that case build it a
second time to achieve fixdep inception.

Reported-by: Arthur Marsh <arthur.marsh@internode.on.net>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+23 -2
+2
tools/build/Build
··· 1 + hostprogs := fixdep 2 + fixdep-y := fixdep.o
+21 -2
tools/build/Makefile
··· 37 37 $(Q)$(MAKE) -C feature OUTPUT=$(TMP_O) clean >/dev/null 38 38 endif 39 39 40 - $(OUTPUT)fixdep: $(srctree)/tools/build/fixdep.c 41 - $(QUIET_CC)$(HOSTCC) $(KBUILD_HOSTCFLAGS) $(KBUILD_HOSTLDFLAGS) -o $@ $< 40 + include $(srctree)/tools/build/Makefile.include 41 + 42 + FIXDEP := $(OUTPUT)fixdep 43 + FIXDEP_IN := $(OUTPUT)fixdep-in.o 44 + 45 + # To track fixdep's dependencies properly, fixdep needs to run on itself. 46 + # Build it twice the first time. 47 + $(FIXDEP_IN): FORCE 48 + $(Q)if [ ! -f $(FIXDEP) ]; then \ 49 + $(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)"; \ 50 + rm -f $(FIXDEP).o; \ 51 + fi 52 + $(Q)$(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)" 53 + 54 + 55 + $(FIXDEP): $(FIXDEP_IN) 56 + $(QUIET_LINK)$(HOSTCC) $(FIXDEP_IN) $(KBUILD_HOSTLDFLAGS) -o $@ 57 + 58 + FORCE: 59 + 60 + .PHONY: FORCE