mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 01:05:39 +03:00
Put allocator shim in a different object file
This commit is contained in:
+6
-1
@@ -13,7 +13,8 @@
|
||||
use rustc::middle::allocator::AllocatorKind;
|
||||
use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS};
|
||||
|
||||
pub fn codegen(sess: &Session, module: &mut Module<impl Backend + 'static>) {
|
||||
/// Returns whether an allocator shim was created
|
||||
pub fn codegen(sess: &Session, module: &mut Module<impl Backend + 'static>) -> bool {
|
||||
let any_dynamic_crate = sess
|
||||
.dependency_formats
|
||||
.borrow()
|
||||
@@ -23,8 +24,12 @@ pub fn codegen(sess: &Session, module: &mut Module<impl Backend + 'static>) {
|
||||
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
|
||||
});
|
||||
if any_dynamic_crate {
|
||||
false
|
||||
} else if let Some(kind) = *sess.allocator_kind.get() {
|
||||
codegen_inner(module, kind);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -258,14 +258,21 @@ fn codegen_crate<'a, 'tcx>(
|
||||
let mut faerie_module = new_module("some_file".to_string());
|
||||
|
||||
codegen_cgus(tcx, &mut faerie_module, &mut log);
|
||||
crate::allocator::codegen(tcx.sess, &mut faerie_module);
|
||||
|
||||
tcx.sess.abort_if_errors();
|
||||
|
||||
let mut allocator_module = new_module("allocator_shim.o".to_string());
|
||||
let created_alloc_shim =
|
||||
crate::allocator::codegen(tcx.sess, &mut allocator_module);
|
||||
|
||||
return Box::new(CodegenResults {
|
||||
crate_name: tcx.crate_name(LOCAL_CRATE),
|
||||
modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module)],
|
||||
allocator_module: None,
|
||||
allocator_module: if created_alloc_shim {
|
||||
Some(emit_module("allocator_shim", ModuleKind::Allocator, allocator_module))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
metadata_module: CompiledModule {
|
||||
name: "dummy_metadata".to_string(),
|
||||
kind: ModuleKind::Metadata,
|
||||
|
||||
Reference in New Issue
Block a user