-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Eagerly compute output_filenames #117584
Eagerly compute output_filenames #117584
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
// Make sure name resolution and macro expansion is run for | ||
// the side-effect of providing a complete set of all | ||
// accessed files and env vars. | ||
let _ = tcx.resolver_for_lowering(()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use ensure()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If resolver_for_lowering
weren't eval_always
and it is green, using ensure()
would mean that the side effects of resolver_for_lowering
(adding the list of used files and env vars to the Session
) are not replayed as far as I understand it. Now resolver_for_lowering
is eval_always
currently, so it shouldn't matter for now I guess. There shouldn't be any perf difference though as resolver_for_lowering
returns a reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe add a comment in the query definition explaining this, i.e. why this needs to be eval_always
?
@@ -580,7 +580,7 @@ pub enum ResolveDocLinks { | |||
/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break | |||
/// dependency tracking for command-line arguments. Also only hash keys, since tracking | |||
/// should only depend on the output types, not the paths they're written to. | |||
#[derive(Clone, Debug, Hash, HashStable_Generic)] | |||
#[derive(Clone, Debug, Hash, HashStable_Generic, Encodable, Decodable)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this cause us to leak host info into build artifacts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rlink file already contains absolute file paths. rustc -Zlink-only foo.rlink
is supposed to be called immediately after all dependencies of a rustc -Zlink-only
invocation are finished. This has to be done on the same machine and can only be done once because all temporary files that are shared between the two rustc invocations have unpredictable names and are removed by rustc -Zlink-only
.
☔ The latest upstream changes (presumably #118001) made this pull request unmergeable. Please resolve the merge conflicts. |
2aa5e3c
to
2b849e6
Compare
☔ The latest upstream changes (presumably #117993) made this pull request unmergeable. Please resolve the merge conflicts. |
2b849e6
to
bea98b1
Compare
☔ The latest upstream changes (presumably #118002) made this pull request unmergeable. Please resolve the merge conflicts. |
#[deprecated = "pre_configure may be made private in the future. If you need it please open an issue with your use case."] | ||
pub fn pre_configure(&self) -> Result<QueryResult<'_, (ast::Crate, ast::AttrVec)>> { | ||
self.pre_configure.compute(|| { | ||
pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The commit message of the third commit is truncated. |
bea98b1
to
0709954
Compare
I think the line that got removed originally started with |
☔ The latest upstream changes (presumably #118086) made this pull request unmergeable. Please resolve the merge conflicts. |
0709954
to
4b809b6
Compare
☔ The latest upstream changes (presumably #117301) made this pull request unmergeable. Please resolve the merge conflicts. |
This ensures that linking will use the correct crate name even when `#![crate_name = "..."]` is used to specify the crate name.
Since the introduction of the crate attribute pre-expansion pass we don't need access to the TyCtxt to compute it.
It has side-effects and as such can't be cached.
4b809b6
to
d7e9a30
Compare
// Make sure name resolution and macro expansion is run for | ||
// the side-effect of providing a complete set of all | ||
// accessed files and env vars. | ||
let _ = tcx.resolver_for_lowering(()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe add a comment in the query definition explaining this, i.e. why this needs to be eval_always
?
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (ac9b308): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.544s -> 675.005s (0.22%) |
It can be computed before creating TyCtxt. Previously the query would also write the dep info file, which meant that the output filenames couldn't be accessed before macro expansion is done. The dep info file writing is now done as a separate non-query function. The old query was always executed again anyways due to depending on the HIR.
Also encode the output_filenames in rlink files to ensure
#![crate_name]
affects the linking stage when doing separate compiling and linking using-Zno-link
/-Zlink-only
.