@@ -14,7 +14,6 @@ use rustc_session::cgu_reuse_tracker::CguReuse;
1414use rustc_session:: config:: { DebugInfo , OutputType } ;
1515use rustc_session:: Session ;
1616
17- use cranelift_codegen:: isa:: TargetIsa ;
1817use cranelift_object:: { ObjectBuilder , ObjectModule } ;
1918
2019use crate :: global_asm:: GlobalAsmConfig ;
@@ -70,7 +69,9 @@ impl OngoingCodegen {
7069 }
7170}
7271
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+
7475 let mut builder =
7576 ObjectBuilder :: new ( isa, name + ".o" , cranelift_module:: default_libcall_names ( ) ) . unwrap ( ) ;
7677 // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
@@ -211,8 +212,7 @@ fn module_codegen(
211212 let cgu = tcx. codegen_unit ( cgu_name) ;
212213 let mono_items = cgu. items_in_deterministic_order ( tcx) ;
213214
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 ( ) ) ;
216216
217217 let mut cx = crate :: CodegenCx :: new (
218218 tcx,
@@ -330,9 +330,7 @@ pub(crate) fn run_aot(
330330
331331 tcx. sess . abort_if_errors ( ) ;
332332
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 ( ) ) ;
336334 let mut allocator_unwind_context = UnwindContext :: new ( allocator_module. isa ( ) , true ) ;
337335 let created_alloc_shim =
338336 crate :: allocator:: codegen ( tcx, & mut allocator_module, & mut allocator_unwind_context) ;
0 commit comments