rust-lang / rust-lang/libz-sys

Add ZLIB_DIR config option, and don't vendor zlib or zlib-ng automatically

Open
#147 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
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-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 that openssl-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 static zlib except with vcpkg.

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 on libz-sys building zlib from source on Windows; which was only noticed when libz-sys improved its dependency management so it didn't auto-vendor)
  • #132 (cross compiling not using system zlib or correct flags)
  • #110 (wants to use pkg-config with zlib-ng, but there's no controls)
  • #109 (zlib-ng build process tries to install to /usr/local as part of a fall-back)
  • #56 (statically linking two different versions of zlib doesn'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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.