Skip codegen_crate call in check mode

This commit is contained in:
bjorn3 2025-10-23 14:45:51 +00:00
parent cc27b04473
commit b548b29e10
2 changed files with 2 additions and 15 deletions

View file

@ -671,18 +671,7 @@ pub(crate) fn run_aot(tcx: TyCtxt<'_>) -> Box<OngoingCodegen> {
}
.to_owned();
let cgus = if tcx.sess.opts.output_types.should_codegen() {
tcx.collect_and_partition_mono_items(()).codegen_units
} else {
// If only `--emit metadata` is used, we shouldn't perform any codegen.
// Also `tcx.collect_and_partition_mono_items` may panic in that case.
return Box::new(OngoingCodegen {
modules: vec![],
allocator_module: None,
crate_info: CrateInfo::new(tcx, target_cpu),
concurrency_limiter: ConcurrencyLimiter::new(0),
});
};
let cgus = tcx.collect_and_partition_mono_items(()).codegen_units;
if tcx.dep_graph.is_fully_enabled() {
for cgu in cgus {

View file

@ -33,9 +33,7 @@ fn create_jit_module(tcx: TyCtxt<'_>) -> (UnwindModule<JITModule>, CodegenCx) {
}
pub(crate) fn run_jit(tcx: TyCtxt<'_>, jit_args: Vec<String>) -> ! {
if !tcx.sess.opts.output_types.should_codegen() {
tcx.dcx().fatal("JIT mode doesn't work with `cargo check`");
}
// FIXME error on check mode or crate types other than bin in CodegenBackend::init()
if !tcx.crate_types().contains(&rustc_session::config::CrateType::Executable) {
tcx.dcx().fatal("can't jit non-executable crate");