Re: [PATCH] perf build: prevent "argument list too long" error

From: Arnaldo Carvalho de Melo

Date: Wed Mar 04 2026 - 09:25:16 EST


On Tue, Mar 03, 2026 at 01:15:01PM -0800, Markus Mayer wrote:
> Due to a recent change, building perf may result in a build error when
> it is trying to "prune orphans". The file list passed to "rm" may exceed
> what the shell can handle. The build will then abort with an error like
> this:
>
> TEST [...]/arm64/build/linux-custom/tools/perf/pmu-events/metric_test.log
> make[5]: /bin/sh: Argument list too long
> make[5]: *** [pmu-events/Build:217: prune_orphans] Error 127
> make[5]: *** Waiting for unfinished jobs....
> make[4]: *** [Makefile.perf:773: [...]/tools/perf/pmu-events/pmu-events-in.o] Error 2
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [Makefile.perf:289: sub-make] Error 2
>
> Processing the arguments via "xargs", instead of passing the list of
> files directly to "rm" via the shell, prevents this issue.
>
> Fixes: 36a1b0061a5 (perf build: Reduce pmu-events related copying and mkdirs)
> Signed-off-by: Markus Mayer <mmayer@xxxxxxxxxxxx>

Thanks, applied to perf-tools, for v7.0.

- Arnaldo

> ---
> tools/perf/pmu-events/Build | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
> index 63c65788d442..dc5f94862a3b 100644
> --- a/tools/perf/pmu-events/Build
> +++ b/tools/perf/pmu-events/Build
> @@ -214,7 +214,8 @@ ifneq ($(strip $(ORPHAN_FILES)),)
> quiet_cmd_rm = RM $^
>
> prune_orphans: $(ORPHAN_FILES)
> - $(Q)$(call echo-cmd,rm)rm -f $^
> + # The list of files can be long. Use xargs to prevent issues.
> + $(Q)$(call echo-cmd,rm)echo "$^" | xargs rm -f
>
> JEVENTS_DEPS += prune_orphans
> endif
> --
> 2.52.0