8000 uv: link pkgs' libzstd instead of zstd-sys's vendored copy by bryan-minimal · Pull Request #1738 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content

uv: link pkgs' libzstd instead of zstd-sys's vendored copy - #1738

Merged
bryan-minimal merged 4 commits into
mainfrom
buildtime-uv
Nov 30, 2026
Merged

bryan-minimal merged 4 commits into
mainfrom
buildtime-uv

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Nov 26, 2026 •
Copy link
Copy Markdown
Member

Blocked on #1694 (zstd 1.5.7 -> 1.6.0). Keep as draft until it merges.

zstd 1.6.0 (2026-11-23) fixes CVE-2026-124851, uninitialized memory exposure in streaming decompression. uv today bundles 1.6.0 through its lock patch (zstd-sys 2.2.0+zstd.1.6.0). Linking pkgs' current 1.5.7 would therefore downgrade uv into the CVE.

Once #1694 lands:

  1. Merge main into this branch.
  2. Confirm the build links 1.6.0.
  3. Mark the PR ready.

What

uv links pkgs' libzstd instead of the copy vendored in zstd-sys:

  • Sets ZSTD_SYS_USE_PKG_CONFIG=1.
  • Adds pkgconf and zstd as build deps, and subsetOf zstd ["libzstd"] as a runtime dep.
  • After the cargo build, a readelf check fails the build unless uv has NEEDED libzstd.so.1.

This is the same pattern as codex (#1713, packages/codex/build.sh).

The generated pkgmgr lock-patch block 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

  • Build time: the zstd C library is no longer compiled with every uv build.
  • One shared copy: a fix to pkgs' zstd now reaches uv without a zstd-sys release and a uv rebuild. The bundled copy, statically linked, was invisible to scanners.

Evidence and one caveat

  • Upstream Cargo.lock at 0.13.10 has zstd-sys 2.1.0+zstd.1.5.7. However, the effective lock is different: security-floors-lock.patch moves zstd-sys to 2.2.0+zstd.1.6.0 as 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.
  • I checked it is ABI-safe:
    • Diffing zstd-sys 2.1.2 and 2.2.0 bindings shows 4 functions newly in the stable set: ZSTD_CCtx_loadDictionary_advanced, ZSTD_DCtx_loadDictionary_advanced, ZSTD_createDDict_byReference and ZSTD_getFrameHeader.
    • All 4 are declared ZSTDLIB_STATIC_API in zstd 1.5.7's zstd.h, which means visible and exported from libzstd.so. pkgs' zstd build doesn't hide them.
    • ZSTD_FrameHeader has the same layout, and the enum values are unchanged.
  • zstd-sys's pkg_config() panics when libzstd isn't found (.expect), so there is no silent fallback. The NEEDED check is belt-and-braces.
  • The build-bot minimal build check 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

  • Chores
    • Updated build and runtime packaging to use the system-provided Zstandard library. Builds now require a compatible library version and verify that the application is linked to it. This changes build and packaging requirements; no changes to end-user features or application behavior are included.

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>
@coderabbitai
coderabbitai Bot commented Nov 26, 2026 •
Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The uv build now uses system libzstd. It checks the system library version against 1.6.0 and the version recorded in Cargo.lock. After the build, it checks that uv declares libzstd.so.1 as a dynamic dependency.

Changes: uv system libzstd build

Layer / File(s) Summary
Configure system libzstd
packages/uv/build.ncl, packages/uv/build.sh
The package adds pkgconf and zstd as build dependencies and the libzstd subset as a runtime dependency. The build script uses pkg-config to check that system libzstd meets the 1.6.0 minimum and the version recorded in Cargo.lock.
Validate binary linkage
packages/uv/build.sh
After building, the script checks for libzstd.so.1 in uv’s dynamic dependencies and exits with an error if it is absent.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: msample

Merge Risk: Minimal · up to 4d000

uv now links the system libzstd 1.6.0 package instead of the copy vendored by zstd-sys. This removes the stale vendored zstd and adds build-time guards on version and linkage. The dependency prerequisite is already in the base, so no concrete merge-blocking risk remains. The build-bot check will confirm the build.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "uv: link pkgs' libzstd instead of zstd-sys's vendored copy" matches the main change. The PR makes uv link the system libzstd from pkgs rather than the copy vendored by zstd-sys. The changed…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "uv: link pkgs' libzstd instead of zstd-sys's vendored copy" matches the main change. The PR makes uv link the system libzstd from pkgs rather than the copy vendored by zstd-sys. The changed files (build.ncl adds pkgconf, zstd, and a libzstd runtime subset; build.sh checks pkg-config, the zstd version, and that uv needs libzstd.so.1) support this. The title is specific, uses the packaging context (uv:), and names both the old and new source.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e9a9776 and 4d00038.

Files selected for processing: 1

  • packages/uv/build.sh

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

bryan-minimal and others added 2 commits November 29, 2026 14:58
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>
@bryan-minimal
bryan-minimal marked this pull request as ready for review November 29, 2026 22:59
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 29, 2026 22:59
@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/uv/build.sh Outdated
# 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest push: the 1.5.7 sentence is gone.

Comment thread packages/uv/build.sh
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 8aeaa53 Nov 30, 2026
16 checks passed
@bryan-minimal
bryan-minimal deleted the buildtime-uv branch November 30, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0