Skip to content

Commit 6e8ea1c

Browse files
committed
Abort earlier when an error happens in jit mode
1 parent 96d76eb commit 6e8ea1c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/driver/jit.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ use std::os::raw::{c_char, c_int};
66

77
use rustc_codegen_ssa::CrateInfo;
88

9+
use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
10+
911
use crate::prelude::*;
1012

1113
pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
12-
use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
14+
if !tcx.sess.opts.output_types.should_codegen() {
15+
tcx.sess.fatal("JIT mode doesn't work with `cargo check`.");
16+
}
1317

1418
#[cfg(unix)]
1519
unsafe {
@@ -53,10 +57,6 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
5357
.declare_function("main", Linkage::Import, &sig)
5458
.unwrap();
5559

56-
if !tcx.sess.opts.output_types.should_codegen() {
57-
tcx.sess.fatal("JIT mode doesn't work with `cargo check`.");
58-
}
59-
6060
let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
6161
let mono_items = cgus
6262
.iter()
@@ -79,12 +79,12 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
7979
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true);
8080
crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context);
8181

82+
tcx.sess.abort_if_errors();
83+
8284
let jit_product = jit_module.finish();
8385

8486
let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_product) };
8587

86-
tcx.sess.abort_if_errors();
87-
8888
let finalized_main: *const u8 = jit_product.lookup_func(main_func_id);
8989

9090
println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed");

0 commit comments

Comments
 (0)