Skip to content

Commit f079ff3

Browse files
sandy-lcqacmel
authored andcommitted
tools build: Make in-target rule robust against too long argument error
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 possible 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. Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Changqing Li <changqing.li@windriver.com> Cc: Charlie Jenkins <charlie@rivosinc.com> Cc: James Clark <james.clark@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent cfdf645 commit f079ff3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tools/build/Makefile.build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ quiet_cmd_gen = GEN $@
7070
# If there's nothing to link, create empty $@ object.
7171
quiet_cmd_ld_multi = LD $@
7272
cmd_ld_multi = $(if $(strip $(obj-y)),\
73-
$(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
73+
printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \
74+
xargs $(LD) -r -o $@,rm -f $@; $(AR) rcs $@)
7475

7576
quiet_cmd_host_ld_multi = HOSTLD $@
7677
cmd_host_ld_multi = $(if $(strip $(obj-y)),\
77-
$(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@)
78+
printf "$(objprefix)%s " $(patsubst $(objprefix)%,%,$(filter $(obj-y),$^)) | \
79+
xargs $(HOSTLD) -r -o $@,rm -f $@; $(HOSTAR) rcs $@)
7880

7981
rust_common_cmd = \
8082
$(RUSTC) $(rust_flags) \

0 commit comments

Comments
 (0)