Add new feature flag "static"#159
Add new feature flag "static"#159NobodyXu wants to merge 2 commits intogyscos:masterfrom NobodyXu:master
Conversation
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
|
Not sure why the CI for windows i686 failed. |
| // println!("cargo:rustc-link-lib=zstd"); | ||
| let (defs, headerpaths) = if cfg!(feature = "pkg-config") { | ||
| let (defs, headerpaths) = if cfg!(feature = "pkg-config") | ||
| && !cfg!(feature = "static") |
There was a problem hiding this comment.
I think we should make it an error to have both pkg-config and static features, rather than silently dropping one.
There was a problem hiding this comment.
I prefer static to override pkg-config, since it is possible for one dependency to request pkg-config and another to request static.
In this situation, it is not always possible to modify or it maybe hard to remove that and I would prefer statically linked to dynamically linked zstd.
There was a problem hiding this comment.
If a dependency asks for pkg-config, we should honor this decision and not discard it.
Though in general asking for pkg-config is not something re-usable libraries should be doing, it's more of a end-of-the-line binary decision.
|
Note that static linking is already the default.
The main reason to add a static feature (and it may be a valid one!) is to detect if the situation ever changes: if some dependency starts requiring Also note that pkg-config does not have to result in dynamic linking. It will try static linking if the In that case, it may be better to detect when pkg-config fails to enable static linking (it uses a private function to check that), and only then trigger a build failure. |
|
@gyscos I just realized that |
It's an unfortunate decision, as it does not appear to make this very visible to the caller. Seems like there's some demand to change things, but nothing done so far: rust-lang/pkg-config-rs#68 |
Resolved #158
Signed-off-by: Jiahao XU Jiahao_XU@outlook.com