All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kbuild: simplify cmd_mod
@ 2021-01-13  1:18 Jeff Johnson
  2021-01-13  1:18 ` [PATCH 2/2] kbuild: handle excessively long argument lists Jeff Johnson
  2021-01-15  1:07 ` [PATCH 1/2] kbuild: simplify cmd_mod Nick Desaulniers
  0 siblings, 2 replies; 12+ messages in thread
From: Jeff Johnson @ 2021-01-13  1:18 UTC (permalink / raw)
  To: linux-kbuild
  Cc: psodagud, eberman, Mahesh Kumar Kalikot Veetil, Jeff Johnson,
	Masahiro Yamada, Michal Marek, linux-kernel

From: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>

Modules with a large number of compilation units can exceed execv
argument list resulting in E2BIG (Argument list too long) error.

Fix this by replacing shell 'echo > file' into a more native
$(file op filename[,text]) option.

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

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 4c058f1..252b7d2 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -279,10 +279,11 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
 	$(call if_changed_rule,cc_o_c)
 	$(call cmd,force_checksrc)
 
-cmd_mod = { \
-	echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
-	$(undefined_syms) echo; \
-	} > $@
+cmd_mod = $(file >$@,\
+		$(if $($*-objs)$($*-y)$($*-m), \
+			$(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), \
+			$(@:.mod=.o))) \
+	$(undefined_syms) echo >> $@
 
 $(obj)/%.mod: $(obj)/%.o FORCE
 	$(call if_changed,mod)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] kbuild: handle excessively long argument lists
  2021-01-13  1:18 [PATCH 1/2] kbuild: simplify cmd_mod Jeff Johnson
@ 2021-01-13  1:18 ` Jeff Johnson
  2021-01-14 21:07   ` Nick Desaulniers
  2021-01-14 21:49   ` [PATCH v2 " Jeff Johnson
  2021-01-15  1:07 ` [PATCH 1/2] kbuild: simplify cmd_mod Nick Desaulniers
  1 sibling, 2 replies; 12+ messages in thread
From: Jeff Johnson @ 2021-01-13  1:18 UTC (permalink / raw)
  To: linux-kbuild
  Cc: psodagud, eberman, Mahesh Kumar Kalikot Veetil, Jeff Johnson,
	Masahiro Yamada, Michal Marek, linux-kernel

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
 
 $(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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kbuild: handle excessively long argument lists
  2021-01-13  1:18 ` [PATCH 2/2] kbuild: handle excessively long argument lists Jeff Johnson
@ 2021-01-14 21:07   ` Nick Desaulniers
  2021-01-14 21:32     ` jjohnson
  2021-01-14 21:49   ` [PATCH v2 " Jeff Johnson
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2021-01-14 21:07 UTC (permalink / raw)
  To: jjohnson
  Cc: eberman, linux-kbuild, linux-kernel, masahiroy, michal.lkml,
	mkalikot, psodagud

> 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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kbuild: handle excessively long argument lists
  2021-01-14 21:07   ` Nick Desaulniers
@ 2021-01-14 21:32     ` jjohnson
  0 siblings, 0 replies; 12+ messages in thread
From: jjohnson @ 2021-01-14 21:32 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: eberman, linux-kbuild, linux-kernel, masahiroy, michal.lkml,
	mkalikot, psodagud, ndesaulniers via sendgmr

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-13  1:18 ` [PATCH 2/2] kbuild: handle excessively long argument lists Jeff Johnson
  2021-01-14 21:07   ` Nick Desaulniers
@ 2021-01-14 21:49   ` Jeff Johnson
  2021-01-15  1:00     ` Nick Desaulniers
  2021-01-15  1:12     ` Masahiro Yamada
  1 sibling, 2 replies; 12+ messages in thread
From: Jeff Johnson @ 2021-01-14 21:49 UTC (permalink / raw)
  To: linux-kbuild
  Cc: psodagud, eberman, ndesaulniers, Mahesh Kumar Kalikot Veetil,
	Jeff Johnson, Masahiro Yamada, Michal Marek, linux-kernel

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>
---

Changes in v2:
  - Remove spurious endif
  
scripts/Makefile.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 252b7d2..787dca2 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -425,7 +425,10 @@ $(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
 
 $(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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-14 21:49   ` [PATCH v2 " Jeff Johnson
@ 2021-01-15  1:00     ` Nick Desaulniers
  2021-01-15  1:25       ` Masahiro Yamada
  2021-01-15  1:12     ` Masahiro Yamada
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2021-01-15  1:00 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Linux Kbuild mailing list, Prasad Sodagudi, Elliot Berman,
	Mahesh Kumar Kalikot Veetil, Masahiro Yamada, Michal Marek, LKML,
	Sami Tolvanen

On Thu, Jan 14, 2021 at 1:50 PM Jeff Johnson <jjohnson@codeaurora.org> 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>
> ---
>
> Changes in v2:
>   - Remove spurious endif
>
> scripts/Makefile.build | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 252b7d2..787dca2 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -425,7 +425,10 @@ $(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

The GNU Make docs linked above use an `@` before the invocation of
`rm`. I don't know what that's about, but that or even this patch
doesn't affect my ability to build negatively. LGTM

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>

>
>  $(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
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] kbuild: simplify cmd_mod
  2021-01-13  1:18 [PATCH 1/2] kbuild: simplify cmd_mod Jeff Johnson
  2021-01-13  1:18 ` [PATCH 2/2] kbuild: handle excessively long argument lists Jeff Johnson
@ 2021-01-15  1:07 ` Nick Desaulniers
  1 sibling, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2021-01-15  1:07 UTC (permalink / raw)
  To: jjohnson
  Cc: eberman, linux-kbuild, linux-kernel, masahiroy, michal.lkml,
	mkalikot, psodagud, Sami Tolvanen, Nick Desaulniers

> From: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
> 
> Modules with a large number of compilation units can exceed execv
> argument list resulting in E2BIG (Argument list too long) error.
> 
> Fix this by replacing shell 'echo > file' into a more native
> $(file op filename[,text]) option.
> 
> Signed-off-by: Mahesh Kumar Kalikot Veetil <mkalikot@codeaurora.org>
> Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
> ---
>  scripts/Makefile.build | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 4c058f1..252b7d2 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -279,10 +279,11 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
>  	$(call if_changed_rule,cc_o_c)
>  	$(call cmd,force_checksrc)
>  
> -cmd_mod = { \
> -	echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
> -	$(undefined_syms) echo; \
> -	} > $@
> +cmd_mod = $(file >$@,\
> +		$(if $($*-objs)$($*-y)$($*-m), \
> +			$(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), \
> +			$(@:.mod=.o))) \
> +	$(undefined_syms) echo >> $@

I find the indendation to be a readability improvement. Thanks for the
patch.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>

>  
>  $(obj)/%.mod: $(obj)/%.o FORCE
>  	$(call if_changed,mod)
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-14 21:49   ` [PATCH v2 " Jeff Johnson
  2021-01-15  1:00     ` Nick Desaulniers
@ 2021-01-15  1:12     ` Masahiro Yamada
  2021-01-15 20:15       ` jjohnson
  1 sibling, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2021-01-15  1:12 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Linux Kbuild mailing list, Prasad Sodagudi, eberman,
	Nick Desaulniers, Mahesh Kumar Kalikot Veetil, Michal Marek,
	Linux Kernel Mailing List

On Fri, Jan 15, 2021 at 6:50 AM Jeff Johnson <jjohnson@codeaurora.org> 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>
> ---




First, is this a real problem?
If so, which module is exceeding the command line limit?


$(file ) is only supported by GNU Make 4.0 or later.

The current minimum version is GNU Make 3.81.

If we need this feature,
Documentation/process/changes.rst must be updated.




But, more importantly, none of your patches
works correctly.



Since $(file ...) is evaluated into an empty string,
your patches would break the Kbuild ability
that detects the command changes.




Steps to reproduce the problem
------------------------------



[1] add a module foo that consists of
    three objects foo1.o, foo2.o, foo3.o

For example, like follows:


obj-m += foo.o
foo-objs := foo1.o foo2.o foo3.o



[2] Run 'make modules'

You will get the module foo.



[3] Drop foo3.o from the module members

Change Makefile as follows:

obj-m += foo.o
foo-objs := foo1.o foo2.o



[4] Re-run 'make modules'





The current build system cleverly
notices the Makefile change, and
correctly rebuilds the foo module.

With your patch set applied,
the build system would not rebuild
the module.







> Changes in v2:
>   - Remove spurious endif
>
> scripts/Makefile.build | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 252b7d2..787dca2 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -425,7 +425,10 @@ $(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
>
>  $(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
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-15  1:00     ` Nick Desaulniers
@ 2021-01-15  1:25       ` Masahiro Yamada
  0 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2021-01-15  1:25 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Jeff Johnson, Linux Kbuild mailing list, Prasad Sodagudi,
	Elliot Berman, Mahesh Kumar Kalikot Veetil, Michal Marek, LKML,
	Sami Tolvanen

On Fri, Jan 15, 2021 at 10:01 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Thu, Jan 14, 2021 at 1:50 PM Jeff Johnson <jjohnson@codeaurora.org> 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>
> > ---
> >
> > Changes in v2:
> >   - Remove spurious endif
> >
> > scripts/Makefile.build | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 252b7d2..787dca2 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -425,7 +425,10 @@ $(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
>
> The GNU Make docs linked above use an `@` before the invocation of
> `rm`. I don't know what that's about, but that or even this patch
> doesn't affect my ability to build negatively. LGTM


See this:

https://www.gnu.org/software/make/manual/html_node/Echoing.html#Echoing




> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
>
> >
> >  $(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
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-15  1:12     ` Masahiro Yamada
@ 2021-01-15 20:15       ` jjohnson
  2021-01-15 21:53         ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: jjohnson @ 2021-01-15 20:15 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Prasad Sodagudi, eberman,
	Nick Desaulniers, Mahesh Kumar Kalikot Veetil, Michal Marek,
	Linux Kernel Mailing List

On 2021-01-14 17:12, Masahiro Yamada wrote:
> On Fri, Jan 15, 2021 at 6:50 AM Jeff Johnson <jjohnson@codeaurora.org> 
> 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>
>> ---
> 
> 
> 
> 
> First, is this a real problem?
> If so, which module is exceeding the command line limit?

On 2021-01-14 17:12, Masahiro Yamada wrote:
> First, is this a real problem?
> If so, which module is exceeding the command line limit?

Mahesh & I appreciate all of the feedback.

The issue is seen in an Android environment with an out-of-tree
driver. The combination of long path names and a large number
of source files is leading to the issue.

Since Mahesh & I are not Kbuild gurus, is there an alternative
solution to this issue?

Jeff

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-15 20:15       ` jjohnson
@ 2021-01-15 21:53         ` Masahiro Yamada
  2021-01-19 20:02           ` mkalikot
  0 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2021-01-15 21:53 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Linux Kbuild mailing list, Prasad Sodagudi, Elliot Berman,
	Nick Desaulniers, Mahesh Kumar Kalikot Veetil, Michal Marek,
	Linux Kernel Mailing List

On Sat, Jan 16, 2021 at 5:15 AM <jjohnson@codeaurora.org> wrote:
>
> On 2021-01-14 17:12, Masahiro Yamada wrote:
> > On Fri, Jan 15, 2021 at 6:50 AM Jeff Johnson <jjohnson@codeaurora.org>
> > 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>
> >> ---
> >
> >
> >
> >
> > First, is this a real problem?
> > If so, which module is exceeding the command line limit?
>
> On 2021-01-14 17:12, Masahiro Yamada wrote:
> > First, is this a real problem?
> > If so, which module is exceeding the command line limit?
>
> Mahesh & I appreciate all of the feedback.
>
> The issue is seen in an Android environment with an out-of-tree
> driver. The combination of long path names and a large number
> of source files is leading to the issue.
>
> Since Mahesh & I are not Kbuild gurus, is there an alternative
> solution to this issue?
>
> Jeff


I see.

The support for out-of-tree modules
is not nice in this regard, but fixing it
would need many changes.


The long-term solution might be to upstream your driver,
but it might not be possible.






One cheesy workaround might be to point the module path
via a symbolic link.


Let's say your module is located in a very deep
directory,
/home/foo/long/long/.../path/to/your/module


 make M=/home/foo/long/long/.../path/to/your/module modules

would fail due to the too long command line.




First, create a symbolic link as follows:

 ln -s /home/foo/long/long/.../path/to/your/module mod_dir


Then, pass the symbolic link to M= option.

 make M=mod_dir modules




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] kbuild: handle excessively long argument lists
  2021-01-15 21:53         ` Masahiro Yamada
@ 2021-01-19 20:02           ` mkalikot
  0 siblings, 0 replies; 12+ messages in thread
From: mkalikot @ 2021-01-19 20:02 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Jeff Johnson, Linux Kbuild mailing list, Prasad Sodagudi,
	Elliot Berman, Nick Desaulniers, Michal Marek,
	Linux Kernel Mailing List

On 2021-01-15 13:53, Masahiro Yamada wrote:
> On Sat, Jan 16, 2021 at 5:15 AM <jjohnson@codeaurora.org> wrote:
>> 
>> On 2021-01-14 17:12, Masahiro Yamada wrote:
>> > On Fri, Jan 15, 2021 at 6:50 AM Jeff Johnson <jjohnson@codeaurora.org>
>> > 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>
>> >> ---
>> >
>> >
>> >
>> >
>> > First, is this a real problem?
>> > If so, which module is exceeding the command line limit?
>> 
>> On 2021-01-14 17:12, Masahiro Yamada wrote:
>> > First, is this a real problem?
>> > If so, which module is exceeding the command line limit?
>> 
>> Mahesh & I appreciate all of the feedback.
>> 
>> The issue is seen in an Android environment with an out-of-tree
>> driver. The combination of long path names and a large number
>> of source files is leading to the issue.
>> 
>> Since Mahesh & I are not Kbuild gurus, is there an alternative
>> solution to this issue?
>> 
>> Jeff
> 
> 
> I see.
> 
> The support for out-of-tree modules
> is not nice in this regard, but fixing it
> would need many changes.
> 

Agree with that. I checked the same after your first comment on this 
thread.
It needs changes in multiple layers of makefiles.

> 
> The long-term solution might be to upstream your driver,
> but it might not be possible.
> 
> 
> 
> 
> 
> 
> One cheesy workaround might be to point the module path
> via a symbolic link.
> 
> 
> Let's say your module is located in a very deep
> directory,
> /home/foo/long/long/.../path/to/your/module
> 
> 
>  make M=/home/foo/long/long/.../path/to/your/module modules
> 
> would fail due to the too long command line.
> 
> 
> 
> 
> First, create a symbolic link as follows:
> 
>  ln -s /home/foo/long/long/.../path/to/your/module mod_dir
> 
> 
> Then, pass the symbolic link to M= option.
> 
>  make M=mod_dir modules

Thanks for the suggestion. Earlier, we have used a similar workaround
of using relative path instead of absolute to reduce the command line
length.


What's your input on the following approach where we link object
files in different stages to reduce the command line length.


./Makefile

  # foo.c is combined and final module.

  obj-m = fooa.o foob.o fooc.o

  # link already combined object files
  fooc-y := fooa.o foob.o

  # combine into different groups
  fooa-y := foo1.o foo2.o
  foob-y := foo3.o foo4.o

  ....


Note: We need to add MODULE_LICENSE in every group.


make -C ../linux-kbuild M=/local/mnt2/workspace/dev/foo modules

   CC [M]  /local/mnt2/workspace/dev/foo/foo1.o
   CC [M]  /local/mnt2/workspace/dev/foo/foo2.o
   LD [M]  /local/mnt2/workspace/dev/foo/fooa.o
   CC [M]  /local/mnt2/workspace/dev/foo/foo3.o
   CC [M]  /local/mnt2/workspace/dev/foo/foo4.o
   LD [M]  /local/mnt2/workspace/dev/foo/foob.o
   LD [M]  /local/mnt2/workspace/dev/foo/fooc.o
   MODPOST /local/mnt2/workspace/dev/foo/Module.symvers
   CC [M]  /local/mnt2/workspace/dev/foo/fooa.mod.o
   LD [M]  /local/mnt2/workspace/dev/foo/fooa.ko
   CC [M]  /local/mnt2/workspace/dev/foo/foob.mod.o
   LD [M]  /local/mnt2/workspace/dev/foo/foob.ko
   CC [M]  /local/mnt2/workspace/dev/foo/fooc.mod.o
   LD [M]  /local/mnt2/workspace/dev/foo/fooc.ko



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-01-19 20:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  1:18 [PATCH 1/2] kbuild: simplify cmd_mod Jeff Johnson
2021-01-13  1:18 ` [PATCH 2/2] kbuild: handle excessively long argument lists Jeff Johnson
2021-01-14 21:07   ` Nick Desaulniers
2021-01-14 21:32     ` jjohnson
2021-01-14 21:49   ` [PATCH v2 " Jeff Johnson
2021-01-15  1:00     ` Nick Desaulniers
2021-01-15  1:25       ` Masahiro Yamada
2021-01-15  1:12     ` Masahiro Yamada
2021-01-15 20:15       ` jjohnson
2021-01-15 21:53         ` Masahiro Yamada
2021-01-19 20:02           ` mkalikot
2021-01-15  1:07 ` [PATCH 1/2] kbuild: simplify cmd_mod Nick Desaulniers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.