rust-bio / rust-htslib

This library provides HTSlib bindings and a high level Rust API for reading and writing BAM files.
MIT License
302 stars 77 forks source link

0.47.0 introduced a dependency on libclang #434

Open DaGaMs opened 3 months ago

DaGaMs commented 3 months ago

I tried to upgrade my code's dependency on rust-htslib to version 0.47.0 (from 0.46.0) but now when I do cargo build -r on Linux (eg in a docker container) without clang, I get:

thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.69.4/lib.rs:622:31:

Unable to find libclang: "couldn't find any valid shared libraries matching: ['[libclang.so](http://libclang.so/)', 'libclang-*.so', '[libclang.so](http://libclang.so/).*', 'libclang-*.so.*'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"

Reverting back to 0.46.0 fixes the issue. I'm not sure what happened here, but I suspect it was not intentional?

moold commented 2 months ago

I also got a cargo build --release problem when I used rust-htslib v0.47.0, reverting to v0.46.0 solved the problem.

  --- stderr
  ./htslib/htslib/hts.h:31:10: fatal error: 'stddef.h' file not found
  thread 'main' panicked at hts-sys-2.1.4/build.rs:275:14:
  Unable to generate bindings.: ClangDiagnostic("./htslib/htslib/hts.h:31:10: fatal error: 'stddef.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fxwiegand commented 2 months ago

I think i also ran into this a while ago. @FelixMoelder i think this might be caused by this recent change:

https://github.com/rust-bio/rust-htslib/blob/5eb729bf35ea653688ac25f6cea82bc6e06c9442/Cargo.toml#L24

DaGaMs commented 2 months ago

So, this is probably related to this feature request in bindgen:

https://github.com/rust-lang/rust-bindgen/issues/918

What I don't understand is: why does 0.46.0 work but 0.47.0 doesn't? If dependency on libclang.a is a general issue of bindgen, then why does 0.46.0 build fine for me? And vice versa, why does adding one header to hts-sys suddenly break things? 🤔