Skip to content

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

Draft
bryan-minimal wants to merge 1 commit into
mainfrom
buildtime-uv
Draft

bryan-minimal wants to merge 1 commit 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

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

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

1 participant