Skip to contentSkip to conversation

kbuild: remove sed command from cmd_ar_builtin

PATCH In review Masahiro Yamada 3 participants 4 messages Jun 14, 2022 – Jun 15, 2022 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kbuild: remove sed command from cmd_ar_builtin

Replace a pipeline of echo and sed with printf to decrease process forks.

---

Changes in v2:
- Avoid the pipeline if there is no object to put in the archive

 scripts/Makefile.build | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
scripts/Makefile.build +2 -3
index cac070aee791..784f46d41959 100644
@@ -358,9 +358,8 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
 
 quiet_cmd_ar_builtin = AR      $@
       cmd_ar_builtin = rm -f $@; \
-		echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \
-		sed -E 's:([^ ]+):$(obj)/\1:g' | \
-		xargs $(AR) cDPrST $@
+	$(if $(real-prereqs), printf "$(obj)/%s " $(patsubst $(obj)/%,%,$(real-prereqs)) | xargs) \
+	$(AR) cDPrST $@
 
 $(obj)/built-in.a: $(real-obj-y) FORCE
 	$(call if_changed,ar_builtin)
Signature · 1 line
2.32.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 2 lines · Masahiro Yamada

Replace a pipeline of echo and sed with printf to decrease process forks.

If you're trying to minimize process forks, is it possible to remove the use of xargs as well and just invoke $(AR) with the parameters splatted out? I don't know myself, but maybe you're creative enough?

Otherwise,

Quoted 29 lines

---

Changes in v2:
- Avoid the pipeline if there is no object to put in the archive

 scripts/Makefile.build | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
scripts/Makefile.build +2 -4
index cac070aee791..784f46d41959 100644
@@ -358,9 +358,8 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
 
 quiet_cmd_ar_builtin = AR      $@
       cmd_ar_builtin = rm -f $@; \
-               echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \
-               sed -E 's:([^ ]+):$(obj)/\1:g' | \
-               xargs $(AR) cDPrST $@
+       $(if $(real-prereqs), printf "$(obj)/%s " $(patsubst $(obj)/%,%,$(real-prereqs)) | xargs) \
+       $(AR) cDPrST $@
 
 $(obj)/built-in.a: $(real-obj-y) FORCE
        $(call if_changed,ar_builtin)
--

2.32.0

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 8 lines · Nick Desaulniers
Quoted 2 lines · Masahiro Yamada

Replace a pipeline of echo and sed with printf to decrease process forks.

If you're trying to minimize process forks, is it possible to remove the use of xargs as well and just invoke $(AR) with the parameters splatted out? I don't know myself, but maybe you're creative enough?

If I remove xargs, we will go back to the situation before cd968b97c49214e6557381bddddacbd0e0fb696e.

This patch tries to avoid "too long argument error" without forking too many processes.
Maybe I am too worried about the potential issue, though...

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw
Quoted 12 lines · Masahiro Yamada
Quoted 8 lines · Nick Desaulniers
Quoted 2 lines · Masahiro Yamada

Replace a pipeline of echo and sed with printf to decrease process forks.

If you're trying to minimize process forks, is it possible to remove the use of xargs as well and just invoke $(AR) with the parameters splatted out? I don't know myself, but maybe you're creative enough?

Quoted 6 lines

If I remove xargs, we will go back to the situation before cd968b97c49214e6557381bddddacbd0e0fb696e.

This patch tries to avoid "too long argument error" without forking too many processes.
Maybe I am too worried about the potential issue, though...

From my very clouded perspective avoiding "too long argument error" should take priority :)