@@ -6,10 +6,14 @@ use std::os::raw::{c_char, c_int};
6
6
7
7
use rustc_codegen_ssa:: CrateInfo ;
8
8
9
+ use cranelift_simplejit:: { SimpleJITBuilder , SimpleJITModule } ;
10
+
9
11
use crate :: prelude:: * ;
10
12
11
13
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
+ }
13
17
14
18
#[ cfg( unix) ]
15
19
unsafe {
@@ -53,10 +57,6 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
53
57
. declare_function ( "main" , Linkage :: Import , & sig)
54
58
. unwrap ( ) ;
55
59
56
- if !tcx. sess . opts . output_types . should_codegen ( ) {
57
- tcx. sess . fatal ( "JIT mode doesn't work with `cargo check`." ) ;
58
- }
59
-
60
60
let ( _, cgus) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
61
61
let mono_items = cgus
62
62
. iter ( )
@@ -79,12 +79,12 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
79
79
crate :: main_shim:: maybe_create_entry_wrapper ( tcx, & mut jit_module, & mut unwind_context, true ) ;
80
80
crate :: allocator:: codegen ( tcx, & mut jit_module, & mut unwind_context) ;
81
81
82
+ tcx. sess . abort_if_errors ( ) ;
83
+
82
84
let jit_product = jit_module. finish ( ) ;
83
85
84
86
let _unwind_register_guard = unsafe { unwind_context. register_jit ( & jit_product) } ;
85
87
86
- tcx. sess . abort_if_errors ( ) ;
87
-
88
88
let finalized_main: * const u8 = jit_product. lookup_func ( main_func_id) ;
89
89
90
90
println ! ( "Rustc codegen cranelift will JIT run the executable, because --jit was passed" ) ;
0 commit comments