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

Skip to content

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

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

bryan-minimal merged 4 commits 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

Summary by CodeRabbit

  • Chores
    • Updated the Ruff package to include the zstd runtime library, improving compatibility when running the packaged application.
    • Builds now require zstd version 1.6.0 or later and verify that the resulting executable links to the required zstd library.

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

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Ruff build now uses system libzstd through pkg-config. It checks for libzstd version 1.6.0 or later, adds libzstd as a runtime dependency, and verifies that the built executable lists libzstd.so.1 as a needed library.

Changes: Ruff system libzstd linkage

Layer / File(s) Summary
Configure system libzstd
packages/ruff/build.ncl, packages/ruff/build.sh
The package adds pkgconf and zstd as build dependencies. The build script selects pkg-config and checks that libzstd is version 1.6.0 or later.
Declare and verify runtime linkage
packages/ruff/build.ncl, packages/ruff/build.sh
The package adds libzstd as a runtime dependency. The build script checks that the executable lists libzstd.so.1 as a needed library.

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

Possibly related PRs

  • gominimal/pkgs#1738: This PR applies the same system libzstd build configuration and runtime linkage check to uv.

Suggested reviewers: norrietaylor

Merge Risk: Minimal · up to dc140

The Ruff build now links the shared libzstd and fails the build if the version is too old or the linkage is missing. No concrete merge-blocking risk was found, and the build-bot check remains the practical verifier.

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 names the main change: ruff now links the package set's libzstd instead of the vendored copy bundled with zstd-sys. The raw summary confirms the build now depends on pkgconf and zstd, and bu…
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 names the main change: ruff now links the package set's libzstd instead of the vendored copy bundled with zstd-sys. The raw summary confirms the build now depends on pkgconf and zstd, and build.sh configures zstd-sys to use the system libzstd. The title is short, specific, and matches the changeset and the PR objectives.

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 bc598ea and dc14062.

Files selected for processing: 2

  • packages/ruff/build.ncl
  • packages/ruff/build.sh

Included review availability: This review used your included allowance. 0 included reviews remain 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. Both files change only what the zstd link needs: two build deps, one runtime dep, the ZSTD_SYS_USE_PKG_CONFIG export, a version floor and a NEEDED check. Clobber none: git log on packages/ruff shows only version bumps before this branch, and the merge of main brought zstd 1.6.0 from #1694. Correctness the change is good. pkgconf ships usr/bin/pkg-config, toolchain supplies readelf through binutils, and base supplies sed and grep. The libzstd output of zstd matches libzstd.so.1, and packages/codex uses the same subsetOf zstd ["libzstd"] pattern. The existing smoke test starts ruff with only the runtime closure, so it fails if the runtime dep is missing. The PR body is stale: it says the PR is blocked on #1694 and that pkgs zstd is 1.5.7, and both statements are no longer true. Not checked, because the check needs a build: that zstd-sys 2.1.2 compiles and links against the 1.6.0 headers, and that workspace feature unification puts libzstd.so.1 in the ruff binary. The NEEDED check fails the build if the second assumption is wrong.

Comment thread packages/ruff/build.sh Outdated
# paths (source dir + cargo registry) and disable incremental builds.
export RUSTFLAGS="-C linker=gcc --remap-path-prefix=$(pwd)=/builddir --remap-path-prefix=$HOME/.cargo=/cargo"
export CARGO_INCREMENTAL=0
# Link pkgs' libzstd instead of the copy vendored in zstd-sys (2.1.2+zstd.1.5.7),
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.

nit · The comment pins the zstd-sys version 2.1.2+zstd.1.5.7. The automated ruff version bumps edit build.ncl only, so this number will be stale after the next bump that moves zstd-sys. Remove the version from the comment. The comment in packages/codex/build.sh names no version, so this is one instance.

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 comment no longer names a zstd-sys version.

The automated ruff bumps edit build.ncl only, so a version named here goes
stale on the next bump that moves zstd-sys.

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 9d083b1 Nov 30, 2026
16 checks passed
@bryan-minimal
bryan-minimal deleted the buildtime-ruff branch November 30, 2026 22:31
6B54 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