rust-lang / rust-lang/rust-bindgen
Bindgen features not additive
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
If you have two different dependencies that both depend on bindgen, but dependency A uses static linking and dependency B using dynamic linking, this will fail to build.
You can test this easily with the following Cargo.toml:
[dependencies]
bindgen57 = { version = "0.57", package = "bindgen", default-features = false, features = ["static"] }
bindgen58 = { version = "0.58", package = "bindgen", default-features = false, features = ["runtime"] }
Cargo features are supposed to be additive, i.e. one crate in your dependency tree should never fail to build because another crate elsewhere in your dependency tree enables some feature.
There's also a related issue where if you do something like this:
[dependencies]
bindgen57 = { version = "0.57", package = "bindgen", default-features = false }
bindgen58 = { version = "0.58", package = "bindgen", default-features = false, features = ["runtime"] }
This will build, but it will panic at runtime:
thread 'main' panicked at 'a `libclang` shared library is not loaded on this thread', .../.cargo/registry/src/github.com-1ecc6299db9ec823/clang-sys-1.2.0/src/lib.rs:1682:1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing both dependency combinations from the issue's Cargo.toml examples, including the static/runtime feature combinations. Then inspect bindgen's feature definitions and the related clang-sys behavior referenced in the panic and linked issue. Done means feature combinations remain additive, both dependency versions build, and the runtime panic no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100