kbuild: remove sed command from cmd_ar_builtin
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
@@ -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
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
Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2:
- Avoid the pipeline if there is no object to put in the archivescripts/Makefile.build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)scripts/Makefile.build +2
-4@@ -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
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
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 :)