]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools build: Fix fixdep dependencies
authorJosh Poimboeuf <jpoimboe@kernel.org>
Mon, 3 Mar 2025 01:01:42 +0000 (17:01 -0800)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 14 Oct 2025 21:45:20 +0000 (14:45 -0700)
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>
tools/build/Build [new file with mode: 0644]
tools/build/Makefile

diff --git a/tools/build/Build b/tools/build/Build
new file mode 100644 (file)
index 0000000..1c7e598
--- /dev/null
@@ -0,0 +1,2 @@
+hostprogs      := fixdep
+fixdep-y       := fixdep.o
index 63ef2187876169d8daaeed6f7a4ff27e4b610271..a5b3c29b8d70ccf6a6e7eadce6b7140e0eae5b0f 100644 (file)
@@ -37,5 +37,24 @@ ifneq ($(wildcard $(TMP_O)),)
        $(Q)$(MAKE) -C feature OUTPUT=$(TMP_O) clean >/dev/null
 endif
 
-$(OUTPUT)fixdep: $(srctree)/tools/build/fixdep.c
-       $(QUIET_CC)$(HOSTCC) $(KBUILD_HOSTCFLAGS) $(KBUILD_HOSTLDFLAGS) -o $@ $<
+include $(srctree)/tools/build/Makefile.include
+
+FIXDEP         := $(OUTPUT)fixdep
+FIXDEP_IN      := $(OUTPUT)fixdep-in.o
+
+# To track fixdep's dependencies properly, fixdep needs to run on itself.
+# Build it twice the first time.
+$(FIXDEP_IN): FORCE
+       $(Q)if [ ! -f $(FIXDEP) ]; then                                         \
+               $(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)";      \
+               rm -f $(FIXDEP).o;                                              \
+       fi
+       $(Q)$(MAKE) $(build)=fixdep HOSTCFLAGS="$(KBUILD_HOSTCFLAGS)"
+
+
+$(FIXDEP): $(FIXDEP_IN)
+       $(QUIET_LINK)$(HOSTCC) $(FIXDEP_IN) $(KBUILD_HOSTLDFLAGS) -o $@
+
+FORCE:
+
+.PHONY: FORCE