public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf build: Avoid argument list too long in orphan pruning
@ 2026-03-13  7:24 cp0613
  2026-03-13  8:36 ` cp0613
  0 siblings, 1 reply; 4+ messages in thread
From: cp0613 @ 2026-03-13  7:24 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, irogers, guoren
  Cc: linux-perf-users, linux-kernel, Chen Pei

From: Chen Pei <cp0613@linux.alibaba.com>

When the output directory contains a large number of orphaned files with
deep file paths, directly passing the entire ORPHAN_FILES list to the
execve command will exceed the system's parameter length limit (it should
be MAX_ARG_STRLEN), causing "argument list too long" error during build.
See below:

  make[6]: execvp: /bin/sh: Argument list too long
  make[6]: *** [pmu-events/Build:217: prune_orphans] Error 127
  make[6]: *** Waiting for unfinished jobs....

Fix this by using GNU Make's $(file ...) function to write the orphan file
list to a temporary file, then use xargs to read from the file and remove
the orphan files. The temporary file is deleted after pruning completes.

This method avoids the argument length limitation since $(file ...) writes
directly without spawning a shell process with command-line arguments.

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
---
 tools/perf/pmu-events/Build | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 63c65788d442..ec5bf89ddfe1 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -209,12 +209,17 @@ endif
 ifneq ($(strip $(ORPHAN_FILES)),)
 .PHONY: prune_orphans
 
+# Store ORPHAN_FILES in a file to avoid argument list too long errors
+ORPHAN_LIST_FILE := $(OUTPUT)pmu-events/.orphan_list
+$(file >$(ORPHAN_LIST_FILE),$(ORPHAN_FILES))
+
 # Message for $(call echo-cmd,rm). Generally cleaning files isn't part
 # of a build step.
 quiet_cmd_rm  = RM      $^
 
-prune_orphans: $(ORPHAN_FILES)
-	$(Q)$(call echo-cmd,rm)rm -f $^
+prune_orphans: $(ORPHAN_LIST_FILE)
+	$(Q)$(call echo-cmd,rm)cat $^ | xargs rm -f
+	$(Q)rm -f $(ORPHAN_LIST_FILE)
 
 JEVENTS_DEPS += prune_orphans
 endif
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-17  1:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13  7:24 [PATCH] perf build: Avoid argument list too long in orphan pruning cp0613
2026-03-13  8:36 ` cp0613
2026-03-13 15:47   ` Ian Rogers
2026-03-17  1:44     ` cp0613

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox