[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fW983q0NUEvxibY+QKLss+_TsyRGtgZF_n_q-XFZ98JLA@mail.gmail.com>
Date: Mon, 18 Aug 2025 13:38:38 -0700
From: Ian Rogers <irogers@...gle.com>
To: changqing.li@...driver.com
Cc: namhyung@...nel.org, james.clark@...aro.org, charlie@...osinc.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tools/build: make in-target rule robust against too long
argument error
On Mon, Jul 28, 2025 at 2:31 AM <changqing.li@...driver.com> wrote:
>
> From: Changqing Li <changqing.li@...driver.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@...driver.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
>
Powered by blists - more mailing lists