Re: [PATCH v2] tools: Restore built-in rules for subdirectory tool compilation

"Rafael J. Wysocki" <[email protected]> Wed, 2 Apr 2025 12:06:48 +0200
Newsgroups gmane.linux.acpi.devel,gmane.linux.kernel.firewire.devel,gmane.linux.kernel
Message-ID <CAJZ5v0h2w8sSer1rWMRKh10QwhXSXW6j_ePTm7CEY=4n7nJWhg@mail.gmail.com>
On Wed, Apr 2, 2025 at 9:54 AM Riwen Lu <[email protected]> wrote:
>
> Prior to commit d1d096312176 ("tools: fix annoying "mkdir -p ..." logs
> when building tools in parallel"), the top-level MAKEFLAGS=-rR
> (disabling built-in rules/variables) was overridden by
> subdirectory-specific MAKEFLAGS during tools compilation. This allowed
> tools like pfrut and firewire to implicitly rely on Make's built-in rules.
>
> After the aforementioned commit, the -rR flags from the top-level
> Makefile began propagating to subdirectory builds. This broke tools
> depending on implicit rules because:
> 1. -r (--no-builtin-rules) disabled implicit .c -> .o rules
> 2. -R (--no-builtin-variables) hid critical implicit variables like CC
>
> Fix this by filtering out -rR from MAKEFLAGS.
>
> Fixes: d1d096312176 ("tools: fix annoying "mkdir -p ..." logs when building tools in parallel")

It would be good to CC the author of the above commit (added).

> Reported-by: k2ci <[email protected]>
> Signed-off-by: Riwen Lu <[email protected]>
> ---
>  Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d138b17b8840..abf9cfebaf4f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1431,11 +1431,11 @@ endif
>
>  tools/: FORCE
>         $(Q)mkdir -p $(objtree)/tools
> -       $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
> +       $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
>
>  tools/%: FORCE
>         $(Q)mkdir -p $(objtree)/tools
> -       $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
> +       $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter-out rR,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
>
>  # ---------------------------------------------------------------------------
>  # Kernel selftest
> --