Include debug info for the allocator shim
Issue Details: In some cases it is necessary to generate an "allocator shim" to forward various Rust allocation functions (e.g., `__rust_alloc`) to an underlying function (e.g., `malloc`). However, since this allocator shim is a manually created LLVM module it is not processed via the normal module processing code and so no debug info is generated for it (if debugging info is enabled). Fix Details: * Modify the `debuginfo` code to allow creating debug info for a module without a `CodegenCx` (since it is difficult, and expensive, to create one just to emit some debug info). * After creating the allocator shim add in basic debug info.
This commit is contained in:
parent
6cfa773583
commit
77a96ed564
5 changed files with 66 additions and 41 deletions
|
@ -538,12 +538,18 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
} else if let Some(kind) = tcx.allocator_kind(()) {
|
||||
let llmod_id =
|
||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
|
||||
let mut modules = backend.new_metadata(tcx, &llmod_id);
|
||||
let mut module_llvm = backend.new_metadata(tcx, &llmod_id);
|
||||
tcx.sess.time("write_allocator_module", || {
|
||||
backend.codegen_allocator(tcx, &mut modules, kind, tcx.lang_items().oom().is_some())
|
||||
backend.codegen_allocator(
|
||||
tcx,
|
||||
&mut module_llvm,
|
||||
&llmod_id,
|
||||
kind,
|
||||
tcx.lang_items().oom().is_some(),
|
||||
)
|
||||
});
|
||||
|
||||
Some(ModuleCodegen { name: llmod_id, module_llvm: modules, kind: ModuleKind::Allocator })
|
||||
Some(ModuleCodegen { name: llmod_id, module_llvm, kind: ModuleKind::Allocator })
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue