ssa: remove dwo of metadata and allocator module

Compiling with `-Csplit-debuginfo=packed` was leaving behind `.dwo`
files because either the metadata or allocator module contained a DWARF
object which was not being removed by the
`maybe_remove_temps_from_module` closure.
This commit is contained in:
David Wood 2022-07-06 10:15:45 +01:00
parent 8371a036ea
commit fc641f21c2

View File

@ -151,11 +151,23 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
return;
}
let remove_temps_from_module = |module: &CompiledModule| {
if let Some(ref obj) = module.object {
ensure_removed(sess.diagnostic(), obj);
}
};
let maybe_remove_temps_from_module =
|preserve_objects: bool, preserve_dwarf_objects: bool, module: &CompiledModule| {
if !preserve_objects {
if let Some(ref obj) = module.object {
ensure_removed(sess.diagnostic(), obj);
}
}
if !preserve_dwarf_objects {
if let Some(ref dwo_obj) = module.dwarf_object {
ensure_removed(sess.diagnostic(), dwo_obj);
}
}
};
let remove_temps_from_module =
|module: &CompiledModule| maybe_remove_temps_from_module(false, false, module);
// Otherwise, always remove the metadata and allocator module temporaries.
if let Some(ref metadata_module) = codegen_results.metadata_module {
@ -177,15 +189,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
debug!(?preserve_objects, ?preserve_dwarf_objects);
for module in &codegen_results.modules {
if !preserve_objects {
remove_temps_from_module(module);
}
if !preserve_dwarf_objects {
if let Some(ref obj) = module.dwarf_object {
ensure_removed(sess.diagnostic(), obj);
}
}
maybe_remove_temps_from_module(preserve_objects, preserve_dwarf_objects, module);
}
});