Skip to content

Commit 426fb6c

Browse files
committed
kbuild: warn if FORCE is missing for if_changed(_dep,_rule) and filechk
JIRA: https://issues.redhat.com/browse/RHEL-2773 commit e1f86d7 Author: Masahiro Yamada <masahiroy@kernel.org> Date: Fri Aug 13 15:30:05 2021 +0900 kbuild: warn if FORCE is missing for if_changed(_dep,_rule) and filechk if_changed, if_changed_dep, and if_changed_rule must have FORCE as a prerequisite so the command line change is detected. Documentation/kbuild/makefiles.rst clearly explains it: Note: It is a typical mistake to forget the FORCE prerequisite. However, not all people follow the document. This mistake occurred again and again, so a compelling force is needed. Show a warning if FORCE is missing in the prerequisite of if_changed and friends. Same for filechk. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Nicolas Schier <n.schier@avm.de> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
1 parent 3dae6ff commit 426fb6c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/Kbuild.include

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ kecho := $($(quiet)kecho)
7373
# - If the content differ the new file is used
7474
# - If they are equal no change, and no timestamp update
7575
define filechk
76+
$(check-FORCE)
7677
$(Q)set -e; \
7778
mkdir -p $(dir $@); \
7879
trap "rm -f $(dot-target).tmp" EXIT; \
@@ -146,7 +147,11 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))
146147
# PHONY targets skipped in both cases.
147148
newer-prereqs = $(filter-out $(PHONY),$?)
148149

149-
if-changed-cond = $(newer-prereqs)$(cmd-check)
150+
# It is a typical mistake to forget the FORCE prerequisite. Check it here so
151+
# no more breakage will slip in.
152+
check-FORCE = $(if $(filter FORCE, $^),,$(warning FORCE prerequisite is missing))
153+
154+
if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE)
150155

151156
# Execute command if command has changed or prerequisite(s) are updated.
152157
if_changed = $(if $(if-changed-cond), \

0 commit comments

Comments
 (0)