rust-lang / rust-lang/libz-sys
Add ZLIB_DIR config option, and don't vendor zlib or zlib-ng automatically
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 138
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
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-sysbuild 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-sysdoes well. -
There's also no way to reliably force the library to be vendored, except by setting the
staticoption - which is itself implemented incorrectly, as it never checks for a system-installed staticzlibexcept 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:
- #143 (caused by
curl-sys' auto-vendoring having a transitive dependency onlibz-sysbuildingzlibfrom source on Windows; which was only noticed whenlibz-sysimproved its dependency management so it didn't auto-vendor) - #132 (cross compiling not using system zlib or correct flags)
- #110 (wants to use
pkg-configwithzlib-ng, but there's no controls) - #109 (
zlib-ngbuild process tries to install to/usr/localas part of a fall-back) - #56 (statically linking two different versions of
zlibdoesn't work)
#83 has a similar request to disable auto-vendoring for zlib-ng.
Contributor guide
No contributing guide indexed for this repository
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 with build.rs, especially the existing static option and the vcpkg, pkg-config, and system discovery paths. Compare the referenced openssl-sys build logic and configuration documentation. Done means explicit ZLIB(_LIB|_INCLUDE)_DIR handling across platforms, opt-in rather than default vendoring, and a hard error when no usable zlib is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100