* [PATCH] rust: Use awk instead of recent xargs
@ 2023-09-28 20:21 Matthew Maurer
2023-09-28 20:32 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Maurer @ 2023-09-28 20:21 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
Cc: Matthew Maurer, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, rust-for-linux,
linux-kernel
`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).
Signed-off-by: Matthew Maurer <mmaurer@google.com>
---
rust/Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index 87958e864be0..0efc5b5cd611 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -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)
--
2.42.0.582.g8ccd20d70d-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: Use awk instead of recent xargs
2023-09-28 20:21 [PATCH] rust: Use awk instead of recent xargs Matthew Maurer
@ 2023-09-28 20:32 ` Joe Perches
2023-09-29 21:36 ` David Laight
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2023-09-28 20:32 UTC (permalink / raw)
To: Matthew Maurer, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, rust-for-linux, linux-kernel
On Thu, 2023-09-28 at 20:21 +0000, Matthew Maurer wrote:
> `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).
[]
> diff --git a/rust/Makefile b/rust/Makefile
[]
> @@ -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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] rust: Use awk instead of recent xargs
2023-09-28 20:32 ` Joe Perches
@ 2023-09-29 21:36 ` David Laight
2023-09-29 23:29 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: David Laight @ 2023-09-29 21:36 UTC (permalink / raw)
To: 'Joe Perches', Matthew Maurer, Miguel Ojeda, Alex Gaynor,
Wedson Almeida Filho
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
From: Joe Perches
> Sent: 28 September 2023 21:33
>
> On Thu, 2023-09-28 at 20:21 +0000, Matthew Maurer wrote:
> > `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).
> []
> > diff --git a/rust/Makefile b/rust/Makefile
> []
> > @@ -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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: Use awk instead of recent xargs
2023-09-29 21:36 ` David Laight
@ 2023-09-29 23:29 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2023-09-29 23:29 UTC (permalink / raw)
To: David Laight, Matthew Maurer, Miguel Ojeda, Alex Gaynor,
Wedson Almeida Filho
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
On Fri, 2023-09-29 at 21:36 +0000, David Laight wrote:
> From: Joe Perches
> > Sent: 28 September 2023 21:33
> >
> > On Thu, 2023-09-28 at 20:21 +0000, Matthew Maurer wrote:
> > > `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).
> > []
> > > diff --git a/rust/Makefile b/rust/Makefile
> > []
> > > @@ -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.)
>
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 } }'
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-29 23:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-28 20:21 [PATCH] rust: Use awk instead of recent xargs Matthew Maurer
2023-09-28 20:32 ` Joe Perches
2023-09-29 21:36 ` David Laight
2023-09-29 23:29 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).