about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2020-10-11 11:31:36 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2020-10-11 11:31:36 +0200
commit6e8ea1c0490e125318c61bdc5918c1ee6137d146 (patch)
tree032501a02c4a9528dd0a3853d89302ebdb01f2e8
parent96d76eb8e478c4a9f82fa6bfc358294cd6942910 (diff)
downloadrust-6e8ea1c0490e125318c61bdc5918c1ee6137d146.tar.gz
rust-6e8ea1c0490e125318c61bdc5918c1ee6137d146.zip
Abort earlier when an error happens in jit mode
-rw-r--r--src/driver/jit.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/driver/jit.rs b/src/driver/jit.rs
index 6f398d045b6..b5bab3d9e1e 100644
--- a/src/driver/jit.rs
+++ b/src/driver/jit.rs
@@ -6,10 +6,14 @@ use std::os::raw::{c_char, c_int};
 
 use rustc_codegen_ssa::CrateInfo;
 
+use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
+
 use crate::prelude::*;
 
 pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
-    use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
+    if !tcx.sess.opts.output_types.should_codegen() {
+        tcx.sess.fatal("JIT mode doesn't work with `cargo check`.");
+    }
 
     #[cfg(unix)]
     unsafe {
@@ -53,10 +57,6 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
         .declare_function("main", Linkage::Import, &sig)
         .unwrap();
 
-    if !tcx.sess.opts.output_types.should_codegen() {
-        tcx.sess.fatal("JIT mode doesn't work with `cargo check`.");
-    }
-
     let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
     let mono_items = cgus
         .iter()
@@ -79,12 +79,12 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
     crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true);
     crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context);
 
+    tcx.sess.abort_if_errors();
+
     let jit_product = jit_module.finish();
 
     let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_product) };
 
-    tcx.sess.abort_if_errors();
-
     let finalized_main: *const u8 = jit_product.lookup_func(main_func_id);
 
     println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed");