-
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
Map crate numbers between compilations #35123
Comments
I have a simple fix for that where, on startup, the compiler just validates that the crate numbers belong to the same crate as they used to (it doesn't try to find a new crate number if they don't match). This is suboptimal, clearly, but not terrible. |
The biggest problem, actually, is krate numbers being removed entirely, which can lead to array-index-out-of-bounds errors. cc rust-lang#35123 -- not a complete fix, since really we ought to "map" the old crate numbers to the new ones, not just detect changes.
Removing from milestone since the current solution is good enough for the time being, I believe. |
Tagging with E-mentor. This would be a good entry point for people looking to help out with incremental compilation. The remaining work is to edit the code in use crate-name/disambiguator in We already save (and re-load) the crate-name and disambiguator (two bits of data that together identify a crate) for each crate-number, so this is basically a matter of re-loading them in the new state and comparing the old against the new. |
I'd like to work on it |
I've briefly review your commit. I should create map from old CrateNum to an new base on name and disambiguator pair. And if old crate has found return retraced path or None in other case. I'm right? Is it any way to check this issue? |
I replaced Vec by HashMap (for debug purpose, HasSet is enough)
But test tests/incremental/krate_reassign_34991 fails, I reverted all my changes and add just trace which outputs crate name and disambiguator, and it fails too. Currently it works because module index is lager than kates vec len. |
@mikhail-m1 Argh, sorry for not responding, I've been behind on GH notifications the last few weeks apparently. Can you give me a bit more details on how the One of the trickier parts of this issue is indeed that you must be wary that an extern crate may no longer exist. The way I had envisioned handling this is to iterate over all the new crate numbers -- e.g., by calling
So this loop that we have today: let ids = self.paths.iter()
.map(|path| {
if self.krate_still_valid(tcx, max_current_crate, path.krate) {
tcx.retrace_path(path)
} else {
debug!("crate {} changed from {:?} to {:?}/{:?}",
path.krate,
self.krates[path.krate as usize],
tcx.crate_name(path.krate),
tcx.crate_disambiguator(path.krate));
None
}
})
.collect(); might become: let ids = self.paths.iter()
.map(|path| {
if let Some(new_krate) = self.map_crate(path.krate) {
let mut new_path = DefPath { krate: new_krate, data: path.data.clone() };
tcx.retrace_path(&new_path)
} else {
// ...just as before...
}
})
.collect(); Here Now, for bonus points, you might change the interface to |
this trace mikhail-m1@6aaf566 breaks krate_reassign_34991. I'll send full change list later, I need some time to clear it |
@mikhail-m1 ah! yes, that would cause a problem, since invoking |
@nikomatsakis I missed max check, now it works but I don't know how to write check in test |
and bonus mikhail-m1@738c026 |
@mikhail-m1 getting closer =) I left some comments here, let me know what you think. |
@nikomatsakis thanks for comments, I'll send you reworked version soon, but I still don't know how write test for it |
@nikomatsakis Next try mikhail-m1@16b7e56 :) |
@mikhail-m1 that looks great! :) I left a few nits. |
map crate numbers between compilations ?r nikomatsakis issue rust-lang#35123
Looks like this problem is solved, and the issue could be closed. |
Agreed. |
It appears we are not checking for crate-numbers having changed. The best thing here would probably be to find the new crate-number. The easiest thing, however, would be to store -- for each crate-number we have -- the name/discriminant and then double-check that nothing has changed. I'll probably start with the easy fix for now.
The text was updated successfully, but these errors were encountered: