kbuild: modpost: include .*.cmd files only when targets exist

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 392885ee82 ("kbuild: let fixdep directly write to .*.cmd
files") missed to fix up this file.

Fixes: 392885ee82 ("kbuild: let fixdep directly write to .*.cmd")
Cc: <stable@vger.kernel.org> # v5.0+
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
Masahiro Yamada 2019-07-31 00:58:59 +09:00
parent 5241ab4cf4
commit 944cfe9be1
1 changed files with 2 additions and 4 deletions

View File

@ -145,10 +145,8 @@ FORCE:
# optimization, we don't need to read them if the target does not # optimization, we don't need to read them if the target does not
# exist, we will rebuild anyway in that case. # 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 $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
include $(cmd_files)
endif
.PHONY: $(PHONY) .PHONY: $(PHONY)