Re: [PATCH v4 12/14] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds

From: Namhyung Kim

Date: Fri May 15 2026 - 15:56:14 EST


On Fri, May 15, 2026 at 10:38:49AM -0700, Ian Rogers wrote:
> In Makefile.perf, ALL_PROGRAMS includes SCRIPTS (perf-archive,
> perf-iostat). However, unlike PROGRAMS and DLFILTERS, SCRIPTS was not
> prefixed with $(OUTPUT).

Looks like a bug.

Thanks,
Namhyung

>
> During out-of-tree builds (or when O= is specified), Make checked for the
> unprefixed target 'tools/perf/perf-archive'. Since the actual script was
> installed into $(OUTPUT)perf-archive, Make concluded the target was
> missing and continuously re-executed the script installation rule on every
> single incremental build.
>
> Prefix SCRIPTS with $(OUTPUT) and update the static pattern rule to ensure
> Kbuild correctly tracks generated script prerequisites during incremental
> builds.
>
> Tested-by: James Clark <james.clark@xxxxxxxxxx>
> Assisted-by: Gemini:gemini-3.1-pro-preview
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/Makefile.perf | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index b8a81c9749a8..fc92d6ceac5b 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -405,7 +405,7 @@ python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT
> # Use the detected configuration
> -include $(OUTPUT).config-detected
>
> -SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
> +SCRIPTS = $(addprefix $(OUTPUT),$(patsubst %.sh,%,$(SCRIPT_SH)))
>
> PROGRAMS += $(OUTPUT)perf
>
> @@ -592,8 +592,8 @@ $(GTK_IN): FORCE prepare
> $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
> $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
>
> -$(SCRIPTS) : % : %.sh
> - $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
> +$(SCRIPTS) : $(OUTPUT)% : %.sh
> + $(QUIET_GEN)$(INSTALL) '$<' '$@'
>
> $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
> $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
> --
> 2.54.0.563.g4f69b47b94-goog
>