function not loaded: clang_createIndex for clang-9 and llvm-7
jyn514 opened this issue · comments
$ cargo check
Compiling yottadb v0.3.0 (/home/joshua/YDBRust)
error: failed to run custom build command for `yottadb v0.3.0 (/home/joshua/YDBRust)`
process didn't exit successfully: `/home/joshua/YDBRust/target/debug/build/yottadb-a199df30696d0c98/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=YOTTADB_NO_PKG_CONFIG
...
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rust-link-search=/usr/library/V999_R129/dbg
cargo:rerun-if-changed=wrapper.h
--- stderr
thread 'main' panicked at 'function not loaded: clang_createIndex', /home/joshua/.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.29.3/src/lib.rs:1659:1
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
$ head -n1 /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
Steps to replicate (on a debian machine):
$ echo 'deb http://deb.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list
$ sudo apt update && sudo apt install llvm-9 clang-9 llvm-7
$ cargo check
I ran into this for https://gitlab.com/YottaDB/Lang/YDBRust/-/commit/f18a07d1228a44074033c60bd6d9c192614e80a9, but I bet it would happen for any project using bindgen.
Backtrace
thread 'main' panicked at 'function not loaded: clang_createIndex', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.29.3/src/lib.rs:1659:1
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1117
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1508
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
9: std::panicking::default_hook
at src/libstd/panicking.rs:217
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:526
11: std::panicking::begin_panic
at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libstd/panicking.rs:456
12: clang_sys::clang_createIndex::{{closure}}
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.29.3/src/link.rs:159
13: clang_sys::with_library::{{closure}}
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.29.3/src/link.rs:146
14: std::thread::local::LocalKey<T>::try_with
at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libstd/thread/local.rs:263
15: std::thread::local::LocalKey<T>::with
at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libstd/thread/local.rs:239
16: clang_sys::with_library
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.29.3/src/link.rs:144
17: clang_sys::clang_createIndex
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-0.29.3/src/link.rs:156
18: bindgen::clang::Index::new
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/clang.rs:1523
19: bindgen::ir::context::BindgenContext::new
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/ir/context.rs:550
20: bindgen::Bindings::generate
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/lib.rs:2106
21: bindgen::Builder::generate
at /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/lib.rs:1419
22: build_script_build::main
at ./build.rs:34
23: std::rt::lang_start::{{closure}}
at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libstd/rt.rs:67
24: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:52
25: std::panicking::try::do_call
at src/libstd/panicking.rs:348
26: std::panicking::try
at src/libstd/panicking.rs:325
27: std::panic::catch_unwind
at src/libstd/panic.rs:394
28: std::rt::lang_start_internal
at src/libstd/rt.rs:51
29: std::rt::lang_start
at /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libstd/rt.rs:67
30: main
31: __libc_start_main
at ../csu/libc-start.c:308
32: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
I tried looking into this, here's my after action report:
- Your steps to replicate did not work in either Debian 8, 9, or 10 Docker containers since those versions of
llvm
andclang
were not available. I tried working around this by installingapt install llvm-10 clang-10 llvm-8
instead since those versions were available in the hope that this similar combination of versions would trigger a similar bug - I was then able to successfully run the
clang-sys
tests (which loads and usesclang_createIndex
) - I then attempted to run
cargo check
for this specific commit in theYDBRust
project. This failed because theyottadb
binaries were not installed - I attempted to remedy this by installing the
yottadb
binaries as specified on the Getting Started page, but I got some error about Debian x86-64 not being supported. I used the suggested installer option to force installation anyway - After installing and configuring
pkg-config
, I rancargo check
for the specific commit inYDBRust
and got about 10 compile errors about mutability mismatches (usingrustc
1.45.1)
At this point my natural laziness kicked in and I gave up.
If you got as far as mutability mismatches that means that bindgen was working, since I call bindgen in the build script.
those versions of llvm and clang were not available
Did you see the first step? They're only available from the testing repos.
Anyway I feel really bad for wasting your time, it turns out the issue is I didn't have libclang-9-dev
installed.