"This crate only supports `libclang` 3.5 and later" with libclang 3.8 identified
ydirson opened this issue · comments
In a nuber f situations, eg. https://gitlab.com/xen-project/xen-guest-agent/-/jobs/5550556953 I find the following confusing error message:
A `libclang` function was called that is not supported by the loaded `libclang` instance.
called function = `clang_getTranslationUnitTargetInfo`
loaded `libclang` instance = 3.8.x
This crate only supports `libclang` 3.5 and later.
There is obviously a problem with the environment, but the error message is obviously wrong.
Digging with this little debug patch:
diff --git a/src/link.rs b/src/link.rs
index 07c4be3..3ae29de 100644
--- a/src/link.rs
+++ b/src/link.rs
@@ -173,6 +173,7 @@ macro_rules! link {
pub unsafe fn $name($($pname: $pty), *) $(-> $ret)* {
let f = with_library(|library| {
if let Some(function) = library.functions.$name {
+ eprintln!("found {} in {:?}", stringify!($name), library.path);
function
} else {
panic!(
... I see:
--- stdout
cargo:rustc-link-lib=xenstore
--- stderr
found clang_createIndex in "/usr/lib/llvm-3.8/lib/libclang-3.8.0.so"
found clang_parseTranslationUnit in "/usr/lib/llvm-3.8/lib/libclang-3.8.0.so"
thread 'main' panicked at /data/src/clang-sys/src/lib.rs:1735:1:
A `libclang` function was called that is not supported by the loaded `libclang` instance.
called function = `clang_getTranslationUnitTargetInfo`
loaded `libclang` instance = 3.8.x
This crate only supports `libclang` 3.5 and later.
The minimum `libclang` requirement for this particular function can be found here:
https://docs.rs/clang-sys/latest/clang_sys/clang_getTranslationUnitTargetInfo/index.html
Instructions for installing `libclang` can be found here:
https://rust-lang.github.io/rust-bindgen/requirements.html
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
found clang_disposeTranslationUnit in "/usr/lib/llvm-3.8/lib/libclang-3.8.0.so"
found clang_disposeIndex in "/usr/lib/llvm-3.8/lib/libclang-3.8.0.so"
And in fact:
$ nm -D /usr/lib/llvm-3.8/lib/libclang-3.8.0.so | grep clang_getTranslationUnitTargetInfo
$
That Ubuntu 16.04.7 LTS would seem to have a funky libclang?
Note that Debian 9 (2017) also has 3.8 and shows the same error message.
The error message is correct:
- The minimum version of
libclang
supported byclang-sys
is 3.5 - The version of
libclang
you have loaded is3.8.x
clang_getTranslationUnitTargetInfo
is not supported by3.8.x
(it requires Clang 5.0 or later)
The remainder of the error message links to the documentation for the function which should have a comment indicating the minimum version of Clang required for that function.
All that being said, I can see how the presence of This crate only supports libclang 3.5 and later.
in the error message could be a bit misleading, I will look into improving the error message further.