Skip to content

applying /Brepro in bootstrap on MSVC and adding a run-make test. - #158873

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
paradoxicalguy:brepro-msvc
Jul 27, 2026
Merged

applying /Brepro in bootstrap on MSVC and adding a run-make test.#158873
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
paradoxicalguy:brepro-msvc

Conversation

@paradoxicalguy

@paradoxicalguy paradoxicalguy commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

View all comments

as per the discussion, this PR applies /Brepro only for bootstrap when building rustc on MSVC, rather than enabling it for all Rust binaries.

it also adds a run-make test that compiles a small PE executable, parses its IMAGE_DEBUG_DIRECTORY using the object crate, and verifies that TimeDateStamp values remain identical across repeated /Brepro builds.

r?@Urgau

@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

compiler-builtins is developed in its own repository. If possible, consider making this change to rust-lang/compiler-builtins instead.

cc @tgross35

@rustbot rustbot added the A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) label Jul 6, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 6, 2026
@rustbot

This comment has been minimized.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

oh no

@tgross35

tgross35 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Whatever the goal is here, would it be possible to write a run-make test that uses gimli/object to check this? Exact binary contents tend to be a bit fragile, as illustrated here...

@tgross35

tgross35 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Also is there any interaction with trim-paths? #111540

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

(a) for the test, i'll investigate if i can write a run-make test that inspects the relevant PE/COFF metadata using object
(b) im not sure right now, i'll also check any interactions w trim paths

@Urgau

Urgau commented Jul 6, 2026

Copy link
Copy Markdown
Member

There seems to be some serious downsides to using /Brepro unconditionally, it apparently breaks incremental linking12, unsure if it's even possible to use from rustc.

If we do enable it, we probably want to enable it only if -Cincremental isn't passed.

Let's ping some of our Windows target maintainer on this matter, @ChrisDenton @dpaoliello @Fulgen301 @lambdageek.

Footnotes

  1. https://stackoverflow.com/questions/75891687/potential-downsides-of-brepro-msvc-linker-option

  2. https://reviews.llvm.org/D51635

@Urgau

Urgau commented Jul 6, 2026

Copy link
Copy Markdown
Member

Buck2 seems to enable it unconditionally, but they also disable incremental linking.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

oh i didn't know that :'(, i'll read those linked pages and wait for target maintainers for their approaches too

@Fulgen301

Copy link
Copy Markdown
Contributor

I'm not a fan:

  • Although popular, this switch is still undocumented, so we shouldn't enable it for every build without some guarantee that it won't go horribly bonkers in the next patch release.
  • Why is this in the function that configured debug info? /Brepro is for reproducibility in the resulting binaries, which includes setting the PE header timestamps to deterministic values. Whether a build is reproducible or not shouldn't depend on whether debuginfo is enabled.
  • Incremental linking fundamentally doesn't work with reproducible builds due to the extra information the linker adds to the binaries. This is a worse debug profile experience for something that, at least in my opinion, few people will care about during development.

I also don't think such major changes should be done in a PR; this should be a Major Change Proposal at the minimum and / or integrate with existing efforts for reproducible builds.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author
  • mcp, not sure this needs one, genuinely asking rather than assuming
    is the concern mainly the incremental-linking regression, or the broader precedent of changing default windows behavior? if it's the latter, i'll look into starting one after other target maintainers have also discussed this. 

and will move this out of debuginfo fn regardless.
open to whatever mitigates the undocumented flag risk too

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

cc @bjorn3

@bjorn3

bjorn3 commented Jul 7, 2026

Copy link
Copy Markdown
Member

The above discussion makes it seem to me like we shouldn't enable it by default inside rustc itself, but could make bootstrap pass it when building everything. We don't use incremental linking for rustc itself anyway.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

then i'll get to it now, thanks :-)

@Fulgen301

Fulgen301 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

is the concern mainly the incremental-linking regression, or the broader precedent of changing default windows behavior? if it's the latter, i'll look into starting one after other target maintainers have also discussed this.

Both; /Brepro doesn't have a (known) way to disable it, so users could not opt into incremental linking again, or disable reproducible builds if they needed it. That alone makes me think a MCP is a good idea, because it's quite a major change and should have room to be discussed. (And MCPs aren't heavy.) It feels like something that should be gated behind something unstable and tested first, though I am not very familiar with the best process here.

That's only about all Windows programs in the wild though; enabling it for only rustc should be fine, like bjorn said.

@paradoxicalguy

paradoxicalguy commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@tgross35 were you hyperlinking something here

@ChrisDenton

Copy link
Copy Markdown
Member

If we did want to more directly support this outside of rustc itself then think it would be better to have it be a cargo option or subcommand. Reproducible builds are not something that needs to be implicit and it requires setting more than just /Brepro, as you're no doubt aware. It's more a whole build system thing (rustc could help in some way but, if so, it should do it via an explicit flag imho).

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

just want to make sure i understand correctly: you are saying the narrow "bootstrap passes /Brepro when building rustc itself" approach (what @bjorn3 suggested) is still fine as a self-contained fix,
and the "explicit flag/subcommand" point is about a broader, separate effort for reproducible builds in general? or does this change the shape of what's being proposed here too?
want to make sure i'm not coding up something that's already been steered away from before i put the patch together

@ChrisDenton

Copy link
Copy Markdown
Member

just want to make sure i understand correctly: you are saying the narrow "bootstrap passes /Brepro when building rustc itself" approach (what @bjorn3 suggested) is still fine as a self-contained fix

Yes, absolutely.

My only point was that reproducible builds are ultimately a build system concern and bootstrap is the build system for rustc so it definitely makes sense to put it there.

@tgross35

tgross35 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@tgross35 were you hyperlinking something here

No; I was referring to how it took multiple attempts to get the desired result :)

@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2026
@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

checked the interaction directly: --remap-path-prefix (trim-paths) and -Clink-arg=/Brepro coexist, compiled and linked cleanly together, and /Brepro's timestamp effect still applies with remap-path-prefix active. so no overlap expected or observed.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

applied /Brepro conditionally in bootstrap, confirmed its working via two independent full rebuilds (coff TimeDateStamp are identical). while writing the run-make test, hitting an interesting problem: the test produces identical timestamps even with /Brepro removed(not sure why), so expanding the fix to something closer to a real build (lto, more codegen) to properly observe the nondeterminism the flag is addressing. will report back once the test reliably distinguishes the two cases.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

(i hadn't removed this pr's change in my local clone, thats why the coff TimeDateStamp were coming identical even after removing it in run-make test's arg😭)

@rust-log-analyzer

This comment has been minimized.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

is it because of msvc not being msvc or msvc* something like that

@Kobzol

Kobzol commented Jul 14, 2026

Copy link
Copy Markdown
Member

@bors try jobs=msvc

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 14, 2026
applying `/Brepro` in bootstrap on MSVC and adding a run-make test.


try-job: *msvc*
@rust-bors

rust-bors Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8f072d0 (8f072d051b779dabc0ba832156761f5820cd3978)
Base parent: 55b6bd8 (55b6bd8ecbed23599e966a04508a8a13cbfe90b3)

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

its done :D
bors' new pfp looking fire btw

@Urgau

Urgau commented Jul 14, 2026

Copy link
Copy Markdown
Member

@Fulgen301 could you take a look at the PR? I don't access to a Windows machine, and this is pretty Windows specific.

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

@Fulgen301
image

@Fulgen301

Copy link
Copy Markdown
Contributor

GitHub did not report the pings at all, yay...

@Fulgen301 Fulgen301 Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also look at the TimeDateStamp field in the COFF file header, currently it only looks at the debug section.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, i'll include that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done
x86_64-pc-windows-msvc and i686-pc-windows-msvc; both pass locally too

Comment thread tests/run-make/brepro-msvc-determinism/rmake.rs
@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

need a msvc bors run on this

@tgross35

Copy link
Copy Markdown
Contributor

@bors try jobs=msvc

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
applying `/Brepro` in bootstrap on MSVC and adding a run-make test.


try-job: *msvc*
@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 7d958e4 (7d958e45d1625eaeb0e7a5896dc1404418e3ad8d)
Base parent: 29e68fe (29e68fe2295f8fc2feb52b8cb0b61a055842fdcf)

@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

cc @Urgau @Fulgen301

@ChrisDenton

Copy link
Copy Markdown
Member

I'm happy to approve this from a Windows pov, thanks for working on it! Though if @Kobzol has any concerns from a bootstrap perspective then feel free to r-.

@bors r+

@rust-bors

rust-bors Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ae29b37 has been approved by ChrisDenton

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 27, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 27, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #160009 (`rust-analyzer` subtree update)
 - #159833 (ci: Make the `x86_64-gnu-parallel-frontend` job non-optional)
 - #158873 (applying `/Brepro` in bootstrap on MSVC and adding a run-make test.)
 - #159777 (Enforce that we don't generate code for comptime fns)
 - #159997 (On many bindings with move error, limit the number of `Span`s)
 - #158205 (fix: defer const normalize in coherence mode)
 - #159312 (Windows implementation for stdio set/take/replace)
 - #159772 (Fix lowering of resolved const inference variables)
 - #159785 (Share _Unwind_Exception definition between native and wasm)
 - #159968 (Fix the const impl suggestion)
 - #159974 (Update thinvec to 0.2.19)
 - #160013 (tests/ui: Ignore one query cycle test in parallel frontend mode)
 - #160016 (compiletest: do not talk about JSON when the user never sees any)
 - #160018 (test suite: add ARM case to ABI-required target feature check for -Ctarget-cpu)
@paradoxicalguy

Copy link
Copy Markdown
Contributor Author

yay (/≧▽≦)/

@rust-bors
rust-bors Bot merged commit ba9c05d into rust-lang:main Jul 27, 2026
14 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 27, 2026
rust-timer added a commit that referenced this pull request Jul 27, 2026
Rollup merge of #158873 - paradoxicalguy:brepro-msvc, r=ChrisDenton

applying `/Brepro` in bootstrap on MSVC and adding a run-make test.

as per the discussion, this PR applies `/Brepro` only for bootstrap when building `rustc` on `MSVC`, rather than enabling it for all Rust binaries.

it also adds a `run-make` test that compiles a small `PE executable`, parses its `IMAGE_DEBUG_DIRECTORY` using the `object` crate, and verifies that `TimeDateStamp` values remain identical across repeated `/Brepro` builds.

r?@Urgau
@Fulgen301

Copy link
Copy Markdown
Contributor

What Chris said.

Thanks!

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

Labels

A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants