Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"This crate only supports libclang 3.5 and later" with libclang 3.8 identified #163

Open
ydirson opened this issue Nov 16, 2023 · 2 comments

Comments

@ydirson
Copy link

ydirson commented Nov 16, 2023

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?

@ydirson
Copy link
Author

ydirson commented Nov 17, 2023

Note that Debian 9 (2017) also has 3.8 and shows the same error message.

@KyleMayes
Copy link
Owner

KyleMayes commented Jan 3, 2024

The error message is correct:

  • The minimum version of libclang supported by clang-sys is 3.5
  • The version of libclang you have loaded is 3.8.x
  • clang_getTranslationUnitTargetInfo is not supported by 3.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants