@@ -10,6 +10,7 @@ use std::sync::{mpsc, Mutex};
10
10
use cranelift_codegen:: binemit:: { NullStackMapSink , NullTrapSink } ;
11
11
use rustc_codegen_ssa:: CrateInfo ;
12
12
use rustc_middle:: mir:: mono:: MonoItem ;
13
+ use rustc_session:: Session ;
13
14
14
15
use cranelift_jit:: { JITBuilder , JITModule } ;
15
16
@@ -65,7 +66,8 @@ fn create_jit_module<'tcx>(
65
66
backend_config : & BackendConfig ,
66
67
hotswap : bool ,
67
68
) -> ( JITModule , CodegenCx < ' tcx > ) {
68
- let imported_symbols = load_imported_symbols_for_jit ( tcx) ;
69
+ let crate_info = CrateInfo :: new ( tcx) ;
70
+ let imported_symbols = load_imported_symbols_for_jit ( tcx. sess , crate_info) ;
69
71
70
72
let isa = crate :: build_isa ( tcx. sess , backend_config) ;
71
73
let mut jit_builder = JITBuilder :: with_isa ( isa, cranelift_module:: default_libcall_names ( ) ) ;
@@ -255,14 +257,16 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
255
257
} )
256
258
}
257
259
258
- fn load_imported_symbols_for_jit ( tcx : TyCtxt < ' _ > ) -> Vec < ( String , * const u8 ) > {
260
+ fn load_imported_symbols_for_jit (
261
+ sess : & Session ,
262
+ crate_info : CrateInfo ,
263
+ ) -> Vec < ( String , * const u8 ) > {
259
264
use rustc_middle:: middle:: dependency_format:: Linkage ;
260
265
261
266
let mut dylib_paths = Vec :: new ( ) ;
262
267
263
- let crate_info = CrateInfo :: new ( tcx) ;
264
- let formats = tcx. dependency_formats ( ( ) ) ;
265
- let data = & formats
268
+ let data = & crate_info
269
+ . dependency_formats
266
270
. iter ( )
267
271
. find ( |( crate_type, _data) | * crate_type == rustc_session:: config:: CrateType :: Executable )
268
272
. unwrap ( )
@@ -272,9 +276,8 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
272
276
match data[ cnum. as_usize ( ) - 1 ] {
273
277
Linkage :: NotLinked | Linkage :: IncludedFromDylib => { }
274
278
Linkage :: Static => {
275
- let name = tcx. crate_name ( cnum) ;
276
- let mut err =
277
- tcx. sess . struct_err ( & format ! ( "Can't load static lib {}" , name. as_str( ) ) ) ;
279
+ let name = & crate_info. crate_name [ & cnum] ;
280
+ let mut err = sess. struct_err ( & format ! ( "Can't load static lib {}" , name. as_str( ) ) ) ;
278
281
err. note ( "rustc_codegen_cranelift can only load dylibs in JIT mode." ) ;
279
282
err. emit ( ) ;
280
283
}
@@ -314,7 +317,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
314
317
std:: mem:: forget ( lib)
315
318
}
316
319
317
- tcx . sess . abort_if_errors ( ) ;
320
+ sess. abort_if_errors ( ) ;
318
321
319
322
imported_symbols
320
323
}
0 commit comments