[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAP-5=fWE4y=t0EF0zwnYyyacncFH0xpwJQGAWW3T2Ruu=STotA@mail.gmail.com>
Date: Tue, 22 Jul 2025 08:43:37 -0700
From: Ian Rogers <irogers@...gle.com>
To: changqing.li@...driver.com
Cc: namhyung@...nel.org, charlie@...osinc.com, james.clark@...aro.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] tools/build: Let link command read option from file
On Mon, Jul 21, 2025 at 11:13 PM <changqing.li@...driver.com> wrote:
>
> From: Changqing Li <changqing.li@...driver.com>
>
> ld_multi will link multiple objects, 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"
>
> So make the ld command read option from file to fix above error. In
> order to convenient debug, write the file content in dot-target.cmd
> as comments.
>
> Signed-off-by: Changqing Li <changqing.li@...driver.com>
Hi Changqing,
I believe your change makes sense. I notice that the regular kernel
build has had to work around this problem too:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/Makefile.build#n290
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/Makefile.build#n463
but in those workarounds the need for an extra .in file isn't
necessary. Would such a change be possible here and avoid the need for
cleaning up an extra file?
Thanks,
Ian
> ---
> tools/build/Makefile.build | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build
> index 3584ff308607..e57ce8c34685 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 $@)
> + $(LD) -r -o $@ @$@.in,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 $@)
> + $(HOSTLD) -r -o $@ @$@.in,rm -f $@; $(HOSTAR) rcs $@)
> +
> +output_ld_multi_dotin = $(if $(quiet),,@printf "# %s:\n# " $@.in >> $(dot-target).cmd;cat $@.in >> $(dot-target).cmd)
>
> ifneq ($(filter $(obj),$(hostprogs)),)
> host = host_
> @@ -145,7 +147,10 @@ $(sort $(subdir-obj-y)): $(subdir-y) ;
>
> $(in-target): $(obj-y) $(test-y) FORCE
> $(call rule_mkdir)
> + $(file >$@.in,$(filter $(obj-y),$^))
> $(call if_changed,$(host)ld_multi)
> + $(if $(strip $(any-prereq) $(arg-check)), $(output_ld_multi_dotin))
> + @rm $@.in
>
> __build: $(in-target)
> @:
> --
> 2.34.1
>
Powered by blists - more mailing lists