Skip to content

ruff: link pkgs' libzstd instead of zstd-sys's vendored copy - #1739

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

bryan-minimal wants to merge 1 commit into
mainfrom
buildtime-ruff

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. ruff's vendored copy is 1.5.7 today, so this PR doesn't regress anything. It is held with the uv PR (#1738) so both land on 1.6.0.

Once #1694 lands:

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

What

ruff 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 ruff has NEEDED libzstd.so.1.

This is the same pattern as codex (#1713) and the uv PR.

Why

  • Build time: the zstd C library is no longer compiled with every ruff build.
  • One shared copy: a fix to pkgs' zstd now reaches ruff without a zstd-sys release.

Evidence

  • ruff 0.17.6's Cargo.lock, read from the pinned tarball (sha256 2c7f6831…), has zstd-sys 2.1.2+zstd.1.5.7, zstd-safe 8.2.0 and zstd 0.14.3. pkgs zstd is 1.5.7, so the versions match.
  • How ruff reaches zstd: ruff -> ruff_db -> zip -> zstd -> zstd-safe -> zstd-sys. The zstd feature on zip comes from ty_vendored/zstd, which ty_project enables. build.sh runs a workspace-wide cargo build --release, so feature unification turns it on for the ruff binary too.
  • zstd-sys's pkg-config path panics when libzstd isn't found, 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).

Follow-up idea (not in this PR)

build.sh builds the whole workspace: ty, ty_server, the wasm crates and the rest, none of which this package ships. Restricting the cargo build to -p ruff would save much more build time than this PR does.

The trade-off: it drops the feature unification that turns on ty_vendored/zstd. The vendored typeshed zip would then be Stored instead of zstd-compressed, and ruff would no longer link libzstd at all. That is a separate decision.

🤖 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 ruff NEEDs libzstd.so.1 (the same
pattern as codex). ruff's lock has zstd-sys 2.1.2+zstd.1.5.7, the same
zstd as pkgs'.

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