@@ -14,7 +14,6 @@ use rustc_session::cgu_reuse_tracker::CguReuse;
14
14
use rustc_session:: config:: { DebugInfo , OutputType } ;
15
15
use rustc_session:: Session ;
16
16
17
- use cranelift_codegen:: isa:: TargetIsa ;
18
17
use cranelift_object:: { ObjectBuilder , ObjectModule } ;
19
18
20
19
use crate :: global_asm:: GlobalAsmConfig ;
@@ -70,7 +69,9 @@ impl OngoingCodegen {
70
69
}
71
70
}
72
71
73
- fn make_module ( sess : & Session , isa : Box < dyn TargetIsa > , name : String ) -> ObjectModule {
72
+ fn make_module ( sess : & Session , backend_config : & BackendConfig , name : String ) -> ObjectModule {
73
+ let isa = crate :: build_isa ( sess, backend_config) ;
74
+
74
75
let mut builder =
75
76
ObjectBuilder :: new ( isa, name + ".o" , cranelift_module:: default_libcall_names ( ) ) . unwrap ( ) ;
76
77
// Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
@@ -211,8 +212,7 @@ fn module_codegen(
211
212
let cgu = tcx. codegen_unit ( cgu_name) ;
212
213
let mono_items = cgu. items_in_deterministic_order ( tcx) ;
213
214
214
- let isa = crate :: build_isa ( tcx. sess , & backend_config) ;
215
- let mut module = make_module ( tcx. sess , isa, cgu_name. as_str ( ) . to_string ( ) ) ;
215
+ let mut module = make_module ( tcx. sess , & backend_config, cgu_name. as_str ( ) . to_string ( ) ) ;
216
216
217
217
let mut cx = crate :: CodegenCx :: new (
218
218
tcx,
@@ -330,9 +330,7 @@ pub(crate) fn run_aot(
330
330
331
331
tcx. sess . abort_if_errors ( ) ;
332
332
333
- let isa = crate :: build_isa ( tcx. sess , & backend_config) ;
334
- let mut allocator_module = make_module ( tcx. sess , isa, "allocator_shim" . to_string ( ) ) ;
335
- assert_eq ! ( pointer_ty( tcx) , allocator_module. target_config( ) . pointer_type( ) ) ;
333
+ let mut allocator_module = make_module ( tcx. sess , & backend_config, "allocator_shim" . to_string ( ) ) ;
336
334
let mut allocator_unwind_context = UnwindContext :: new ( allocator_module. isa ( ) , true ) ;
337
335
let created_alloc_shim =
338
336
crate :: allocator:: codegen ( tcx, & mut allocator_module, & mut allocator_unwind_context) ;
0 commit comments