-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Move metadata generation #145834
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
base: master
Are you sure you want to change the base?
Move metadata generation #145834
Conversation
It's currently done within `start_codegen`, which is called from `codegen_and_build_linker`, and it gets included in the codegen timing section. All this is surprising, because it's not part of codegen. This commit moves it into `run_compiler`, just before the call to `codegen_and_build_linker`. This is a more sensible place for it. The commit also adds some extra non-obvious information about the `has_errors_or_delayed_bugs` check, which I learned when I tried moving metadata generation earlier. Likewise, the nearby `rustc_delayed_bug_from_inside_query` code is also moved, because (a) it's not part of codegen, and (b) it needs to be nearby.
The background here: I was trying to see if metadata generation could be moved significantly earlier to increase the amount of overlap provided by compilation pipelining. This turns out to be difficult; lots of things start to break if metadata generation precedes some or all of analysis. But I figured I could do this cleanup and improve some comments with some things I learned. |
Oh, I guess that metadata generation was part of the "backend" section, as recorded in rustc-perf and |
// during codegen, obscuring the original problem. | ||
if let Some(guar) = tcx.sess.dcx().has_errors_or_delayed_bugs() { | ||
guar.raise_fatal(); | ||
} |
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 way it is easy to forget to call this function before calling codegen_and_build_linker
. rustc_interface is meant to be called directly by custom drivers if rustc_driver doesn't provide enough flexibility. For example for rustdoc. mutest-rs also uses it directly. Also by moving this call before report_symbol_names
, errors in the latter no longer block codegen. Maybe instead just move the tcx.sess.timings.start_section(tcx.sess.dcx(), TimingSection::Codegen);
later in codegen_and_build_linker
?
It's currently done within
start_codegen
, which is called fromcodegen_and_build_linker
, and it gets included in the codegen timing section. All this is surprising, because it's not part of codegen.This commit moves it into
run_compiler
, just before the call tocodegen_and_build_linker
. This is a more sensible place for it. The commit also adds some extra non-obvious information about thehas_errors_or_delayed_bugs
check, which I learned when I tried moving metadata generation earlier.Likewise, the nearby
rustc_delayed_bug_from_inside_query
code is also moved, because (a) it's not part of codegen, and (b) it needs to be nearby.r? @bjorn3