Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend the "if-unchanged" logic for compiler builds #131831

Merged
merged 7 commits into from
Nov 12, 2024

Conversation

onur-ozkan
Copy link
Member

@onur-ozkan onur-ozkan commented Oct 17, 2024

Implements the first item from this tracking issue.

In short, we want to make "if-unchanged" logic to check for changes outside of certain allowed directories, and this PR implements that.

See #131658 for more context.

@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2024

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 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 Oct 17, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2024

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

Comment on lines 74 to 75
/// Holds subpaths from [`RUSTC_IF_UNCHANGED_ALLOWED_PATHS`] that should not be allowed.
pub(crate) const RUSTC_IF_UNCHANGED_DENIED_SUBPATHS: &[&str] = &[
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want to have this list, but without it, it will be extremely hard to manage RUSTC_IF_UNCHANGED_ALLOWED_PATHS since there will be hundreds of paths 🙁.

Copy link
Member

Choose a reason for hiding this comment

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

I think it really doesn't matter if there are a few more rebuilds than necessary. I'd remove this list here and significantly reduce the list above. I think I'd be fine if it only contained library.

Copy link
Member

Choose a reason for hiding this comment

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

If we have to maintain a list of paths, making it simple and obvious and handle the most important cases seems way more important than making it granular and perfect.

@bjorn3
Copy link
Member

bjorn3 commented Oct 17, 2024

Would it make sense to compute the set of files that may not be changed for download-rustc to work based on the .d files in build/host/stage0-rustc? This is what cargo uses for determining if a crate should be recompiled. It doesn't list the Cargo.toml files though. For the aggregated .d file generated by cargo in build/host/stage0-rustc/<host>/release/rustc-main.d I think it would make sense to add Cargo.toml there too. These aggregated .d files are meant for integration with external build systems AFAIK, which need to track Cargo.toml changes too.

":!CODE_OF_CONDUCT.md",
":!CONTRIBUTING.md",
":!COPYRIGHT",
":!Cargo.lock",
Copy link
Member

Choose a reason for hiding this comment

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

this is wrong

Copy link
Member Author

Choose a reason for hiding this comment

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

How?

Copy link
Member

Choose a reason for hiding this comment

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

if the dependencies of the compiler are updated, the compiler needs to be rebuilt

Copy link
Member Author

@onur-ozkan onur-ozkan Oct 17, 2024

Choose a reason for hiding this comment

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

Oh, I didn't consider (but I should) the small bumps that can happen without changing Cargo.toml files in compiler and library tree.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, there are so many things to consider or to not consider here that I think it makes the most sense to be super simple and only special case library as not rebuilding. in case anyone complains we can add more as needed

@onur-ozkan
Copy link
Member Author

@rustbot author

@rustbot rustbot 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 Oct 18, 2024
@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from 2468461 to 135b903 Compare October 18, 2024 17:09
@onur-ozkan
Copy link
Member Author

RUSTC_IF_UNCHANGED_DENIED_SUBPATHS is removed to rely on allowed paths only. Also, "src/bootstrap" is not included in the allowed paths on purpose since it can affect compiler builds.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2024
@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from 135b903 to 6e6625b Compare October 18, 2024 17:16
@onur-ozkan
Copy link
Member Author

Would it make sense to compute the set of files that may not be changed for download-rustc to work based on the .d files in build/host/stage0-rustc?

We are comparing against the nightly compiler, "stage0-rustc" wouldn't help.

@bors
Copy link
Contributor

bors commented Oct 19, 2024

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

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from 6e6625b to a140442 Compare October 20, 2024 01:08
@onur-ozkan
Copy link
Member Author

RUSTC_IF_UNCHANGED_DENIED_SUBPATHS is removed to rely on allowed paths only. Also, "src/bootstrap" is not included in the allowed paths on purpose since it can affect compiler builds.

@rustbot ready

Nevermind, allowed src/bootstrap again because modifications on bootstrap could break CI rustc usage and we wouldn't catch that if we used the in-tree compiler. The CI failure would only show up the next day.

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch 2 times, most recently from 31eaf3b to 7ccca59 Compare October 22, 2024 08:38
@bors
Copy link
Contributor

bors commented Oct 23, 2024

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

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from 7ccca59 to b115071 Compare October 24, 2024 10:36
@bors
Copy link
Contributor

bors commented Oct 27, 2024

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

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from b115071 to 7352257 Compare October 27, 2024 16:17
@bors
Copy link
Contributor

bors commented Oct 31, 2024

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

@onur-ozkan onur-ozkan removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 2, 2024
@rustbot rustbot added A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs labels Nov 10, 2024
@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from bbb7e28 to 8c01563 Compare November 10, 2024 20:54
@onur-ozkan
Copy link
Member Author

FWIW, I ran my git analysis scripts using the current allowlist in this PR. For merge commits from the last 365 days, only around 3.8% would be cacheable. Before the latest change made a few minutes ago, it was 12.4%.

I guess src/tools is playing serious role on that.

What about PR CIs btw? I think CI rustc brings some serious advantage on that.

@rust-log-analyzer

This comment has been minimized.

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from 8c01563 to c104f3a Compare November 10, 2024 21:07
@rust-log-analyzer

This comment has been minimized.

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch 3 times, most recently from ef77e4d to f87fc33 Compare November 11, 2024 06:39
@rust-log-analyzer

This comment has been minimized.

@onur-ozkan onur-ozkan force-pushed the improve-rustc-if-unchanged-logic branch from f87fc33 to 4dfc052 Compare November 11, 2024 08:19
@onur-ozkan
Copy link
Member Author

Do you have any other concerns on this PR? @RalfJung

@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2024

This PR modifies config.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

mati865 pushed a commit to mati865/rust that referenced this pull request Nov 12, 2024
…ozkan

do not trust download-rustc=if-unchanged on CI for now

See rust-lang#131658.

Once rust-lang#131831 lands this will be unnecessary, for until then, better safe than sorry.

r? `@onur-ozkan`
Cc `@rust-lang/bootstrap`
@RalfJung
Copy link
Member

I haven't dug into the logic here, so my concerns were entirely about the list of folders that considered "not affecting the compiler". That one has been resolved.

@onur-ozkan
Copy link
Member Author

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Nov 12, 2024

📌 Commit 2d143ab has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#131831 (extend the "if-unchanged" logic for compiler builds)
 - rust-lang#132541 (Proper support for cross-crate recursive const stability checks)
 - rust-lang#132657 (AIX: add run-make support)
 - rust-lang#132901 (Warn about invalid `mir-enable-passes` pass names)
 - rust-lang#132923 (Triagebot: Consolidate the T-compiler ad hoc assignment groups)
 - rust-lang#132938 (Make precise capturing suggestion machine-applicable only if it has no APITs)
 - rust-lang#132947 (clarify `must_produce_diag` ICE for debugging)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 134459e into rust-lang:master Nov 12, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2024
Rollup merge of rust-lang#131831 - onur-ozkan:improve-rustc-if-unchanged-logic, r=Mark-Simulacrum

extend the "if-unchanged" logic for compiler builds

Implements the first item from [this tracking issue](rust-lang#131744).

In short, we want to make "if-unchanged" logic to check for changes outside of certain allowed directories, and this PR implements that.

See rust-lang#131658 for more context.
@onur-ozkan onur-ozkan deleted the improve-rustc-if-unchanged-logic branch November 13, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc 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-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants