* [PATCH] tools/build: make in-target rule robust against too long argument error @ 2025-07-28 9:31 changqing.li 2025-08-18 20:38 ` Ian Rogers 0 siblings, 1 reply; 7+ messages in thread From: changqing.li @ 2025-07-28 9:31 UTC (permalink / raw) To: namhyung, james.clark, irogers, charlie, linux-kernel; +Cc: changqing.li From: Changqing Li <changqing.li@windriver.com> The command length of in-target scales with the depth of the directory times the number of objects in the Makefile. When there are many objects, and O=[absolute_path] is set, and the absolute_path is relatively long. It is possile that this line "$(call if_changed,$(host)ld_multi)" will report error: "make[4]: /bin/sh: Argument list too long" For example, build perf tools with O=/long/output/path Like built-in.a and *.mod rules in scripts/Makefile.build, add $(objpredix)/ by the shell command instead of by Make's builtin function. Signed-off-by: Changqing Li <changqing.li@windriver.com> --- tools/build/Makefile.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build index 3584ff308607..39066a3ef2fc 100644 --- a/tools/build/Makefile.build +++ b/tools/build/Makefile.build @@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@ # If there's nothing to link, create empty $@ object. quiet_cmd_ld_multi = LD $@ cmd_ld_multi = $(if $(strip $(obj-y)),\ - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) + printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \ + xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@) quiet_cmd_host_ld_multi = HOSTLD $@ cmd_host_ld_multi = $(if $(strip $(obj-y)),\ - $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) + printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \ + xargs $(HOSTLD) -r -o $@,rm -f $@; $(HOSTAR) rcs $@) ifneq ($(filter $(obj),$(hostprogs)),) host = host_ -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tools/build: make in-target rule robust against too long argument error 2025-07-28 9:31 [PATCH] tools/build: make in-target rule robust against too long argument error changqing.li @ 2025-08-18 20:38 ` Ian Rogers 2025-08-19 3:01 ` Changqing Li 0 siblings, 1 reply; 7+ messages in thread From: Ian Rogers @ 2025-08-18 20:38 UTC (permalink / raw) To: changqing.li; +Cc: namhyung, james.clark, charlie, linux-kernel On Mon, Jul 28, 2025 at 2:31 AM <changqing.li@windriver.com> wrote: > > From: Changqing Li <changqing.li@windriver.com> > > The command length of in-target scales with the depth of the directory > times the number of objects in the Makefile. When there are many > objects, and O=[absolute_path] is set, and the absolute_path is > relatively long. It is possile that this line "$(call > if_changed,$(host)ld_multi)" will report error: > "make[4]: /bin/sh: Argument list too long" > > For example, build perf tools with O=/long/output/path > > Like built-in.a and *.mod rules in scripts/Makefile.build, add > $(objpredix)/ by the shell command instead of by Make's builtin > function. > > Signed-off-by: Changqing Li <changqing.li@windriver.com> Thanks Changqing, the change makes sense to me. The printf is pushing the values into xargs rather than using $^ with ld. I've tried reproducing the error to test your fix by creating long directory names in /tmp and then passing them to O=. I've not been able to do this. Could you send a reproduction for me to test? Thanks, Ian > --- > tools/build/Makefile.build | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build > index 3584ff308607..39066a3ef2fc 100644 > --- a/tools/build/Makefile.build > +++ b/tools/build/Makefile.build > @@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@ > # If there's nothing to link, create empty $@ object. > quiet_cmd_ld_multi = LD $@ > cmd_ld_multi = $(if $(strip $(obj-y)),\ > - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) > + printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \ > + xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@) > > quiet_cmd_host_ld_multi = HOSTLD $@ > cmd_host_ld_multi = $(if $(strip $(obj-y)),\ > - $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) > + printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \ > + xargs $(HOSTLD) -r -o $@,rm -f $@; $(HOSTAR) rcs $@) > > ifneq ($(filter $(obj),$(hostprogs)),) > host = host_ > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools/build: make in-target rule robust against too long argument error 2025-08-18 20:38 ` Ian Rogers @ 2025-08-19 3:01 ` Changqing Li 2025-10-28 2:15 ` Changqing Li 0 siblings, 1 reply; 7+ messages in thread From: Changqing Li @ 2025-08-19 3:01 UTC (permalink / raw) To: Ian Rogers; +Cc: namhyung, james.clark, charlie, linux-kernel, Changqing Li On 8/19/25 04:38, Ian Rogers wrote: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > On Mon, Jul 28, 2025 at 2:31 AM <changqing.li@windriver.com> wrote: >> From: Changqing Li <changqing.li@windriver.com> >> >> The command length of in-target scales with the depth of the directory >> times the number of objects in the Makefile. When there are many >> objects, and O=[absolute_path] is set, and the absolute_path is >> relatively long. It is possile that this line "$(call >> if_changed,$(host)ld_multi)" will report error: >> "make[4]: /bin/sh: Argument list too long" >> >> For example, build perf tools with O=/long/output/path >> >> Like built-in.a and *.mod rules in scripts/Makefile.build, add >> $(objpredix)/ by the shell command instead of by Make's builtin >> function. >> >> Signed-off-by: Changqing Li <changqing.li@windriver.com> > Thanks Changqing, the change makes sense to me. The printf is pushing > the values into xargs rather than using $^ with ld. I've tried > reproducing the error to test your fix by creating long directory > names in /tmp and then passing them to O=. I've not been able to do > this. Could you send a reproduction for me to test? > > Thanks, > Ian Hi, Ian Thanks. Here is my steps: 1. git clone https://github.com/torvalds/linux.git 2. cd linux/tools/perf/ 3. mkdir /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 4. make NO_LIBTRACEEVENT=1 O=/tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 5. Above step failed with error: make[4]: /bin/sh: Argument list too long make[4]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:148: /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/util/perf-util-in.o] Error 127 make[3]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:142: util] Error 2 make[2]: *** [Makefile.perf:797: /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/perf-util-in.o] Error 2 Regards Changqing >> --- >> tools/build/Makefile.build | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build >> index 3584ff308607..39066a3ef2fc 100644 >> --- a/tools/build/Makefile.build >> +++ b/tools/build/Makefile.build >> @@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@ >> # If there's nothing to link, create empty $@ object. >> quiet_cmd_ld_multi = LD $@ >> cmd_ld_multi = $(if $(strip $(obj-y)),\ >> - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) >> + printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \ >> + xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@) >> >> quiet_cmd_host_ld_multi = HOSTLD $@ >> cmd_host_ld_multi = $(if $(strip $(obj-y)),\ >> - $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) >> + printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \ >> + xargs $(HOSTLD) -r -o $@,rm -f $@; $(HOSTAR) rcs $@) >> >> ifneq ($(filter $(obj),$(hostprogs)),) >> host = host_ >> -- >> 2.34.1 >> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools/build: make in-target rule robust against too long argument error 2025-08-19 3:01 ` Changqing Li @ 2025-10-28 2:15 ` Changqing Li 2026-03-03 22:33 ` Ian Rogers 0 siblings, 1 reply; 7+ messages in thread From: Changqing Li @ 2025-10-28 2:15 UTC (permalink / raw) To: Ian Rogers; +Cc: namhyung, james.clark, charlie, linux-kernel Hi, Ian Kindly ping. Could you reproduce it? Any comments? Regards Changqing On 8/19/25 11:01, Changqing Li wrote: > > On 8/19/25 04:38, Ian Rogers wrote: >> CAUTION: This email comes from a non Wind River email account! >> Do not click links or open attachments unless you recognize the >> sender and know the content is safe. >> >> On Mon, Jul 28, 2025 at 2:31 AM <changqing.li@windriver.com> wrote: >>> From: Changqing Li <changqing.li@windriver.com> >>> >>> The command length of in-target scales with the depth of the directory >>> times the number of objects in the Makefile. When there are many >>> objects, and O=[absolute_path] is set, and the absolute_path is >>> relatively long. It is possile that this line "$(call >>> if_changed,$(host)ld_multi)" will report error: >>> "make[4]: /bin/sh: Argument list too long" >>> >>> For example, build perf tools with O=/long/output/path >>> >>> Like built-in.a and *.mod rules in scripts/Makefile.build, add >>> $(objpredix)/ by the shell command instead of by Make's builtin >>> function. >>> >>> Signed-off-by: Changqing Li <changqing.li@windriver.com> >> Thanks Changqing, the change makes sense to me. The printf is pushing >> the values into xargs rather than using $^ with ld. I've tried >> reproducing the error to test your fix by creating long directory >> names in /tmp and then passing them to O=. I've not been able to do >> this. Could you send a reproduction for me to test? >> >> Thanks, >> Ian > > Hi, Ian > > Thanks. Here is my steps: > > 1. git clone https://github.com/torvalds/linux.git > > 2. cd linux/tools/perf/ > > 3. mkdir > /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 > > 4. make NO_LIBTRACEEVENT=1 > O=/tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 > > > 5. Above step failed with error: > > make[4]: /bin/sh: Argument list too long > > make[4]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build > <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:148: > /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/util/perf-util-in.o] > Error 127 > > make[3]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build > <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:142: > util] Error 2 > > make[2]: *** [Makefile.perf:797: > /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/perf-util-in.o] > Error 2 > > > Regards > > Changqing >>> --- >>> tools/build/Makefile.build | 6 ++++-- >>> 1 file changed, 4 insertions(+), 2 deletions(-) >>> >>> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build >>> index 3584ff308607..39066a3ef2fc 100644 >>> --- a/tools/build/Makefile.build >>> +++ b/tools/build/Makefile.build >>> @@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@ >>> # If there's nothing to link, create empty $@ object. >>> quiet_cmd_ld_multi = LD $@ >>> cmd_ld_multi = $(if $(strip $(obj-y)),\ >>> - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f >>> $@; $(AR) rcs $@) >>> + printf "$(objprefix)%s " $(patsubst >>> $(objprefix)%,%,$(filter $(obj-y),$^)) | \ >>> + xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@) >>> >>> quiet_cmd_host_ld_multi = HOSTLD $@ >>> cmd_host_ld_multi = $(if $(strip $(obj-y)),\ >>> - $(HOSTLD) -r -o $@ $(filter >>> $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) >>> + printf "$(objprefix)%s " $(patsubst >>> $(objprefix)%,%,$(filter $(obj-y),$^)) | \ >>> + xargs $(HOSTLD) -r -o $@,rm -f $@; >>> $(HOSTAR) rcs $@) >>> >>> ifneq ($(filter $(obj),$(hostprogs)),) >>> host = host_ >>> -- >>> 2.34.1 >>> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools/build: make in-target rule robust against too long argument error 2025-10-28 2:15 ` Changqing Li @ 2026-03-03 22:33 ` Ian Rogers 2026-03-04 2:35 ` Changqing Li 2026-03-04 14:13 ` Arnaldo Carvalho de Melo 0 siblings, 2 replies; 7+ messages in thread From: Ian Rogers @ 2026-03-03 22:33 UTC (permalink / raw) To: Changqing Li, Arnaldo Carvalho de Melo, Namhyung Kim Cc: namhyung, james.clark, charlie, linux-kernel, Markus Mayer, linux-perf-users On Mon, Oct 27, 2025 at 7:16 PM Changqing Li <changqing.li@windriver.com> wrote: > > Hi, Ian > > Kindly ping. Could you reproduce it? Any comments? Sorry Changqing, I was reminded by: https://lore.kernel.org/lkml/20260303211503.165337-1-mmayer@broadcom.com/ that "argument list too long" is a problem for others. I tried reproducing it, but I think it doesn't fail for me, possibly because MAX_ARGS is larger on my system: ``` $ xargs --show-limits Your environment variables take up 6133 bytes POSIX upper limit on argument length (this system): 2088971 POSIX smallest allowable upper limit on argument length (all systems): 4096 Maximum length of command we could actually use: 2082838 Size of command buffer we are actually using: 131072 Maximum parallelism (--max-procs must be no greater): 2147483647 ``` Anyway, the change makes sense to me. Reviewed-by: Ian Rogers <irogers@google.com> Thanks, Ian > Regards > > Changqing > > On 8/19/25 11:01, Changqing Li wrote: > > > > On 8/19/25 04:38, Ian Rogers wrote: > >> CAUTION: This email comes from a non Wind River email account! > >> Do not click links or open attachments unless you recognize the > >> sender and know the content is safe. > >> > >> On Mon, Jul 28, 2025 at 2:31 AM <changqing.li@windriver.com> wrote: > >>> From: Changqing Li <changqing.li@windriver.com> > >>> > >>> The command length of in-target scales with the depth of the directory > >>> times the number of objects in the Makefile. When there are many > >>> objects, and O=[absolute_path] is set, and the absolute_path is > >>> relatively long. It is possile that this line "$(call > >>> if_changed,$(host)ld_multi)" will report error: > >>> "make[4]: /bin/sh: Argument list too long" > >>> > >>> For example, build perf tools with O=/long/output/path > >>> > >>> Like built-in.a and *.mod rules in scripts/Makefile.build, add > >>> $(objpredix)/ by the shell command instead of by Make's builtin > >>> function. > >>> > >>> Signed-off-by: Changqing Li <changqing.li@windriver.com> > >> Thanks Changqing, the change makes sense to me. The printf is pushing > >> the values into xargs rather than using $^ with ld. I've tried > >> reproducing the error to test your fix by creating long directory > >> names in /tmp and then passing them to O=. I've not been able to do > >> this. Could you send a reproduction for me to test? > >> > >> Thanks, > >> Ian > > > > Hi, Ian > > > > Thanks. Here is my steps: > > > > 1. git clone https://github.com/torvalds/linux.git > > > > 2. cd linux/tools/perf/ > > > > 3. mkdir > > /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 > > > > 4. make NO_LIBTRACEEVENT=1 > > O=/tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 > > > > > > 5. Above step failed with error: > > > > make[4]: /bin/sh: Argument list too long > > > > make[4]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build > > <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:148: > > /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/util/perf-util-in.o] > > Error 127 > > > > make[3]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build > > <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:142: > > util] Error 2 > > > > make[2]: *** [Makefile.perf:797: > > /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/perf-util-in.o] > > Error 2 > > > > > > Regards > > > > Changqing > >>> --- > >>> tools/build/Makefile.build | 6 ++++-- > >>> 1 file changed, 4 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build > >>> index 3584ff308607..39066a3ef2fc 100644 > >>> --- a/tools/build/Makefile.build > >>> +++ b/tools/build/Makefile.build > >>> @@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@ > >>> # If there's nothing to link, create empty $@ object. > >>> quiet_cmd_ld_multi = LD $@ > >>> cmd_ld_multi = $(if $(strip $(obj-y)),\ > >>> - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f > >>> $@; $(AR) rcs $@) > >>> + printf "$(objprefix)%s " $(patsubst > >>> $(objprefix)%,%,$(filter $(obj-y),$^)) | \ > >>> + xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@) > >>> > >>> quiet_cmd_host_ld_multi = HOSTLD $@ > >>> cmd_host_ld_multi = $(if $(strip $(obj-y)),\ > >>> - $(HOSTLD) -r -o $@ $(filter > >>> $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) > >>> + printf "$(objprefix)%s " $(patsubst > >>> $(objprefix)%,%,$(filter $(obj-y),$^)) | \ > >>> + xargs $(HOSTLD) -r -o $@,rm -f $@; > >>> $(HOSTAR) rcs $@) > >>> > >>> ifneq ($(filter $(obj),$(hostprogs)),) > >>> host = host_ > >>> -- > >>> 2.34.1 > >>> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools/build: make in-target rule robust against too long argument error 2026-03-03 22:33 ` Ian Rogers @ 2026-03-04 2:35 ` Changqing Li 2026-03-04 14:13 ` Arnaldo Carvalho de Melo 1 sibling, 0 replies; 7+ messages in thread From: Changqing Li @ 2026-03-04 2:35 UTC (permalink / raw) To: Ian Rogers, Arnaldo Carvalho de Melo, Namhyung Kim Cc: namhyung, james.clark, charlie, linux-kernel, Markus Mayer, linux-perf-users On 3/4/26 06:33, Ian Rogers wrote: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > On Mon, Oct 27, 2025 at 7:16 PM Changqing Li <changqing.li@windriver.com> wrote: >> Hi, Ian >> >> Kindly ping. Could you reproduce it? Any comments? > Sorry Changqing, > > I was reminded by: > https://lore.kernel.org/lkml/20260303211503.165337-1-mmayer@broadcom.com/ > that "argument list too long" is a problem for others. > > I tried reproducing it, but I think it doesn't fail for me, possibly > because MAX_ARGS is larger on my system: > ``` > $ xargs --show-limits > Your environment variables take up 6133 bytes > POSIX upper limit on argument length (this system): 2088971 > POSIX smallest allowable upper limit on argument length (all systems): 4096 > Maximum length of command we could actually use: 2082838 > Size of command buffer we are actually using: 131072 > Maximum parallelism (--max-procs must be no greater): 2147483647 > ``` > > Anyway, the change makes sense to me. > > Reviewed-by: Ian Rogers <irogers@google.com> > > Thanks, > Ian > Hi, Ian Thanks. I also cannot reproduce with previous length of tmpdir, maybe caused by perf source changes during this period, but I can still reproduce after I make the tmpdir longer. $ xargs --show-limits Your environment variables take up 3124 bytes POSIX upper limit on argument length (this system): 2091980 POSIX smallest allowable upper limit on argument length (all systems): 4096 Maximum length of command we could actually use: 2088856 Size of command buffer we are actually using: 131072 Maximum parallelism (--max-procs must be no greater): 2147483647 Regards Changqing >> Regards >> >> Changqing >> >> On 8/19/25 11:01, Changqing Li wrote: >>> On 8/19/25 04:38, Ian Rogers wrote: >>>> CAUTION: This email comes from a non Wind River email account! >>>> Do not click links or open attachments unless you recognize the >>>> sender and know the content is safe. >>>> >>>> On Mon, Jul 28, 2025 at 2:31 AM <changqing.li@windriver.com> wrote: >>>>> From: Changqing Li <changqing.li@windriver.com> >>>>> >>>>> The command length of in-target scales with the depth of the directory >>>>> times the number of objects in the Makefile. When there are many >>>>> objects, and O=[absolute_path] is set, and the absolute_path is >>>>> relatively long. It is possile that this line "$(call >>>>> if_changed,$(host)ld_multi)" will report error: >>>>> "make[4]: /bin/sh: Argument list too long" >>>>> >>>>> For example, build perf tools with O=/long/output/path >>>>> >>>>> Like built-in.a and *.mod rules in scripts/Makefile.build, add >>>>> $(objpredix)/ by the shell command instead of by Make's builtin >>>>> function. >>>>> >>>>> Signed-off-by: Changqing Li <changqing.li@windriver.com> >>>> Thanks Changqing, the change makes sense to me. The printf is pushing >>>> the values into xargs rather than using $^ with ld. I've tried >>>> reproducing the error to test your fix by creating long directory >>>> names in /tmp and then passing them to O=. I've not been able to do >>>> this. Could you send a reproduction for me to test? >>>> >>>> Thanks, >>>> Ian >>> Hi, Ian >>> >>> Thanks. Here is my steps: >>> >>> 1. git clone https://github.com/torvalds/linux.git >>> >>> 2. cd linux/tools/perf/ >>> >>> 3. mkdir >>> /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 >>> >>> 4. make NO_LIBTRACEEVENT=1 >>> O=/tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0 >>> >>> >>> 5. Above step failed with error: >>> >>> make[4]: /bin/sh: Argument list too long >>> >>> make[4]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build >>> <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:148: >>> /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/util/perf-util-in.o] >>> Error 127 >>> >>> make[3]: *** [/buildarea2/cli10/tmp/linux/tools/build/Makefile.build >>> <https://urldefense.com/v3/__http://Makefile.build__;!!AjveYdw8EvQ!c2n7zPX4Vrhwd7a9UxsjCXBGO5V8Llmon1egvupz4kHL4869ilesQgRgQZO8nj8AWwQJUlY9DOoWPD688quA73jNugR6IZRxy09Eig$>:142: >>> util] Error 2 >>> >>> make[2]: *** [Makefile.perf:797: >>> /tmp/01234567890123456789/0123456789012345678901234567890123456789/0123456789012345678901234567890123456789/012345678901234567890123456789/01234567890123456789/012345678901234567890123456789/01234567890123456789012345678/9012345678901234567890123456789/012345678901234567890123456789/012345678901234567890123456789/01234567890123456789012345678901234567890123456789012345678901234567890123/perf-1.0/perf-util-in.o] >>> Error 2 >>> >>> >>> Regards >>> >>> Changqing >>>>> --- >>>>> tools/build/Makefile.build | 6 ++++-- >>>>> 1 file changed, 4 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build >>>>> index 3584ff308607..39066a3ef2fc 100644 >>>>> --- a/tools/build/Makefile.build >>>>> +++ b/tools/build/Makefile.build >>>>> @@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@ >>>>> # If there's nothing to link, create empty $@ object. >>>>> quiet_cmd_ld_multi = LD $@ >>>>> cmd_ld_multi = $(if $(strip $(obj-y)),\ >>>>> - $(LD) -r -o $@ $(filter $(obj-y),$^),rm -f >>>>> $@; $(AR) rcs $@) >>>>> + printf "$(objprefix)%s " $(patsubst >>>>> $(objprefix)%,%,$(filter $(obj-y),$^)) | \ >>>>> + xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@) >>>>> >>>>> quiet_cmd_host_ld_multi = HOSTLD $@ >>>>> cmd_host_ld_multi = $(if $(strip $(obj-y)),\ >>>>> - $(HOSTLD) -r -o $@ $(filter >>>>> $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) >>>>> + printf "$(objprefix)%s " $(patsubst >>>>> $(objprefix)%,%,$(filter $(obj-y),$^)) | \ >>>>> + xargs $(HOSTLD) -r -o $@,rm -f $@; >>>>> $(HOSTAR) rcs $@) >>>>> >>>>> ifneq ($(filter $(obj),$(hostprogs)),) >>>>> host = host_ >>>>> -- >>>>> 2.34.1 >>>>> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tools/build: make in-target rule robust against too long argument error 2026-03-03 22:33 ` Ian Rogers 2026-03-04 2:35 ` Changqing Li @ 2026-03-04 14:13 ` Arnaldo Carvalho de Melo 1 sibling, 0 replies; 7+ messages in thread From: Arnaldo Carvalho de Melo @ 2026-03-04 14:13 UTC (permalink / raw) To: Ian Rogers Cc: Changqing Li, Namhyung Kim, namhyung, james.clark, charlie, linux-kernel, Markus Mayer, linux-perf-users On Tue, Mar 03, 2026 at 02:33:04PM -0800, Ian Rogers wrote: > On Mon, Oct 27, 2025 at 7:16 PM Changqing Li <changqing.li@windriver.com> wrote: > > Kindly ping. Could you reproduce it? Any comments? > Sorry Changqing, > I was reminded by: > https://lore.kernel.org/lkml/20260303211503.165337-1-mmayer@broadcom.com/ > that "argument list too long" is a problem for others. > I tried reproducing it, but I think it doesn't fail for me, possibly > because MAX_ARGS is larger on my system: > ``` > $ xargs --show-limits > Your environment variables take up 6133 bytes > POSIX upper limit on argument length (this system): 2088971 > POSIX smallest allowable upper limit on argument length (all systems): 4096 > Maximum length of command we could actually use: 2082838 > Size of command buffer we are actually using: 131072 > Maximum parallelism (--max-procs must be no greater): 2147483647 > ``` > Anyway, the change makes sense to me. > Reviewed-by: Ian Rogers <irogers@google.com> Ok, so I'll pick this one and the other for rm that you mentioned: https://lore.kernel.org/lkml/20260303211503.165337-1-mmayer@broadcom.com I'll have it in perf-tools, for v7.0. - Arnaldo ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-04 14:13 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-07-28 9:31 [PATCH] tools/build: make in-target rule robust against too long argument error changqing.li 2025-08-18 20:38 ` Ian Rogers 2025-08-19 3:01 ` Changqing Li 2025-10-28 2:15 ` Changqing Li 2026-03-03 22:33 ` Ian Rogers 2026-03-04 2:35 ` Changqing Li 2026-03-04 14:13 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox