Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ab7c706

Browse files
committed
Move build_isa call into make_module
1 parent d3512b1 commit ab7c706

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/driver/aot.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_session::cgu_reuse_tracker::CguReuse;
1414
use rustc_session::config::{DebugInfo, OutputType};
1515
use rustc_session::Session;
1616

17-
use cranelift_codegen::isa::TargetIsa;
1817
use cranelift_object::{ObjectBuilder, ObjectModule};
1918

2019
use 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

Comments
 (0)