-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Fix ICE in incremental compilation when rust-src component is changed #83591
Conversation
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
b8c8979
to
3b40763
Compare
This comment has been minimized.
This comment has been minimized.
3b40763
to
779fedc
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 779fedc95fbc68b2c3ea1065a3aef383fd383c29 with merge 87a37cc83f9cf37be440e573e062eaec4f60dc74... |
☀️ Try build successful - checks-actions |
Queued 87a37cc83f9cf37be440e573e062eaec4f60dc74 with parent 97717a5, future comparison URL. |
Finished benchmarking try commit (87a37cc83f9cf37be440e573e062eaec4f60dc74): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
@Aaron1011 is this still a work in progress or are you looking for a review? |
I'm still trying to reproduce the ICE with |
We don't build the standard library with remapped debug info on CI, which means that the test |
779fedc
to
07a6ec0
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 07a6ec0cd2c7f67b786f83624b2a819cc6aa5384 with merge fe9de0761e7a673c82626a3dbc1e45b532645214... |
☀️ Try build successful - checks-actions |
Queued fe9de0761e7a673c82626a3dbc1e45b532645214 with parent 1255053, future comparison URL. |
When the `rust-src` component is installed, rustc will automatically remap paths from the standard library to point into the local system. The target filesystem location is stored in `tcx.sess.real_rust_source_base_dir` This is a form of global state that's not tracked by the incremental compilation system, which can lead to ICEs when the `rust-src` component is added or removed between compilation sessions. This PR fixes several bugs in incremental compilation * We now hash `real_rust_source_base_dir` when computing a crate hash, since it affects any spans that we import from foreign crates (e.g. via macros or inlining). * The `crate_hash` and `host_crate_hash` quereis now return a wrapper around `Svh`, which also hashes the value of `real_rust_source_base_dir` in the *current* compilation session. This reflects the fact that changes to this value affect how we decode values from all foreign crates. * We now properly re-compute the `name_hash` of an imported `SourceFile` when we remap a path. There was a test for this kind of issue, but it was broken when the standard library was moved to `library/std`, and was no longer actually testing anything. To ensure that this doesn't happen again, I've modified the test to build a binary that outputs a remapped standard library path (via a panic), and verifies that the precense of `rust-src` during compilation correctly affects the output of the compiled binary.
899a5ea
to
7edda7b
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 7edda7b with merge eb7cdc743679b9eec36e733c4853fe8997193e86... |
According to #83813 (comment), we actually dont want remapped paths in crate metadata. So, this PR might actually be redundant. |
☀️ Try build successful - checks-actions |
Queued eb7cdc743679b9eec36e733c4853fe8997193e86 with parent 5c13042, future comparison URL. |
Finished benchmarking try commit (eb7cdc743679b9eec36e733c4853fe8997193e86): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
This is now ready for review. The perf results look bad, but all of the large regressions are on extremely short benchmarks (e.g. A large number of people are hitting #84341 in various forms. I'm not 100% certain that this PR will fix all of those issues - however, it will definitely fix some, and will allow us to narrow down the cause of any ones which aren't fixed. cc @rust-lang/wg-incr-comp |
While this will probably generate merge conflicts with #83813, I believe the two PRs are actually independent of each other. I believe that #83813 will cause us to stop writing devirtualized paths into the metadata - however, any devirtualized paths that we use (e.g. in diagnostics) will still affect query results. Therefore, I think it will still be necessary for us to explicitly track the state of devirtualization via the |
These changes look good to me, but someone else from incr-comp should probably take a look. r? @wesleywiser |
There's been additional discussion in #83813. The PR might end up being unecessary after all, or we might want to do with the simpler approach of wiping the entire incremental cache with |
Superseded by #84233, which invalidates the entire incremental cache when |
When importing source files from an external crate, we try to remap 'virtualized' filenames pointing into the standard library. However, we only do this remapping if the
rust-src
component is present on disk. As a result, the values we decode from a foreign crate's metadata depend on untracked global state.This PR explicitly tracks our dependency on this global state via the
crate_hash
query. Instead of just returning anSvh
, we return aCrateHashAndState
, which holds the current state of therust-src
component. As a result, changes to this will cause all queries that depend oncrate_hash
(e.g. all external queries) to get re-run, avoiding the ICEs that result from an unexpected hash change.