Repository navigation
uv: link pkgs' libzstd instead of zstd-sys's vendored copy - #1738
Conversation
ZSTD_SYS_USE_PKG_CONFIG=1 with pkgconf + zstd as build deps, libzstd as a runtime dep, and a readelf check that uv NEEDs libzstd.so.1 (the same pattern as codex). A fix to pkgs' zstd then reaches uv without waiting for a zstd-sys release, and the C library is no longer compiled in every uv build. The generated lock-patch block, including its zstd-sys floor, is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
zstd 1.6.0 is on main now (pkgs#1694), so linking pkgs' libzstd no longer downgrades anything. Check the floor at build time so an older libzstd fails the build instead of shipping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Scope matches the title. The diff touches only packages/uv/build.ncl and packages/uv/build.sh, and every hunk traces to the libzstd change. The generated pkgmgr lock-patch block is untouched. The PR body is stale: it says the PR is blocked on #1694 and that pkgs' zstd is 1.5.7, but the branch already contains #1694 and packages/zstd/build.ncl is at 1.6.0.
Clobber none. git log on packages/uv and packages/zstd shows only the two PR commits and the merge of main.
Correctness The pattern matches packages/codex (pkgconf and zstd in build_deps, subsetOf zstd ["libzstd"] in runtime_deps, a readelf NEEDED check). pkgconf ships usr/bin/pkg-config, and zstd ships libzstd.pc and no libzstd.a. The lock patch moves zstd-sys to 2.2.0+zstd.1.6.0, which matches pkgs' zstd 1.6.0. The two existing Standalone tests start uv and uvx in the runtime closure, so a missing libzstd.so.1 fails them. Two low findings: one stale comment and one hardcoded floor.
Not checked Nothing was built. I did not read the zstd-sys 2.2.0 build script, so the claims that it honours ZSTD_SYS_USE_PKG_CONFIG and panics without libzstd.pc are unverified. The NEEDED check covers uv only, not uvx.
| # NEEDED check after the build fails closed if it ever links a bundled copy. | ||
| # The lock patch above moves zstd-sys to 2.2.0+zstd.1.6.0, whose bindings are | ||
| # for zstd 1.6.0; the functions zstd-safe calls through them (the dictionary | ||
| # *_advanced / byReference ones) are all exported by libzstd 1.5.7 already. |
There was a problem hiding this comment.
low · This sentence describes a state that the code is no longer in. It justifies ABI safety against libzstd 1.5.7, but pkgs' zstd is 1.6.0 (packages/zstd/build.ncl:22) and the guard at line 89 refuses anything older. The next reader will think that uv links 1.5.7 with 1.6.0 bindings. Delete the sentence, or say that the bindings and the library are both 1.6.0. This is the only such comment in the repo.
There was a problem hiding this comment.
Fixed in the latest push: the 1.5.7 sentence is gone.
| if ! pkg-config --atleast-version=1.6.0 libzstd; then | ||
| echo "ERROR: libzstd $(pkg-config --modversion libzstd) is older than 1.6.0 (CVE-2026-124851)" >&2 | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
low · The comment states the rule as "not older than the copy that zstd-sys vendors", but the check is the literal 1.6.0. The vendored version comes from Cargo.lock, which pkgmgr lock-patch regenerates on every uv bump. When the lock moves to a zstd-sys that vendors a later zstd, this guard still passes on 1.6.0 and the downgrade it exists to stop goes through unnoticed. Read the floor from the lock (the +zstd.X.Y.Z suffix of the zstd-sys version) so the guard follows the lock. Codex, the only other ZSTD_SYS_USE_PKG_CONFIG user, has no floor at all.
There was a problem hiding this comment.
Fixed in the latest push. The floor is read from the lock now: the +zstd.X.Y.Z suffix of zstd-sys in the patched Cargo.lock, and the build fails if there's none. 1.6.0 stays as a floor of its own for CVE-2026-124851. A lock regeneration that moves zstd-sys to a later vendored zstd raises the guard with it.
The guard checked the literal 1.6.0 while its comment called it the zstd that zstd-sys vendors; a lock regeneration that moves zstd-sys to a later vendored zstd would have left the guard at 1.6.0. Read the floor from the `+zstd.X.Y.Z` suffix of zstd-sys in Cargo.lock (fail if absent) and keep 1.6.0 as its own floor (CVE-2026-124851). Drop the sentence about libzstd 1.5.7, a state the code is no longer in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
uv links pkgs'
libzstdinstead of the copy vendored inzstd-sys:ZSTD_SYS_USE_PKG_CONFIG=1.pkgconfandzstdas build deps, andsubsetOf zstd ["libzstd"]as a runtime dep.readelfcheck fails the build unlessuvhasNEEDED libzstd.so.1.This is the same pattern as codex (#1713,
packages/codex/build.sh).The generated
pkgmgr lock-patchblock is untouched, and so is its zstd-sys floor (RUSTSEC-2026-0410). That advisory concerns the wasm32 allocator shim only, so it doesn't apply on our targets either way.Why
Evidence and one caveat
Cargo.lockat 0.13.10 has zstd-sys2.1.0+zstd.1.5.7. However, the effective lock is different:security-floors-lock.patchmoves zstd-sys to2.2.0+zstd.1.6.0as a companion of the zstd-safe floors. Its pregenerated bindings are for zstd 1.6.0, while pkgs zstd is 1.5.7. So for uv this is not "same version": the C library effectively goes from the bundled 1.6.0 to the system 1.5.7.ZSTD_CCtx_loadDictionary_advanced,ZSTD_DCtx_loadDictionary_advanced,ZSTD_createDDict_byReferenceandZSTD_getFrameHeader.ZSTDLIB_STATIC_APIin zstd 1.5.7'szstd.h, which means visible and exported fromlibzstd.so. pkgs' zstd build doesn't hide them.ZSTD_FrameHeaderhas the same layout, and the enum values are unchanged.zstd-sys'spkg_config()panics whenlibzstdisn't found (.expect), so there is no silent fallback. The NEEDED check is belt-and-braces.minimal buildcheck is the verifier. Nothing was built locally.Expected saving: small per build (one C library, about a minute). uv rebuilds often, though: 0.13.4 → 0.13.10 was 7 bumps.
🤖 Generated with Claude Code
Summary by CodeRabbit