Re: [PATCH 1/2] rust: suppress error messages from CONFIG_{RUSTC,BINDGEN}_VERSION_TEXT

From: Miguel Ojeda
Date: Sat Jul 27 2024 - 13:05:55 EST


On Sat, Jul 27, 2024 at 4:03 PM Masahiro Yamada <masahiroy@xxxxxxxxxx> 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@xxxxxxxxxx>
Tested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>

Otherwise, I can take it too.

Cheers,
Miguel