fix: Support opt-out of static linking via LIBZ_SYS_STATIC=0
#252
+20
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change refactors the
want_staticlogic to additionally supportLIBZ_SYS_STATIC=0as an explicit opt-out to thestaticfeature whenlibz-sysis a transitive dependency and the build environment prefers to dynamic linklibzinstead.I've inlined some rough commentary should it help grokking the helper method to maintainers (and any future contributors), with clear intent of supporting opt-out from the crate's
staticfeature. This could probably do with some revision, along with user visible documentation of ENV precedence over the crate feature.Future work
A follow-up PR may want to further refactor the following with consideration of
LIBZ_SYS_STATICexplicitly forcing a linkage preference as opposed to convenience fallback/assumptions (the commentary was contributed some time ago and lacks further context/sources):libz-sys/build.rs
Lines 25 to 31 in 80c597a
libz-sys/build.rs
Lines 39 to 42 in 80c597a
libz-sys/build.rs
Lines 76 to 86 in 80c597a
libz-sys/build.rs
Lines 88 to 100 in 80c597a
Likewise a follow-up PR may want to consider dynamic link support for
zlib-ng:libz-sys/build.rs
Lines 16 to 23 in 80c597a
The zlib logic already enforces a build if
want_static == true, otherwise runs a test to check if a system library is available to link, and if not falls back to building from source.References
For anyone engaging on the topic/support, these might be of interest:
<CRATE>_NO_VENDOR=1(git, openssl)<CRATE>_USE_PKG_CONFIG=1(ssh, zstd, sqlite)<CRATE>_STATIC=0(pcre2, libz)