From: <changqing.li@windriver.com>
To: <namhyung@kernel.org>, <charlie@rivosinc.com>,
<james.clark@linaro.org>, <irogers@google.com>,
<linux-kernel@vger.kernel.org>
Cc: <changqing.li@windriver.com>
Subject: [PATCH 1/1] tools/build: Let link command read option from file
Date: Tue, 22 Jul 2025 14:13:35 +0800 [thread overview]
Message-ID: <20250722061335.285249-2-changqing.li@windriver.com> (raw)
In-Reply-To: <20250722061335.285249-1-changqing.li@windriver.com>
From: Changqing Li <changqing.li@windriver.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@windriver.com>
---
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
next prev parent reply other threads:[~2025-07-22 6:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 6:13 [RFC][PATCH 0/1] " changqing.li
2025-07-22 6:13 ` changqing.li [this message]
2025-07-22 15:43 ` [PATCH 1/1] " Ian Rogers
2025-08-11 1:37 ` Changqing Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250722061335.285249-2-changqing.li@windriver.com \
--to=changqing.li@windriver.com \
--cc=charlie@rivosinc.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®