Re: [PATCH] scripts: rust_is_available: check for empty libclang version

From: Martin Rodriguez Reboredo
Date: Sun May 07 2023 - 19:16:05 EST


On 5/7/23 05:41, Matthew Leach wrote:
If bindgen can't find libclang, then bindgen will panic with the
following error:

thread 'main' panicked at 'Unable to find libclang: "couldn't find any
valid shared libraries matching: ['libclang.so', 'libclang-*.so',
'libclang.so.*', 'libclang-*.so.*'], set the `LIBCLANG_PATH` environment
variable to a path where one of these files can be found.

This is outputted to stderr, leaving stdout empty. The empty string is
then passed to get_canonical_version and the following is show to the
user:

$ make LLVM=1 rustavailable
./scripts/rust_is_available.sh: line 21: 100000 * + 100 * + : syntax error: operand expected (error token is "+ ")
make: *** [Makefile:1825: rustavailable] Error 1

Note: bindgen's bad exit code isn't caught by 'set -e' since it is ran
in a subshell.

Fix this by prnting out a more helpful error message if the output of
bindgen is empty.

Signed-off-by: Matthew Leach <dev@xxxxxxxxxxxxx>
---
[...]

Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@xxxxxxxxx>