-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
ICE: stage2 builds of rustc itself see metadata serialized by a different rustc #76720
Comments
What was the exact build command that caused the ICE? If this is with |
@RalfJung I do The assertion is fired in the not the same line but the same file, I haven't gotten around looking at the query code to see what failed. Only thing I worked on since the last x.py clean (maybe 10-15ish builds in, though I could be wrong) was change closure/generator pretty printing (in rustc_middle/src/ty/print/pretty), haven't rebased since. Though I can see that rustc builds are themselves are more prone incr compile errors, also didn't think |
I mentioned |
You can set ignore-git to false in config.toml and that'll embed git commit hashes. But I think that must only patch over bugs - it can't be necessary. I doubt it will fully fix this bug. I suspect the problem is that Cargo doesn't delete incremental state on dependency changes - which means that rustc must be prepared, currently, to see incremental state serialized by a different rustc... ideally, handling that in a way that doesn't just throw everything out, but even just not panicking would probably be enough. |
See also #75849. |
The proper way to fix this is to wipe the build cache whenever the stage1 compiler changes. That will make builds a lot slower, but it's better than ICEs and having to wipe the cache anyway. I guess we could add a --keep-stage1-cache flag if you're sure you haven't touched metadata - not sure how useful it would be in practice. @RalfJung said on Zulip:
|
Wait, I'm confused again. Why does the metadata matter other than the incremental cache? Cargo already invalidates the cache when Is there anyone not using |
Allow cleaning individual crates As a bonus, this stops special casing `clean` in `Builder`. ## Motivation Cleaning artifacts isn't strictly necessary to get cargo to rebuild; `touch compiler/rustc_driver/src/lib.rs` (for example) will also work. There's two reasons I thought making this part of bootstrap proper was a better approach: 1. `touch` does not *remove* artifacts, it just causes a rebuild. This is unhelpful for when you want to measure how long the compiler itself takes to build (e.g. for rust-lang#65031). 2. It seems a little more discoverable; and I want to extend it in the future to things like `x clean --stage 1 rustc`, which makes it easier to work around rust-lang#76720 without having to completely wipe all the stage 0 artifacts, or having to be intimately familiar with which directories to remove.
The only time it won't fully fix the issue is when you're modifying rustc_metadata or similar and don't make a commit between builds. I'm ok with not fixing that case, because anyone working on metadata is much more likely to understand what went happened and how to work around it than random contributors stumbling into this for the first time. |
@BoxyUwU hit this issue this morning with incremental disabled, so it's relevant to all metadata loading, not just incremental. |
Thanks for pointing me to the right issue. Following #60228 (comment)
Tried some commits from the past few days
Would it be useful to keep going with this approach? Oh, and this is with |
That's helpful, thanks! No need to find more commits, having a reproducer at all is already very useful. |
This fundamental issue doesn't just apply to bootstrap, right? If one uses a locally built toolchain to build some crates, and then updates the toolchain, the same ICEs can arise (because the dependency rlibs will now be in the wrong format). Bootstrap is just where people run into it most often. But a solution inside bootstrap won't fix the fundamental issue. (E.g., it won't fix the Miri version of this problem, which got reported at rust-lang/miri#2847.) |
Yes, that's right, any two toolchains that were built from different sources but have the same version string will have this problem (this is why we set a custom description by default in the source tarballs, so they won't reuse metadata from the official toolchain). Removing |
A more "principled" fix would be to have something like a metadata version number embedded in the .rmeta/.rlib files that contributors are responsible for updating when the format changes. But I worry people will forget to update it, the same way people often forget to bump |
oh right, and @Mark-Simulacrum suggested adding incremental to dep-info: #86641 (comment) but given that this bug is also showing up for metadata, not just incremental, I suspect that's not a complete fix: #76720 (comment) |
Yeah, if we could somehow ensure that such a version number is always correct it would be a proper fix but manual bumping probably won't work. Unless we find a way to at least have CI fail when one forgets to bump... |
@saethlin reported seeing these crashes for Lines 1558 to 1567 in 32e27cc
that shouldn't filter only to build, nearly all the commands read metadata and need the same treatment. Not making a PR because I don't have a test case yet, but if anyone comes up with an MCVE that makes diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 1267c0be719..d64c4fa16c6 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1563,7 +1563,7 @@ pub fn cargo(
//
// Only clear out the directory if we're compiling std; otherwise, we
// should let Cargo take care of things for us (via depdep info)
- if !self.config.dry_run() && mode == Mode::Std && cmd == "build" {
+ if !self.config.dry_run() && mode == Mode::Std {
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
} also, I wonder if we could fix the original problem with metadata/incremental in stage 1 by applying clear_if_dirty to rustc too: diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 1267c0be719..875bd09dc9e 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1560,10 +1560,7 @@ pub fn cargo(
//
// Avoid doing this during dry run as that usually means the relevant
// compiler is not yet linked/copied properly.
- //
- // Only clear out the directory if we're compiling std; otherwise, we
- // should let Cargo take care of things for us (via depdep info)
- if !self.config.dry_run() && mode == Mode::Std && cmd == "build" {
+ if !self.config.dry_run() {
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
} |
@whtahy's reproducer unfortunately gives me a different ICE than the one in the linked issue; it's for stage0, not stage1. So I can't use it to test my diff.
|
@BoxyUwU a while ago found that
reproduced the issue; if someone could run that both with and without my diff applied to see if it makes a difference that would be helpful; I'm out of time for today. |
…ot,est31 Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc rust-lang#76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc rust-lang/rust#76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc rust-lang/rust#76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc rust-lang/rust#76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
Error happened while working on updating closure capture analysis in rustc which is part of rustc_typeck.
Code
https://github.com/rust-lang/rust/compare/master...sexxi-goose:use_places_new?expand=1#diff-a7b1a49c68b1a1ce388558eee4f3514aR267
The highlighted line is what changed between the build that broke and the build before it.
Meta
Version reported in build log
Error output
and similarly one or two more
Complete build log: http://csclub.uwaterloo.ca/~a52arora/ice/log_75e93202-df10-4ea2-bff9-167ff9b968c2
Build log with
RUST_BACKTRACE=1
: http://csclub.uwaterloo.ca/~a52arora/ice/log_b7ef389e-c9a9-495e-92c1-5f55468705ecBuild directory: http://csclub.uwaterloo.ca/~a52arora/ice/build.tar (Heads up, this is 29G tar, 39G extracted)
The text was updated successfully, but these errors were encountered: