Repository navigation
Make the shipped package resolve its own zlib - #30
Merged
Merged
Conversation
RocksDBConfig resolves ZLIB in module mode, and vcpkg installs the static zlib as zs.lib - a name FindZLIB searches only when it knows the library is static. Every Windows target failed to configure the probe without it. Consumers of the archive need the same flag, so the README says so too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ZLIB_USE_STATIC_LIBS arrived in CMake 3.24 and the probe declared 3.20, so an older CMake would have ignored it and failed the same way. Consumers on an older CMake can name the library themselves; the README now says how. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The archive could not be consumed through its own RocksDBConfig on Windows: vcpkg installs the static zlib as zs.lib, which FindZLIB does not search by default, so find_package(RocksDB CONFIG) failed for every consumer. Fixing it in the probe would have hidden that from the one thing that tests it, so the portfile names the library in the config instead, the way vcpkg's own zlib wrapper does. MODULE keeps ZLIB::ZLIB defined for consumers preferring config. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The injected block relied on PACKAGE_PREFIX_DIR, which the dependencies imported above it leave holding one of their own prefixes on CMake 3.29 and older; it now derives the prefix from the config's own location. A missing library or header is a hard error rather than a silent fall back to the search that cannot find it, the header is pinned to the archive alongside the library, and the block is skipped when the consumer already has a usable ZLIB::ZLIB. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
REQUIRED on find_library needs CMake 3.18 and, worse, makes an optional find_package(RocksDB CONFIG) fatal when the archive is incomplete. Dropping it and the surrounding guards leaves the shape vcpkg has shipped for years, plus the two corrections this archive needs: the prefix taken from the config's own location, and MODULE so ZLIB::ZLIB is the target that gets defined. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the README and the RocksDB portfile to ensure the package can correctly resolve its static zlib dependency (such as zs.lib on Windows) automatically. In the portfile, it modifies RocksDBConfig.cmake to locate the release and debug zlib libraries relative to the package prefix. The review feedback recommends also finding and caching ZLIB_INCLUDE_DIR using the package's own include directory to prevent FindZLIB from failing to locate zlib.h when a consumer configures their project by setting RocksDB_DIR directly.
Pinning the library alone let the header come from somewhere else, or from nowhere: without the archive on CMAKE_PREFIX_PATH, FindZLIB reported the library found and ZLIB_INCLUDE_DIR missing. Gemini raised it on #30. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
cb1kenobi
marked this pull request as ready for review
October 9, 2026 20:10
This was referenced Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
⊙ Problem
Both
windows-x64targets failed in run 37962402212. The #29 generator fix worked — the log reachesBuilding the probe with Visual Studio 18 2026and detects MSVC 19.51 — and the run stops one step later:RocksDBConfigresolves ZLIB in module mode, and vcpkg installs the static zlib aszs.lib— a nameFindZLIBsearches only inside itsZLIB_USE_STATIC_LIBSbranch. Unix passed becausezis in the default list and matcheslibz.a.This is a defect in what we ship, not in the probe.
find_package(RocksDB CONFIG)has never worked on Windows for any consumer of these archives. It went unnoticed because nothing exercised it until the probe existed. All four published Windows archives of v11.8.1 carryzs.lib.💡 Solution
The first version of this fix set
ZLIB_USE_STATIC_LIBSin the probe. Review rejected it: that repairs the one thing that tests the archive and leaves every other consumer broken, so the probe would no longer detect the defect.The overlay portfile now patches the installed
RocksDBConfig.cmaketo name its own zlib, which is what vcpkg's own zlib wrapper does and needs no particular CMake version. The probe is a plain consumer again.Two corrections beyond the wrapper's shape, each from a confirmed finding:
PACKAGE_PREFIX_DIRis reset by every config file, so theSnappy,lz4andzstddependencies imported above leave it holding one of theirs on CMake 3.29 and older.find_dependency(ZLIB **MODULE**), becauseRocksDBTargetslinksZLIB::ZLIBand onlyFindZLIBdefines it — the zlib package installed beside it exportsZLIB::ZLIBSTATIC. WithoutMODULE, a consumer preferring config mode configures and then fails to link.🔧 Changes
vcpkg-overlays/rocksdb/portfile.cmakevcpkg_cmake_config_fixup, inject an archive-pinned zlib lookup ahead offind_dependency, deriving the prefix from the config's own directory and forcing module mode. A missing anchor is fatal at build time, so an upstream change to RocksDB's config cannot silently ship an unresolvable package.README.md✅ Verification
Route: a real local vcpkg install on
darwin-arm64plus consumer projects built against the resulting archive. The platform that actually failed cannot be reproduced here.Restored 0 package(s)and rebuilt both variants from source, so the portfile path really ran; the installed config carries the injection.nm59 vs 0, probeuser_key_comparison_count40,959 vs 0.cmake_minimum_required(VERSION 3.20)configures and links, resolvingZLIB::ZLIBto the archive's own library.CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON, and again with ZLIB already found in config mode: both resolve to the archive's library. Against the unpatched config,PREFER_CONFIGleavesZLIB::ZLIBundefined, which is the failure this closes.find_package(RocksDB CONFIG)stays non-fatal when the archive is incomplete.BZip2resolves asbz2.lib, and Snappy, lz4 and zstd ship CONFIG files. All six Unix archives carrylibz.a.Not verified here: that MSVC compiles and links the probe against the patched package.
build.ymlhas nopull_requesttrigger, so a dispatch is the only proof.Accepted limitations
Matching vcpkg's wrapper means inheriting its edges, each raised in review and left deliberately: a
find_librarymiss degrades toFindZLIB's default search rather than erroring; an absent debug zlib leavesZLIB_LIBRARY_DEBUGforFindZLIBto resolve; and a consumer-setZLIB_LIBRARYor a cached value from a previous prefix wins over the pin. Making any of these fatal would break optionalfind_package(RocksDB), which is why the first attempt atREQUIREDwas backed out.🤖 Generated by Claude (Anthropic); posted via @cb1kenobi.
Related PRs: #29 overlaps (fixed the generator this failure came after; merged), #28 overlaps (merged)
Complexity: medium
Review-Coverage: authored=claude; ran=gemini,codex,cursor-composer,cursor-muse; adjudicated=domain; blocked=cursor-grok(failed); declined=cursor-kimi; rounds=3; full=3 @ e51bfff
Review-Attention: study ~20m (critical: portfile.cmake; decisions: patch-generated-config, defer-to-consumer-zlib, static-libs-knob, prove-before-merge; raised: degraded review) @ e51bfff