Description
libz-sys
should have a configuration option like ZLIB(_LIB|_INCLUDE)_DIR
which allows you to explicitly point at which zlib
to use on all platforms, similar to what openssl-sys
does with OPENSSL(_LIB|_INCLUDE)_DIR
(documentation).
If those environment variables are unset, then libz-sys
should continue to use vcpkg
, pkg-config
or system paths to find zlib
.
Additionally, vendoring should be behind a feature flag, disabled by default, so that libz-sys
failng to find zlib
is a hard error by default:
-
While auto-vendoring makes
libz-sys
build in more scenarios with zero configuration, it leads to surprising behaviour, and makes it more difficult to track down your dependencies. Again, this is something thatopenssl-sys
does well. -
There's also no way to reliably force the library to be vendored, except by setting the
static
option - which is itself implemented incorrectly, as it never checks for a system-installed staticzlib
except withvcpkg
.
These changes would require a major version bump, as they're SemVer incompatible changes, and will likely break some environments until they can be fixed up.
Some related issues include:
- Build failure in msys2 in windows after updating from 1.1.9 to 1.1.10 #143 (caused by
curl-sys
' auto-vendoring having a transitive dependency onlibz-sys
buildingzlib
from source on Windows; which was only noticed whenlibz-sys
improved its dependency management so it didn't auto-vendor) - when cross-compiling it never uses pre-build (static) library and
zlib_installed
does not use the correct flags #132 (cross compiling not using system zlib or correct flags) - Support using pkg-config for zlib-ng #110 (wants to use
pkg-config
withzlib-ng
, but there's no controls) - crate wants to install to /usr/local during building #109 (
zlib-ng
build process tries to install to/usr/local
as part of a fall-back) - Linking fails on Windows if other -sys crates link to the system zlib #56 (statically linking two different versions of
zlib
doesn't work)
#83 has a similar request to disable auto-vendoring for zlib-ng
.