Skip to content

Commit

Permalink
Extract emit_allocator_module
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Dec 4, 2024
1 parent 27c9960 commit 87cd09b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,26 @@ pub(crate) fn run_aot(
modules
});

let allocator_module = emit_allocator_module(tcx);

let metadata_module =
if need_metadata_module { Some(emit_metadata_module(tcx, &metadata)) } else { None };

Box::new(OngoingCodegen {
modules,
allocator_module,
metadata_module,
metadata,
crate_info: CrateInfo::new(tcx, target_cpu),
concurrency_limiter: concurrency_limiter.0,
})
}

fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
let mut allocator_module = make_module(tcx.sess, "allocator_shim".to_string());
let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module);

let allocator_module = if created_alloc_shim {
if created_alloc_shim {
let product = allocator_module.finish();

match emit_module(
Expand All @@ -679,19 +695,7 @@ pub(crate) fn run_aot(
}
} else {
None
};

let metadata_module =
if need_metadata_module { Some(emit_metadata_module(tcx, &metadata)) } else { None };

Box::new(OngoingCodegen {
modules,
allocator_module,
metadata_module,
metadata,
crate_info: CrateInfo::new(tcx, target_cpu),
concurrency_limiter: concurrency_limiter.0,
})
}
}

fn emit_metadata_module(tcx: TyCtxt<'_>, metadata: &EncodedMetadata) -> CompiledModule {
Expand Down

0 comments on commit 87cd09b

Please sign in to comment.