diff mbox series

[2/2] kbuild: handle excessively long argument lists

Message ID 1610500731-30960-2-git-send-email-jjohnson@codeaurora.org (mailing list archive)
State New
Headers show
Series [1/2] kbuild: simplify cmd_mod | expand

Commit Message

Jeff Johnson Jan. 13, 2021, 1:18 a.m. UTC
From: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>

Modules with a large number of compilation units may be
exceeding AR and LD command argument list. Handle this gracefully by
writing the long argument list in a file. The command line options
read from file are inserted in place of the original @file option.

The usage is well documented at
https://www.gnu.org/software/make/manual/html_node/File-Function.html

Signed-off-by: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
---
 scripts/Makefile.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Nick Desaulniers Jan. 14, 2021, 9:07 p.m. UTC | #1
> From: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
> 
> Modules with a large number of compilation units may be
> exceeding AR and LD command argument list. Handle this gracefully by
> writing the long argument list in a file. The command line options
> read from file are inserted in place of the original @file option.
> 
> The usage is well documented at
> https://www.gnu.org/software/make/manual/html_node/File-Function.html
> 
> Signed-off-by: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
> Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
> ---
>  scripts/Makefile.build | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 252b7d2..d5ef345 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -425,7 +425,11 @@ $(obj)/lib.a: $(lib-y) FORCE
>  # module is turned into a multi object module, $^ will contain header file
>  # dependencies recorded in the .*.cmd file.
>  quiet_cmd_link_multi-m = LD [M]  $@
> -      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
> +      cmd_link_multi-m =					\
> +	$(file >$@.in,$(filter %.o,$^))				\
> +	$(LD) $(ld_flags) -r -o $@ @$@.in;			\
> +	rm -f $@.in
> +endif

Was this build tested?

$ make LLVM=1 LLVM_IAS=1 -j72 defconfig
scripts/Makefile.build:432: *** extraneous 'endif'.  Stop.
make: *** [Makefile:535: scripts_basic] Error 2

(Please cc me on v2)

>  
>  $(multi-used-m): FORCE
>  	$(call if_changed,link_multi-m)
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
Jeff Johnson Jan. 14, 2021, 9:32 p.m. UTC | #2
On 2021-01-14 13:07, Nick Desaulniers wrote:
>> From: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
>> 
>> Modules with a large number of compilation units may be
>> exceeding AR and LD command argument list. Handle this gracefully by
>> writing the long argument list in a file. The command line options
>> read from file are inserted in place of the original @file option.
>> 
>> The usage is well documented at
>> https://www.gnu.org/software/make/manual/html_node/File-Function.html
>> 
>> Signed-off-by: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
>> Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
>> ---
>>  scripts/Makefile.build | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>> 
>> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
>> index 252b7d2..d5ef345 100644
>> --- a/scripts/Makefile.build
>> +++ b/scripts/Makefile.build
>> @@ -425,7 +425,11 @@ $(obj)/lib.a: $(lib-y) FORCE
>>  # module is turned into a multi object module, $^ will contain header 
>> file
>>  # dependencies recorded in the .*.cmd file.
>>  quiet_cmd_link_multi-m = LD [M]  $@
>> -      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
>> +      cmd_link_multi-m =					\
>> +	$(file >$@.in,$(filter %.o,$^))				\
>> +	$(LD) $(ld_flags) -r -o $@ @$@.in;			\
>> +	rm -f $@.in
>> +endif
> 
> Was this build tested?
> 
> $ make LLVM=1 LLVM_IAS=1 -j72 defconfig
> scripts/Makefile.build:432: *** extraneous 'endif'.  Stop.
> make: *** [Makefile:535: scripts_basic] Error 2
> 
> (Please cc me on v2)

blush

It was tested on a workspace that also contains the Clang LTO series
https://patchwork.kernel.org/project/linux-kbuild/patch/20201211184633.3213045-3-samitolvanen@google.com/

I messed up when trimming, will update in v2
diff mbox series

Patch

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 252b7d2..d5ef345 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -425,7 +425,11 @@  $(obj)/lib.a: $(lib-y) FORCE
 # module is turned into a multi object module, $^ will contain header file
 # dependencies recorded in the .*.cmd file.
 quiet_cmd_link_multi-m = LD [M]  $@
-      cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
+      cmd_link_multi-m =					\
+	$(file >$@.in,$(filter %.o,$^))				\
+	$(LD) $(ld_flags) -r -o $@ @$@.in;			\
+	rm -f $@.in
+endif
 
 $(multi-used-m): FORCE
 	$(call if_changed,link_multi-m)