[PATCH 1/3] fortify: use if_changed_dep to record header dependency in *.cmd files

From: Masahiro Yamada
Date: Mon Jul 15 2024 - 10:45:54 EST


After building with CONFIG_FORTIFY_SOURCE=y, many .*.d files are left
in lib/test_fortify/ because the compiler outputs header dependencies
into *.d without fixdep being invoked.

When compiling C files, if_changed_dep should be used so that the
auto-generated header dependencies are recorded in .*.cmd files.

Currently, if_changed is incorrectly used, and only two headers are
hard-coded in lib/Makefile.

Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
---

lib/Makefile | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/Makefile b/lib/Makefile
index 30337431d10e..429b259b5b64 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -408,11 +408,9 @@ targets += $(TEST_FORTIFY_LOGS)
clean-files += $(TEST_FORTIFY_LOGS)
clean-files += $(addsuffix .o, $(TEST_FORTIFY_LOGS))
$(obj)/test_fortify/%.log: $(src)/test_fortify/%.c \
- $(src)/test_fortify/test_fortify.h \
- $(srctree)/include/linux/fortify-string.h \
$(srctree)/scripts/test_fortify.sh \
FORCE
- $(call if_changed,test_fortify)
+ $(call if_changed_dep,test_fortify)

quiet_cmd_gen_fortify_log = GEN $@
cmd_gen_fortify_log = cat </dev/null $(filter-out FORCE,$^) 2>/dev/null > $@ || true
--
2.43.0