[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YRtyc1poEhr8YHYp@deb-nschier.ads.avm.de>
Date: Tue, 17 Aug 2021 10:25:23 +0200
From: Nicolas Schier <n.schier@....de>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
Michal Marek <michal.lkml@...kovi.net>
Subject: Re: [PATCH 2/2] kbuild: warn if FORCE is missing for
if_changed(_dep,_rule) and filechk
On Friday, 2021-08-13 Masahiro Yamada wrote:
> 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 read the document, or understand what is written
> in it.
>
> People repeated this mistake over again, and I determined 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@...nel.org>
> ---
>
> scripts/Kbuild.include | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index c3c975a92318..dd48e68965f8 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -57,6 +57,7 @@ kecho := $($(quiet)kecho)
> # - If the content differ the new file is used
> # - If they are equal no change, and no timestamp update
> define filechk
> + $(check-FORCE)
> $(Q)set -e; \
> mkdir -p $(dir $@); \
> trap "rm -f $(dot-target).tmp" EXIT; \
> @@ -130,7 +131,11 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))
> # PHONY targets skipped in both cases.
> newer-prereqs = $(filter-out $(PHONY),$?)
>
> -if-changed-cond = $(newer-prereqs)$(cmd-check)
> +# It is a typical mistake to forget the FORCE prerequisite. Check it here so
prerequsite -> prerequisite?
Successfully found the missing FORCE in arch/x86/entry/vdso/Makefile:135.
Tested-by: Nicolas Schier <n.schier@....de>
> +# no more breakage will slip in.
> +check-FORCE = $(if $(filter FORCE, $^),,$(warning FORCE prerequsite is missing))
> +
> +if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE)
>
> # Execute command if command has changed or prerequisite(s) are updated.
> if_changed = $(if $(if-changed-cond), \
> --
> 2.30.2
>
Powered by blists - more mailing lists