Repository navigation
State that incremental compilation assumes the same compiler - #3071
Closed
isHeSatoshi wants to merge 1 commit into
Closed
isHeSatoshi wants to merge 1 commit into
isHeSatoshi wants to merge 1 commit into
Conversation
Nothing in the chapter said that the red-green algorithm assumes the compiler itself is unchanged between the previous and the current compilation. A reader who is still thinking about building the compiler can reasonably wonder whether the saved query DAG is reused when the compiler changes, since a changed query produces a different result for the same inputs. Add a note at the top: the assumption is that the same compiler is used, and `rustc` does not try to cope with a changed one. Each cache file begins with a header containing the compiler's version string, which encodes the git commit hash, and a file whose header does not match is treated as out of date, which invalidates the session directory and starts the compilation from scratch.
This comment was marked as low quality.
This comment was marked as low quality.
Collaborator
|
Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1860.
The chapter describes the red-green algorithm without saying that it assumes the compiler itself does not change between the previous and the current compilation. That is an easy assumption to miss while reading a guide about how to build and change the compiler: if a query's implementation changes, the same inputs no longer produce the same result, and the saved query DAG stops meaning anything.
The issue also asks whether it works anyway when you change rustc. It does not get the chance to, because
rustcdiscards the cache rather than trying to cope with it.This adds a note at the top of the chapter covering both points:
Where this comes from, for review:
rustc_incremental/src/persist/file_format.rswrites the header asFILE_MAGIC, aHEADER_FORMAT_VERSION, and the result ofrustc_version(sess), which issess.cfg_version(with aRUSTC_FORCE_RUSTC_VERSIONoverride that tests use to force a mismatch on demand). Its module docs state that "compatible compiler version" means "exactly the same compiler version", since the header encodes the git commit hash of the compiler, and that being conservative costs little because the cache can always just be ignored.OpenFileError::NotFoundOrHeaderMismatch, whichload_dep_graphmaps toLoadResult::DataOutOfDate, documented as "The file either didn't exist or was produced by an incompatible compiler version".setup_dep_graphhandlesDataOutOfDateby callinginvalidate_old_session_dirand starting from an empty dep graph.No new links are added.