-
Notifications
You must be signed in to change notification settings - Fork 729
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
Bindgen features not additive #2030
Comments
Yeah, this was known when taking #1617, but there didn't seem to be a lot of better solutions to this problem. Better ideas def. welcome. |
You need to choose one of the features to override the other. It's not really clear to me what the difference is between “no features”, the “runtime feature”, but I'd suggest: (default behavior): dynamic linking Also, IIUC, if static feature is enabled by clang-sys, you need to call it in a different way. So then the existence of this feature should be propagated by clang-sys's build script to dependents using the |
Another option would be that the dependents that want static linking get static linking, and the ones that want dynamic linking get dynamic linking? You'd need two separate crates, or types, or a builder to do this properly. |
I need to page this back in, but IIRC the problem is that there are effectively three behaviors, not two:
|
Ah, that makes sense. So yeah you have to make a choice between static and dynamic. But runtime could be used independently, assuming symbols are sufficiently namespaced? |
I ran into this issue when trying to use both example
|
Also, if this isn’t fixed in the code, it should at least be documented to make users aware of this issue and how to fix it. |
Per rust-lang/rust-bindgen#2030, this seems to interact poorly with other bindgen dependents that also specify `features = ["runtime"]` (and perhaps other dependents that don't specify `default-features = "false"` at all).
Perhaps a solution based on |
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:
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:
This will build, but it will panic at runtime:
See also KyleMayes/clang-sys#128
The text was updated successfully, but these errors were encountered: