Skip to content

Rust tools: make difftastic/nushell/hex-patch reproducible (codegen-units + const-random)#254

Open
bryan-minimal wants to merge 1 commit into
mainfrom
bryan/rust-tools-reproducible
Open

Rust tools: make difftastic/nushell/hex-patch reproducible (codegen-units + const-random)#254
bryan-minimal wants to merge 1 commit into
mainfrom
bryan/rust-tools-reproducible

Conversation

@bryan-minimal

Copy link
Copy Markdown
Member

Problem

difftastic, nushell, and hex-patch are non-reproducible — two builds of the same
source produce binaries that differ pervasively in .text/.rodata.

Root cause (two layers)

  1. Parallel codegen-units — Rust's release default (16 units) produces
    non-deterministic .llvm.<hash> local-symbol names and function partitioning, so
    layout differs build-to-build. This is the bulk of the difference (millions of bytes).
  2. ahash / const-random compile-time seedahash's compile-time-rng (via
    the const-random crate) bakes a random 64-byte seed in at build time.

(--remap-path-prefix alone — the usual Rust fix — did not resolve these; the diffs
were in codegen, not paths.)

Fix

Pin both, matching the bat/ripgrep/fd path hygiene already in the tree:

export RUSTFLAGS="... --remap-path-prefix=$(pwd)=/builddir --remap-path-prefix=$HOME/.cargo=/cargo -C codegen-units=1"
export CONST_RANDOM_SEED=0   # const-random honors this

Verification

hex-patch is confirmed byte-reproducible across two from-scratch builds with the
combined fix (repro-check diff: no differences). difftastic and nushell share the
identical root cause and fix; their full re-verification is a longer build (-C codegen-units=1 disables codegen parallelism on large crates) — recommend confirming
in CI.

Trade-off: -C codegen-units=1 swaps codegen parallelism for determinism (slower build,
occasionally smaller/faster output) — a fine trade for these tools.

🤖 Generated with Claude Code

Two-layer non-determinism: parallel codegen-units (.llvm.<hash> local symbols + partitioning) and ahash/const-random compile-time seed. Fix: -C codegen-units=1 + CONST_RANDOM_SEED=0 (plus --remap-path-prefix path hygiene). hex-patch verified byte-reproducible with the combined fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@bryan-minimal, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 hours, 23 minutes, and 47 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2ff276ee-7309-4d53-bb6e-8f1102f942e7

📥 Commits

Reviewing files that changed from the base of the PR and between 263ba22 and bc714a2.

📒 Files selected for processing (3)
  • packages/difftastic/build.sh
  • packages/hex-patch/build.sh
  • packages/nushell/build.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bryan/rust-tools-reproducible

Comment @coderabbitai help to get the list of available commands and usage tips.

@twitchyliquid64 twitchyliquid64 added this pull request to the merge queue Jun 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jun 17, 2026
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