-
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
Make sure to clear out the stageN-{rustc,std,tools} directories. #44792
Conversation
Unfortunately at this point I honestly forget why this is architected the way it is and how it worked at some point. I'm a little worried here about the loss of stamp files as it may cause us to probe quite a few files on builds, and I'm also a little worried about the global atomic hack needed here. Could you expand a bit on these two changes and why a stamp file didn't cut it and why the step always nees to run? |
I didn't really investigate why the stamp file doesn't cut it -- I can try to do that. I suspect it's because we don't actively touch it/update it properly when running Cargo, but wouldn't be too certain. It's also certainly less reliable than the method I chose (which seems to have minimal impact, at least on Linux -- I didn't notice any slowdown with my patch on noop builds). The global atomic hack exposes a weakness of our current caching implementation, combined with how we build tools. Basically, if the sequence of the build is libstd -> tidy (std tool) -> test/rustc -> error-index-generator (librustc dependent tool), then we'll clear out the tools directory while build libtest and librustc, which means we need to recompile tools. Previously we would've errored out when trying to run tidy later, but now we will rebuild it and properly run it. This may be better solved by moving tools to We can either file a mentored issue for the CleanTools refactor (it should just be a method, though perhaps with some per-stage caching... not really necessary, shouldn't have a major effect) or I can implement that in this PR, if you'd like. We still need the global atomic or some way to clear all tools in a given stage out of the "built cache," though, since we'll otherwise not rebuild tools properly after we've cleaned them out. |
Ok for the stamp file I'd prefer to not probe the entire directory, so mind checking to see what's going on there? For cleaning tools I looked into this and this is how it used to work. This previously worked because of "order only dependencies". That is, the "clean all tools" step didn't actually depend on libstd/libtest/librustc, but it always ran after those steps if they were present in the dependency graph. I don't think that strategy is implementable today because we don't ever know the dependency graph. A worry I have about this PR as-is, though, is something like:
After we build libtest the cleaning of the tools dir ends up blowing away the build tidy binary when it didn't get invalidated. The only solution I can think of right now is Thinking some more... I wonder if maybe we could do something like copy the tools out of the |
44512b7
to
e2e8e36
Compare
We can copy the tools out of the tools directory -- I actually like that idea, since we could even potentially copy them into It may be worth pointing out though that with this PR as written, we don't (I hope) expect tools today to exist unless we've called
It's worth pointing out that this is exactly what we do today, I believe. The old logic was wrong, though perhaps always worked out in practice since we ran tools as "after" dependencies of clean-tools, IIRC. That may have been sufficient, not sure, but it would've been about equivalent to the current state (without this PR). With this PR, we run I'll look into the stamp file problem soon. |
@Mark-Simulacrum I'm a little confused then, isn't the ordering I posted above incorrect but possible today and with this PR? That is, I could do something like:
The second step may kill the tool built in the first step if it builds libtest? |
Sure, yeah, that can happen -- I was more saying that I'd expect the workflow today to be that we run tools immediately after compilation. I could see how that might not be quite the case when looking at something like compiletest, though, e.g. with doc tests. Since we seem to be fine today though it's not a case I'm too worried about. We can (if necessary) keep a track of "built tools" per stage and rebuild all after clearing out, but it would probably be unnecessary and wasteful. |
Yeah I'd just personally prefer to not rely on "make sure you |
I think implementing the copy approach for tools is a good one -- and it should resolve the problem of clearing out tools, too, I believe. |
Oh right yeah, I was thinking let's not use the folder where |
☔ The latest upstream changes (presumably #44785) made this pull request unmergeable. Please resolve the merge conflicts. |
@Mark-Simulacrum just a ping on this PR, I note there's a merge conflict at minimum :) |
Going to close this for now to keep the queue clean! |
e2e8e36
to
5951df6
Compare
@alexcrichton Updated this -- I've removed the directory scanning logic, I think I actually never needed it and just introduced it before realizing the build script problem. We can come back to that problem later if necessary; I think there might be an edge case if cargo is killed via |
|
5951df6
to
39fa86c
Compare
@bors: r+ Looks great! |
📌 Commit 39fa86c has been approved by |
⌛ Testing commit 39fa86c0bf56f6fa1f4a1a0ebeadf7fb80b5f0eb with merge f14ede0cc7faeb0f86ff060e4237c34957ec5cb3... |
💔 Test failed - status-travis |
Cannot build stage2-miri on
|
39fa86c
to
58252a3
Compare
We copy built tool binaries into a dedicated directory to avoid deleting them, stageN-tools-bin. These aren't ever cleared out by code, since there should be no reason to do so, and we'll simply overwrite them as necessary. When clearing out the stageN-{std,rustc,tools} directories, make sure to delete both Cargo directories -- per-target and build scripts. This ensures that changing libstd doesn't cause problems due to build scripts not being rebuilt, even though they should be.
I think clippy might be broken? I can't really tell. I've rebased, going to wait on travis though. |
58252a3
to
0fcd3e7
Compare
@alexcrichton I don't understand how I've managed to break clippy in a PR that touches none of the related code. Did I do something wrong? |
wut |
Oh that's expected, the real error is:
|
This makes it mandatory for other steps to have to handle the potential failure instead of failing in an odd way later down the road.
@bors: r+ |
📌 Commit 686c101 has been approved by |
Make sure to clear out the stageN-{rustc,std,tools} directories. We copy built tool binaries into a dedicated directory to avoid deleting them, stageN-tools-bin. These aren't ever cleared out by code, since there should be no reason to do so, and we'll simply overwrite them as necessary. When clearing out the stageN-{std,rustc,tools} directories, make sure to delete both Cargo directories -- per-target and build scripts. This ensures that changing libstd doesn't cause problems due to build scripts not being rebuilt, even though they should be. Fixes #44739.
☀️ Test successful - status-appveyor, status-travis |
We copy built tool binaries into a dedicated directory to avoid deleting them,
stageN-tools-bin. These aren't ever cleared out by code, since there should be
no reason to do so, and we'll simply overwrite them as necessary.
When clearing out the stageN-{std,rustc,tools} directories, make sure to delete
both Cargo directories -- per-target and build scripts. This ensures that
changing libstd doesn't cause problems due to build scripts not being rebuilt,
even though they should be.
Fixes #44739.