rust: Use awk instead of recent xargs
PATCH 1/1 rust: Use awk instead of recent xargs
awk is already required by the kernel build, and the xargs feature used in current Rust detection is not present in all xargs (notably, toybox based xargs, used in the Android kernel build).
--- rust/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
rust/Makefile +1 -2
@@ -365,8 +365,7 @@ quiet_cmd_exports = EXPORTS $@ cmd_exports = \ $(NM) -p --defined-only $< \ | grep -E ' (T|R|D) ' | cut -d ' ' -f 3 \ - | xargs -Isymbol \ - echo 'EXPORT_SYMBOL_RUST_GPL(symbol);' > $@ + | awk 'NF {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$0}' > $@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE $(call if_changed,exports)
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
Quoted 3 lines · Matthew Maurer
awkis already required by the kernel build, and thexargsfeature used in current Rust detection is not present in allxargs(notably, toybox based xargs, used in the Android kernel build).
[]
rust/Makefile
Quoted 1 line
rust/Makefile +0
-0
[]
rust/Makefile quiet_cmd_exports = EXPORTS $@ · line 368
Quoted 7 lines
rust/Makefile +1
-2@@ -365,8 +365,7 @@ quiet_cmd_exports = EXPORTS $@ cmd_exports = \ $(NM) -p --defined-only $< \ | grep -E ' (T|R|D) ' | cut -d ' ' -f 3 \ - | xargs -Isymbol \ - echo 'EXPORT_SYMBOL_RUST_GPL(symbol);' > $@ + | awk 'NF {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$0}' > $@
Perhaps remove the cut as well and use $$3 instead of $$0 ? Maybe integrate the grep as well.
From: Joe Perches
Quoted 9 lines
Sent: 28 September 2023 21:33
Quoted 3 lines · Matthew Maurer
awkis already required by the kernel build, and thexargsfeature used in current Rust detection is not present in allxargs(notably, toybox based xargs, used in the Android kernel build).[]
rust/Makefile
Quoted 1 line
rust/Makefile +0
-0[]
Quoted 10 lines
rust/Makefile quiet_cmd_exports = EXPORTS $@ · line 368
Quoted 7 lines
rust/Makefile +1
-2@@ -365,8 +365,7 @@ quiet_cmd_exports = EXPORTS $@ cmd_exports = \ $(NM) -p --defined-only $< \ | grep -E ' (T|R|D) ' | cut -d ' ' -f 3 \ - | xargs -Isymbol \ - echo 'EXPORT_SYMBOL_RUST_GPL(symbol);' > $@ + | awk 'NF {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$0}' > $@Perhaps remove the cut as well and use $$3 instead of $$0 ? Maybe integrate the grep as well.
Or keep the grep and use a shell loop?
grep -E ' (T|R|D) ' | while read val flag symbol; do \ echo "EXPORT_SYMBOL_RUST_GPL($symbol);"; done
(The grep is typically much faster than a shell conditional.)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Quoted 21 lines · David Laight
From: Joe Perches
Quoted 9 lines
Sent: 28 September 2023 21:33
Quoted 3 lines · Matthew Maurer
awkis already required by the kernel build, and thexargsfeature used in current Rust detection is not present in allxargs(notably, toybox based xargs, used in the Android kernel build).[]
rust/Makefile
Quoted 1 line
rust/Makefile +0
-0[]
Quoted 10 lines
rust/Makefile quiet_cmd_exports = EXPORTS $@ · line 368
Quoted 7 lines
rust/Makefile +1
-2@@ -365,8 +365,7 @@ quiet_cmd_exports = EXPORTS $@ cmd_exports = \ $(NM) -p --defined-only $< \ | grep -E ' (T|R|D) ' | cut -d ' ' -f 3 \ - | xargs -Isymbol \ - echo 'EXPORT_SYMBOL_RUST_GPL(symbol);' > $@ + | awk 'NF {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$0}' > $@Perhaps remove the cut as well and use $$3 instead of $$0 ? Maybe integrate the grep as well.
Quoted 6 lines
Or keep the grep and use a shell loop?
grep -E ' (T|R|D) ' | while read val flag symbol; do \ echo "EXPORT_SYMBOL_RUST_GPL($symbol);"; done(The grep is typically much faster than a shell conditional.)
Bikeshed:
no grep just a single awk with whatever the appropriate syntax is like
awk '{ if ($$2 ~ /^[TRD]$/) { printf "EXPORT_SYMBOL_RUST(%s);\n", $$3 } }'