Auto merge of #148035 - bjorn3:check_skip_codegen_crate, r=madsmtm
Skip codegen_crate call in check mode This way we don't have to spawn the coordinator thread. Some errors will no longer be emitted with this in check mode. For example the check that `-Ctarget-cpu` is passed on targets that need this. Suggested by `@saethlin`
This commit is contained in:
@@ -8,6 +8,7 @@ use std::{env, fs, iter};
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr_parsing::{AttributeParser, ShouldEmit};
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
|
||||
use rustc_data_structures::jobserver::Proxy;
|
||||
use rustc_data_structures::steal::Steal;
|
||||
use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, WorkerLocal};
|
||||
@@ -1244,7 +1245,21 @@ pub(crate) fn start_codegen<'tcx>(
|
||||
|
||||
let metadata = rustc_metadata::fs::encode_and_write_metadata(tcx);
|
||||
|
||||
let codegen = tcx.sess.time("codegen_crate", move || codegen_backend.codegen_crate(tcx));
|
||||
let codegen = tcx.sess.time("codegen_crate", move || {
|
||||
if tcx.sess.opts.unstable_opts.no_codegen || !tcx.sess.opts.output_types.should_codegen() {
|
||||
// Skip crate items and just output metadata in -Z no-codegen mode.
|
||||
tcx.sess.dcx().abort_if_errors();
|
||||
|
||||
// Linker::link will skip join_codegen in case of a CodegenResults Any value.
|
||||
Box::new(CodegenResults {
|
||||
modules: vec![],
|
||||
allocator_module: None,
|
||||
crate_info: CrateInfo::new(tcx, "<dummy cpu>".to_owned()),
|
||||
})
|
||||
} else {
|
||||
codegen_backend.codegen_crate(tcx)
|
||||
}
|
||||
});
|
||||
|
||||
info!("Post-codegen\n{:?}", tcx.debug_stats());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::sync::Arc;
|
||||
|
||||
use rustc_codegen_ssa::CodegenResults;
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::indexmap::IndexMap;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_errors::timings::TimingSection;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
@@ -46,7 +47,14 @@ impl Linker {
|
||||
|
||||
pub fn link(self, sess: &Session, codegen_backend: &dyn CodegenBackend) {
|
||||
let (codegen_results, mut work_products) = sess.time("finish_ongoing_codegen", || {
|
||||
codegen_backend.join_codegen(self.ongoing_codegen, sess, &self.output_filenames)
|
||||
match self.ongoing_codegen.downcast::<CodegenResults>() {
|
||||
// This was a check only build
|
||||
Ok(codegen_results) => (*codegen_results, IndexMap::default()),
|
||||
|
||||
Err(ongoing_codegen) => {
|
||||
codegen_backend.join_codegen(ongoing_codegen, sess, &self.output_filenames)
|
||||
}
|
||||
}
|
||||
});
|
||||
sess.timings.end_section(sess.dcx(), TimingSection::Codegen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user