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

Documentation around libclang version is confusing #2446

Closed
cgmckeever opened this issue Mar 16, 2023 · 2 comments
Closed

Documentation around libclang version is confusing #2446

cgmckeever opened this issue Mar 16, 2023 · 2 comments

Comments

@cgmckeever
Copy link

cgmckeever commented Mar 16, 2023

error came up using during an install, and was guided to post here

During an installation, with libclang-3.9 installed, the installer errors with libclang 3.9 or later is needed

The docs (referenced as installing-clang-39) then state It is required to use Clang 5.0 or greater ... clarification of this in the installer output would make troubleshooting a bit more straightforward.

Actual Results

thread 'main' panicked at '`libclang` function not loaded: `clang_getTranslationUnitTargetInfo`. 
This crate requires that `libclang` 3.9 or later be installed on your system. 
For more information on how to accomplish this, see here: https://rust-lang.github.io/rust-bindgen/requirements.html#installing-clang-39', /home/ubuntu/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/clang-sys-1.6.0/src/lib.rs:1735:1
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected Results

Update the output to properly reference the libclang-5.0 dependency

Steps

apt-get install fuse libfuse-dev cmake clang-3.9 libclang-3.9-dev pkg-config llvm-dev 
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
git clone --recurse-submodules https://github.com/awslabs/mountpoint-s3.git

export LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu/
cd mountpoint-s3; cargo build --release

resolution

apt-get install libclang-5.0-dev

@pvdrz
Copy link
Contributor

pvdrz commented Mar 20, 2023

I find this very confusing as clang-sys documentation states that the minimum version where that function is available happens to be 5.0 and not 3.9: https://docs.rs/clang-sys/latest/clang_sys/clang_getTranslationUnitTargetInfo/index.html.

However, this panic is happening inside clang-sys. if you go to clang-sys/src/link.rs:144 you'll find this:

            pub unsafe fn $name($($pname: $pty), *) $(-> $ret)* {
                let f = with_library(|l| {
                    l.functions.$name.expect(concat!(
                        "`libclang` function not loaded: `",
                        stringify!($name),
                        "`. This crate requires that `libclang` 3.9 or later be installed on your ",
                        "system. For more information on how to accomplish this, see here: ",
                        "https://rust-lang.github.io/rust-bindgen/requirements.html#installing-clang-39"))
                }).expect("a `libclang` shared library is not loaded on this thread");
                f($($pname), *)
            }

Which gives me the impression that clang-sys is just printing that every function that cannot be loaded requires clang 3.9 or later and just happens to refer to the bindgen user guide.

I suspect this is a clang-sys issue and it is not hard to fix as is it just a matter of either printing the right version for each function or changing the panic message stating that the user should check the documentation for the right version.

However, I'm not familiar with clang-sys codebase so I'm pinging @KyleMayes to be sure.

@KyleMayes
Copy link
Contributor

I just released clang-sys v1.6.1 that improves (I hope) the error messages for unloaded functions.

The error message for the issue from the Actual Results section from the initial comment would now look like this:

A `libclang` function was called that is not supported by the loaded `libclang` instance.

    called function = `clang_getTranslationUnitTargetInfo`
    loaded `libclang` instance = 3.9.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

@pvdrz pvdrz closed this as completed Apr 4, 2023
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

3 participants