kbuild: modpost: include .*.cmd files only when targets exist
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 30 Jul 2019 15:58:59 +0000 (00:58 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 31 Jul 2019 15:09:49 +0000 (00:09 +0900)
If a build rule fails, the .DELETE_ON_ERROR special target removes the
target, but does nothing for the .*.cmd file, which might be corrupted.
So, .*.cmd files should be included only when the corresponding targets
exist.

Commit 392885ee82d3 ("kbuild: let fixdep directly write to .*.cmd
files") missed to fix up this file.

Fixes: 392885ee82d3 ("kbuild: let fixdep directly write to .*.cmd")
Cc: <stable@vger.kernel.org> # v5.0+
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/Makefile.modpost

index 6b19c1a4eae530e1b00c305575d27173677dada4..ad4b9829a456b57952f69bd2553951f2d91ab94c 100644 (file)
@@ -145,10 +145,8 @@ FORCE:
 # optimization, we don't need to read them if the target does not
 # exist, we will rebuild anyway in that case.
 
-cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
+existing-targets := $(wildcard $(sort $(targets)))
 
-ifneq ($(cmd_files),)
-  include $(cmd_files)
-endif
+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
 
 .PHONY: $(PHONY)