* [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT
@ 2024-07-27 14:02 Masahiro Yamada
2024-07-27 14:03 ` [PATCH 2/2] rust: fix the default format for CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Masahiro Yamada
2024-07-27 17:05 ` [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Miguel Ojeda
0 siblings, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2024-07-27 14:02 UTC (permalink / raw)
To: Miguel Ojeda, rust-for-linux; +Cc: linux-kernel, Masahiro Yamada
While this is a somewhat unusual case, I encountered odd error messages
when I ran Kconfig in a foreign architecture chroot.
$ make allmodconfig
sh: 1: rustc: not found
sh: 1: bindgen: not found
#
# configuration written to .config
#
The successful execution of 'command -v rustc' does not necessarily mean
that 'rustc --version' will succeed.
$ sh -c 'command -v rustc'
/home/masahiro/.cargo/bin/rustc
$ sh -c 'rustc --version'
sh: 1: rustc: not found
Here, 'rustc' is built for x86, and I ran it in an arm64 system.
The current code:
command -v $(RUSTC) >/dev/null 2>&1 && $(RUSTC) --version || echo n
can be turned into:
command -v $(RUSTC) >/dev/null 2>&1 && $(RUSTC) --version 2>/dev/null || echo n
However, I did not understand the necessity of 'command -v $(RUSTC)'.
I simplified it to:
$(RUSTC) --version 2>/dev/null || echo n
Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
init/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index c41260ffe99a..466849f9f1b9 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1919,12 +1919,12 @@ config RUST
config RUSTC_VERSION_TEXT
string
depends on RUST
- default $(shell,command -v $(RUSTC) >/dev/null 2>&1 && $(RUSTC) --version || echo n)
+ default $(shell,$(RUSTC) --version 2>/dev/null || echo n)
config BINDGEN_VERSION_TEXT
string
depends on RUST
- default $(shell,command -v $(BINDGEN) >/dev/null 2>&1 && $(BINDGEN) --version || echo n)
+ default $(shell,$(BINDGEN) --version 2>/dev/null || echo n)
#
# Place an empty function call at each tracepoint site. Can be
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] rust: fix the default format for CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT
2024-07-27 14:02 [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Masahiro Yamada
@ 2024-07-27 14:03 ` Masahiro Yamada
2024-07-27 17:13 ` Miguel Ojeda
2024-07-27 17:05 ` [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Miguel Ojeda
1 sibling, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2024-07-27 14:03 UTC (permalink / raw)
To: Miguel Ojeda, rust-for-linux; +Cc: linux-kernel, Masahiro Yamada
Another oddity in these config entries is their default value can fall
back to 'n', which is a value for bool or tristate symbols.
The '|| echo n' is an incorrect workaround to avoid the syntax error.
This is not a big deal, as the entry is hidden by 'depends on RUST' in
situations where '$(RUSTC) --version' or '$(BINDGEN) --version' fails.
Anyway, it looks odd.
The default of a string type symbol should be a double-quoted string
literal. Turn it into an empty string when the version command fails.
Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
init/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/init/Kconfig b/init/Kconfig
index 466849f9f1b9..47e074a93d94 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1919,12 +1919,12 @@ config RUST
config RUSTC_VERSION_TEXT
string
depends on RUST
- default $(shell,$(RUSTC) --version 2>/dev/null || echo n)
+ default "$(shell,$(RUSTC) --version 2>/dev/null)"
config BINDGEN_VERSION_TEXT
string
depends on RUST
- default $(shell,$(BINDGEN) --version 2>/dev/null || echo n)
+ default "$(shell,$(BINDGEN) --version 2>/dev/null)"
#
# Place an empty function call at each tracepoint site. Can be
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT
2024-07-27 14:02 [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Masahiro Yamada
2024-07-27 14:03 ` [PATCH 2/2] rust: fix the default format for CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Masahiro Yamada
@ 2024-07-27 17:05 ` Miguel Ojeda
2024-07-28 8:02 ` Masahiro Yamada
1 sibling, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2024-07-27 17:05 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Miguel Ojeda, rust-for-linux, linux-kernel
On Sat, Jul 27, 2024 at 4:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> The successful execution of 'command -v rustc' does not necessarily mean
> that 'rustc --version' will succeed.
+1, it could also be e.g. non-executable.
By the way, I was checking recently `pahole-version.sh` for a series I
will send about `RUSTC_VERSION` and I saw that one has a `[ ! -x`
check after the `command -v` for the non-executable case. But taking
into account what you say here, I wonder if something needs to be done
there too, e.g.
$ echo 'bad' > bad-pahole
$ chmod u+x bad-pahole
$ make PAHOLE=./bad-pahole defconfig
...
./bad-pahole: 1: bad: not found
init/Kconfig:112: syntax error
init/Kconfig:112: invalid statement
So perhaps we can put in pahole-version.sh something like:
if output=$("$@" --version 2>/dev/null); then
echo $output | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
else
echo 0
exit 1
fi
i.e. similar to what you do here for `rustc`/`bindgen`.
> However, I did not understand the necessity of 'command -v $(RUSTC)'.
I agree, I don't think it is needed.
If you want to take it through your tree:
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>
Otherwise, I can take it too.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT
2024-07-27 17:05 ` [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Miguel Ojeda
@ 2024-07-28 8:02 ` Masahiro Yamada
2024-07-29 12:46 ` Miguel Ojeda
0 siblings, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2024-07-28 8:02 UTC (permalink / raw)
To: Miguel Ojeda; +Cc: Miguel Ojeda, rust-for-linux, linux-kernel
On Sun, Jul 28, 2024 at 2:05 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Sat, Jul 27, 2024 at 4:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > The successful execution of 'command -v rustc' does not necessarily mean
> > that 'rustc --version' will succeed.
>
> +1, it could also be e.g. non-executable.
>
> By the way, I was checking recently `pahole-version.sh` for a series I
> will send about `RUSTC_VERSION` and I saw that one has a `[ ! -x`
> check after the `command -v` for the non-executable case. But taking
> into account what you say here, I wonder if something needs to be done
> there too, e.g.
>
> $ echo 'bad' > bad-pahole
> $ chmod u+x bad-pahole
> $ make PAHOLE=./bad-pahole defconfig
> ...
> ./bad-pahole: 1: bad: not found
> init/Kconfig:112: syntax error
> init/Kconfig:112: invalid statement
>
> So perhaps we can put in pahole-version.sh something like:
>
> if output=$("$@" --version 2>/dev/null); then
> echo $output | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
> else
> echo 0
> exit 1
> fi
>
> i.e. similar to what you do here for `rustc`/`bindgen`.
Agree.
pahole-version.sh should be fixed too.
>
> > However, I did not understand the necessity of 'command -v $(RUSTC)'.
>
> I agree, I don't think it is needed.
>
> If you want to take it through your tree:
>
> Acked-by: Miguel Ojeda <ojeda@kernel.org>
> Tested-by: Miguel Ojeda <ojeda@kernel.org>
>
> Otherwise, I can take it too.
Yes, please take this to your tree. Thanks.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-29 12:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-27 14:02 [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Masahiro Yamada
2024-07-27 14:03 ` [PATCH 2/2] rust: fix the default format for CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Masahiro Yamada
2024-07-27 17:13 ` Miguel Ojeda
2024-07-27 17:05 ` [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT Miguel Ojeda
2024-07-28 8:02 ` Masahiro Yamada
2024-07-29 12:46 ` Miguel Ojeda
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).