-
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
Tracking Issue for bootstrap spurious rebuilds #131726
Comments
Setting flags in the wrapper can also be an issue because it means cargo doesn't know about them and if bootstrap picks different flags, cargo won't know it has to rebuild. So that can easily lead to the opposite bug where a rebuild is needed due to config changes or a bootstrap update, but then a rebuild doesn't happen. |
It’s worth mentioning in the implementation that we shouldn’t pass a rustflags to the wrapper if it’s propagated dynamically (e.g., from config.toml). But in most cases bootstrap sets rustflags consistently so this situation shouldn't happen. |
Remember that the build cache might have been built with a previous version of bootstrap. Bootstrap doesn't set the flags consistently over time, a |
Hm, would a possible mechanism be to record which RUSTFLAGS a particular tool/lib was built with, then perform additional invalidation to the build cache from a bootstrap perspective, and not just from cargo (as the untracked env vars are not known to cargo)? |
Well then we get rebuilds again. ;) We really need to ensure that the flags are consistent. Maybe by using better APIs that avoid having to set the same flags in 3 different places, or so. It's not an easy problem. |
We will do that already but it's not enough. We can create a mechanism to clear the cache when untracked/implicit rustflags (ones that are propagated to wrappers from bootstrap) change. I think this is the most sensible solution as it solves the main issue. In CI, it's already a one-shot build, and for developers it shouldn't be too much trouble to trigger a rebuild occasionally (this should be rare since we don't expect to change untracked rustflags too often). |
That's exactly what cargo already does if we tell it about the flags, so what's the benefit of that over the status quo? The fix to "we have rebuilds because the flags are different" can't be "stop the rebuilds" (that replaces rebuilds by a worse bug: producing the wrong output), it has to be "make the flags not different". So moving the flag application into the RUSTC_WRAPPER doesn't help. |
I wonder if we can do the other direction: enforce the rule where build caches may only be shared if they share the same |
Sorry if I wasn't clear. I was thinking about a mechanism that triggers when things change (which can happen after
We are already aiming to do that, the problem is there are cases when you can't set the flag unconditionally for every rust/src/bootstrap/src/core/build_steps/tool.rs Lines 212 to 228 in 88f3114
By the way we already have multiple flags being set inside rustc wrapper, so I am not trying to add a new concept here but rather handle this sub-problem which already exists. |
I don't think we should touch |
Sorry if I wasn't clear. I'm was thinking about a mechanism that triggers when things change (which can happen after git pull) in wrapper module.
How is that different from cargo triggering a rebuild when flags change?
If there is a logic bug and flags differ in expectedly, a rebuild is the safe thing to do! We should not override that logic, doing so will introduce subtle correctness bugs.
The current situation is just that the APIs inside bootstrap are a bit messy and flags need to be set in multiple places to be consistently applied. That's the actual source of the issue.
|
It's not just that and I already wrote it in #131726 (comment). |
Ah I see, you want to basically hash the
Maybe the resolution here is to take a different approach to the "on broken pipe" flag? Doing this via a |
You may want to raise that on the tracking issue: #97889. It was originally an attribute but was switched to a compiler flag to avoid polluting the language with library concerns. |
Alternatively we could use support for per-package rustflags in cargo, and use that to set the flag on the binaries we want it for? Bootstrap doesn't have to do things that cargo can do just as well. ;) See here for an example of what that may look like. |
The flags situation is more tricky than I initially figured:
Temporarily unassigning myself because I still need to investigate it, and should not block any intermediate efforts. |
This is a tracking issue for collecting spurious rebuild issues in bootstrap. Spurious rebuilds refer to rebuilds that seem unnecessary, e.g. if running
./x test run-make
twice in a row without modifying any sources rebuilds cargo. Note that is this not always the case, e.g. at the time when this issue was created,mir-opt
tests build a special std withmir-opt
RUSTFLAGS
, which will need to be rebuilt if trying to go to stage2 because a stage2 rustc will expect a stage1 "standard" std build withoutmir-opt
RUSTFLAGS
(there are other solutions to that, not in the scope of this issue).Categories
NOTE: There is only currently one category of spurious rebuilds that I am acutely aware of, it's entirely possible to have other classes of causes for spurious rebuilds.
Differing
RUSTFLAGS
While some of these issues are closed, the fixes are usually stopgap solutions.
./x test mir-opt
rebuilds std every time #131437RUSTFLAGS
too viacargo.configure_linker
../x.py test miri --stage 0
twice rebuilds miri, cargo-miri, and rustdoc #123177Preventing spurious rebuilds due to differing
RUSTFLAGS
To solve the class of spurious rebuilds due to differing
RUSTFLAGS
, we will need to properly handle them. Specifically, we need to (#131636 (comment)):RUSTFLAGS
handling to forbid naive "conditional"RUSTFLAGS
.RUSTFLAGS
should be propagated to bootstrap shims using environment variable (something likeIMPLICIT_RUSTFLAGS
) so they can't invalidate the build cache.Discussion
https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Mechanism.20for.20better.20RUSTFLAGS.20handling
The text was updated successfully, but these errors were encountered: