Closed nickdesaulniers closed 2 years ago
cc @Xuanwo @ojeda
IDK if this actually fixes the error; not sure how to forcibly make bindgen use this version. Also, not sure how to run the test suite:
$ cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running unittests src/lib.rs (target/debug/deps/clang_sys-a71dd1d1d018ae47)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/lib.rs (target/debug/deps/lib-ffd11d5bc5516370)
/tmp/clang-sys/target/debug/deps/lib-ffd11d5bc5516370: error while loading shared libraries: libclang.so.13: cannot open shared object file: No such file or directory
error: test failed, to rerun pass '--test lib'
/tmp/clang-sys/target/debug/deps/lib-ffd11d5bc5516370: error while loading shared libraries: libclang.so.13: cannot open shared object file: No such file or directory
$ find /android0/llvm-project/llvm/build/ | grep libclang.so
/android0/llvm-project/llvm/build/lib/libclang.so.15.0.0git
/android0/llvm-project/llvm/build/lib/libclang.so.13
/android0/llvm-project/llvm/build/lib/libclang.so
/android0/llvm-project/llvm/build/lib/libclang.so.14.0.0git
$ PATH=$PATH:/android0/llvm-project/llvm/build/lib cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running unittests src/lib.rs (target/debug/deps/clang_sys-a71dd1d1d018ae47)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/lib.rs (target/debug/deps/lib-ffd11d5bc5516370)
/tmp/clang-sys/target/debug/deps/lib-ffd11d5bc5516370: error while loading shared libraries: libclang.so.13: cannot open shared object file: No such file or directory
error: test failed, to rerun pass '--test lib'
ah, it's not PATH
I need, but LD_LIBRARY_PATH
:
$ LD_LIBRARY_PATH=/android0/llvm-project/llvm/build/lib cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running unittests src/lib.rs (target/debug/deps/clang_sys-a71dd1d1d018ae47)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/lib.rs (target/debug/deps/lib-ffd11d5bc5516370)
running 3 tests
test test_support ... FAILED
test test_support_target ... FAILED
test test ... ok
failures:
---- test_support stdout ----
thread 'test_support' panicked at 'called `Result::unwrap()` on an `Err` value: "could not run executable `/android0/llvm-project/clang`: Permission denied (os error 13)"', src/support.rs:188:58
---- test_support_target stdout ----
thread 'test_support_target' panicked at 'called `Result::unwrap()` on an `Err` value: "could not run executable `/android0/llvm-project/clang`: Permission denied (os error 13)"', src/support.rs:188:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
test_support
test_support_target
test result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
error: test failed, to rerun pass '--test lib
ok, I should now be able to test this.
now that I can test, I can see better what's going wrong. It's that we simply check that clang
is executable, but not not a directory.
$ git clone https://github.com/llvm/llvm-project.git --depth=1
$ stat -c "%a %n" llvm-project/clang
755 llvm-project/clang
$ ls -l llvm-project
...
drwxr-xr-x 14 ndesaulniers primarygroup 4096 May 24 16:20 clang
...
so by having that in my PATH; we're finding that, and it does have the executable bit set, but it's a directory.
omg, I set an env var in my ~/.zshrc
ages ago called CLANG_PATH
so I could cd $CLANG_PATH
quickly. What an (awful) coincidence.
$ unset CLANG_PATH
If $CLANG_PATH is set, but doesn't point to a clang binary (but say, the source code directory of clang) bindgen will fail with cryptic errors pointing back to clang-sys:
Check this env var points to an executable file or ignore it.
Fixes #138