scripts/rust_is_available.sh | 9 +++++++++ 1 file changed, 9 insertions(+)
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@mattleach.net>
---
scripts/rust_is_available.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/scripts/rust_is_available.sh b/scripts/rust_is_available.sh
index aebbf1913970..e5478429841c 100755
--- a/scripts/rust_is_available.sh
+++ b/scripts/rust_is_available.sh
@@ -107,6 +107,15 @@ bindgen_libclang_version=$( \
| head -n 1 \
)
bindgen_libclang_min_version=$($min_tool_version llvm)
+if [ -z "$bindgen_libclang_version" ]; then
+ if [ "$1" = -v ]; then
+ echo >&2 "***"
+ echo >&2 "*** libclang could not be found by bindgen. Ensure that LIBCLANG_PATH"
+ echo >&2 "*** is set correctly."
+ echo >&2 "***"
+ fi
+ exit 1;
+fi
bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version)
bindgen_libclang_min_cversion=$(get_canonical_version $bindgen_libclang_min_version)
if [ "$bindgen_libclang_cversion" -lt "$bindgen_libclang_min_cversion" ]; then
--
2.39.2
On Sun, May 7, 2023 at 10:41 AM Matthew Leach <dev@mattleach.net> 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@mattleach.net>
Thanks a lot for this patch! This was previously reported and should
be fixed in this patch series (I added you as a reporter in v2):
https://lore.kernel.org/rust-for-linux/20230616001631.463536-1-ojeda@kernel.org/
If you could please test the series, to make sure it solves your
issue, it would be great!
Cheers,
Miguel
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@mattleach.net> > --- > [...] Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
© 2016 - 2026 Red Hat, Inc.