Repository navigation
Rust tools: make difftastic/nushell/hex-patch reproducible (codegen-units + const-random) - #254
Conversation
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>
|
Warning Review limit reached
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…tropy) (gominimal#292) * nushell: make reproducible (mangling v0 + deterministic build-time entropy) The rebuild-world audit caught that gominimal#254's recipe (codegen-units=1 + CONST_RANDOM_SEED) left `nu` non-reproducible. Root-caused in three layers: 1. ThinLTO (Cargo.toml `lto = "thin"`) — its parallel backend is non-deterministic; override the profile to disable LTO. 2. Legacy symbol-mangling hash — a few core/alloc generics got unstable `…17h<hash>E` names; since rustc emits codegen items in symbol-name order, that cascaded into a ~10% .text/.rela.dyn reorder. Fix: -C symbol-mangling-version=v0. 3. Proc-macro HashMap (the last 0.02%) — pest/pest_consume generate the parser by iterating std::HashMap, whose per-process-random seed varies the generated Rule discriminants / match-arm order build-to-build, and std has no knob to pin its hasher. Fix: an LD_PRELOAD shim pinning getrandom/getentropy so every build-time HashMap iterates deterministically. Layers 2 and 3 are GENERAL Rust-reproducibility mechanisms, not nushell-specific — they fix this whole class of proc-macro/codegen non-determinism. Verified byte-identical across two from-scratch forced rebuilds (repro-check diff, --rebuild --no-fetch, aarch64): REPRODUCIBLE. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * nushell: scope LD_PRELOAD to the cargo build (review nit) Per CodeRabbit on gominimal#292 — set the determinism shim inline on the single cargo invocation instead of export-then-unset, removing the window where another command could inherit it. Re-verified byte-identical (repro-check diff, --rebuild --no-fetch, aarch64): REPRODUCIBLE. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore: no-op to re-trigger build (buildbot queue cleared) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Problem
difftastic,nushell, andhex-patchare non-reproducible — two builds of the samesource produce binaries that differ pervasively in
.text/.rodata.Root cause (two layers)
non-deterministic
.llvm.<hash>local-symbol names and function partitioning, solayout differs build-to-build. This is the bulk of the difference (millions of bytes).
ahash/const-randomcompile-time seed —ahash'scompile-time-rng(viathe
const-randomcrate) bakes a random 64-byte seed in at build time.(
--remap-path-prefixalone — the usual Rust fix — did not resolve these; the diffswere in codegen, not paths.)
Fix
Pin both, matching the
bat/ripgrep/fdpath hygiene already in the tree:Verification
hex-patchis confirmed byte-reproducible across two from-scratch builds with thecombined fix (
repro-check diff: no differences).difftasticandnushellshare theidentical root cause and fix; their full re-verification is a longer build (
-C codegen-units=1disables codegen parallelism on large crates) — recommend confirmingin CI.
Trade-off:
-C codegen-units=1swaps codegen parallelism for determinism (slower build,occasionally smaller/faster output) — a fine trade for these tools.
🤖 Generated with Claude Code