Skip to content

Add repro-check tool for verifying reproducible Rust builds - #149888

Open
windsunil wants to merge 1 commit into
rust-lang:mainfrom
windsunil:reprocheck-tool
Open

Add repro-check tool for verifying reproducible Rust builds#149888
windsunil wants to merge 1 commit into
rust-lang:mainfrom
windsunil:reprocheck-tool

Conversation

@windsunil

@windsunil windsunil commented Dec 11, 2025

Copy link
Copy Markdown

This patch introduces a new host tool called repro-check that helps verify whether Rust compiler builds are reproducible.

Summary:
-> Builds the stage-2 Rust toolchain (or a full distribution) twice in separate workspaces.
-> Compares the resulting sysroots byte-for-byte using SHA-256.
-> Generates a detailed HTML report highlighting mismatches and ignored files.
-> Writes a deterministic bootstrap.toml for each build to ensure consistent settings.
-> Supports parallel hashing via Rayon.
-> Accepts standard options such as:
--jobs – Number of parallel jobs
--exclude-pattern – Ignore files matching a pattern
--path-delta – Adds extra directory levels to second build for path-sensitivity testing
--full-dist – Build full distribution instead of stage 2
--clean – Start from a clean workspace
--skip-copy – Reuse existing workspace without copying source
--verbose – Print detailed logging

Included components:
-> src/tools/repro-check/ – Tool source code (main.rs, build.rs, compare.rs, fs_utils.rs, config.rs)
-> Integration tests for hash computation, mismatch detection, ignored patterns, and case-insensitive handling.
-> Updates to Cargo.toml and Cargo.lock to include repro-check dependencies.
-> Bootstrap and builder updates to register the new tool.

References:
Tracking issues: #139793, #134589, #144669

Usage:

Build the tool

./x.py build src/tools/repro-check

Run (stage2 only, host target)

./build/x86_64-unknown-linux-gnu/stage1-tools-bin/repro-check

Full distribution with custom options

./build/x86_64-unknown-linux-gnu/stage1-tools-bin/repro-check
--jobs 16
--exclude-pattern .so
--path-delta 10
--html-output my-report.html

@rustbot

rustbot commented Dec 11, 2025

Copy link
Copy Markdown
Collaborator

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Dec 11, 2025
@rustbot

rustbot commented Dec 11, 2025

Copy link
Copy Markdown
Collaborator

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

@Kobzol

Kobzol commented Dec 12, 2025

Copy link
Copy Markdown
Member

r? kobzol

Thank you for working on this! I will take a look, and also nominate this for the next t-infra meeting.

@Kobzol

Kobzol commented Dec 19, 2025

Copy link
Copy Markdown
Member

We discussed this at our infra meeting, and we're unsure of who should maintain this tool, and if we have enough interest in fixing repro bugs, if they appear. Continuing the discussion on compiler stream on Zulip.

We think that it might make sense to merge such a tool and keep it in for some time, to see if it finds any issues, and if we have someone to actually go and try to fix such issues. And then we can evaluate later if its maintenance costs offset the gains.

@windsunil

Copy link
Copy Markdown
Author

We discussed this at our infra meeting, and we're unsure of who should maintain this tool, and if we have enough interest in fixing repro bugs, if they appear. Continuing the discussion on compiler stream on Zulip.

We think that it might make sense to merge such a tool and keep it in for some time, to see if it finds any issues, and if we have someone to actually go and try to fix such issues. And then we can evaluate later if its maintenance costs offset the gains.


Thanks for the discussion and for considering this.

I agree with treating repro-check as an experimental tool initially. The goal from my side is to help surface reproducibility issues and provide a concrete way to compare builds. While I’m not a deep Rust compiler expert, I’m happy to help with using the tool for investigation, analyzing CI reports, narrowing down differences, and collaborating with the relevant teams when issues are found.

I’m also fine with revisiting or adjusting the tool if the maintenance cost turns out to be too high. I’ll follow the discussion on the compiler stream on Zulip as well. Thanks again!

@windsunil

Copy link
Copy Markdown
Author

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2026
@rust-bors

This comment has been minimized.

@Dylan-DPC Dylan-DPC removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 1, 2026
@Dylan-DPC

Copy link
Copy Markdown
Member

@windsunil this pr has a merge commit, you need to do a rebase as per the policy linked above. Please make the change for this to proceed further. Thanks

@rustbot

rustbot commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 30, 2026
@rust-log-analyzer

This comment has been minimized.

Add a new host tool that checks whether Rust builds are reproducible.

It builds the stage-2 toolchain (or a full distribution) twice in separate
workspaces and compares the resulting sysroots byte-for-byte using SHA-256.
Differences are reported in an HTML file.

The tool writes a minimal deterministic `bootstrap.toml` for each build,
hashes files in parallel with Rayon, and supports the usual flags
(`--jobs`, `--exclude-pattern`, `--path-delta`, `--full-dist`, etc.).

Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[TIMING:end] tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
fmt: checked 7075 files
tidy check
tidy [deps]: proc-macro crate dependency `jiff-core` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`
tidy [deps]: proc-macro crate dependency `defmt-parser` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`
tidy [deps]: proc-macro crate dependency `defmt` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`
tidy [deps]: `wasm-encoder` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `crypto-common` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `prettyplease` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `wit-bindgen-core` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `ryu` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `block-buffer` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `sha2` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `generic-array` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `cfg-if` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `digest` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `log` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `wasm-metadata` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `libc` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `anyhow` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `wit-bindgen-rust` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `wit-parser` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `typenum` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `allocator-api2` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `wasmparser` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `version_check` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `wit-component` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `id-arena` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `semver` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `leb128fmt` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `cpufeatures` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `itoa` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `serde_json` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: `unicode-xid` is registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency
tidy [deps]: Run `./x.py test tidy --bless` to regenerate the list
tidy [deps]: could not find allowed package `ryu`
Remove from PERMITTED_DEPENDENCIES list if it is no longer used.
tidy [deps]: Dependency for rustc-main not explicitly permitted: registry+https://github.com/rust-lang/crates.io-index#defmt@1.1.1
tidy [deps]: Dependency for rustc-main not explicitly permitted: registry+https://github.com/rust-lang/crates.io-index#defmt-macros@1.1.1
tidy [deps]: Dependency for rustc-main not explicitly permitted: registry+https://github.com/rust-lang/crates.io-index#defmt-parser@1.0.0
tidy [deps]: Dependency for rustc-main not explicitly permitted: registry+https://github.com/rust-lang/crates.io-index#zmij@1.0.23
tidy [deps]: Dependency for rustc-main not explicitly permitted: registry+https://github.com/rust-lang/crates.io-index#jiff-core@0.1.0
Go to `src/tools/tidy/src/deps.rs:295` for the list.
tidy [deps]: FAIL
tidy [rustdoc_json (src)]: `rustdoc-json-types` modified, checking format version
tidy: Skipping binary file check, read-only filesystem
removing old virtual environment
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'venv'
creating virtual environment at '/checkout/obj/build/venv' using 'python3.10' and 'virtualenv'
---
Running eslint on rustdoc JS files
info: ES-Check: checking 7 files...
info: ✓ ES-Check passed! All files are ES10 compatible.
typechecking javascript files
tidy: The following check failed: deps
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --ci=true --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1628:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1684:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1606
Build completed unsuccessfully in 0:03:29
  local time: Thu Jul 30 12:07:02 UTC 2026

@rust-bors

rust-bors Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #160310) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants