Skip to content

Commit fc641f2

Browse files
committed
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.
1 parent 8371a03 commit fc641f2

File tree

1 file changed

+18
-14
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+18
-14
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,23 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
151151
return;
152152
}
153153

154-
let remove_temps_from_module = |module: &CompiledModule| {
155-
if let Some(ref obj) = module.object {
156-
ensure_removed(sess.diagnostic(), obj);
157-
}
158-
};
154+
let maybe_remove_temps_from_module =
155+
|preserve_objects: bool, preserve_dwarf_objects: bool, module: &CompiledModule| {
156+
if !preserve_objects {
157+
if let Some(ref obj) = module.object {
158+
ensure_removed(sess.diagnostic(), obj);
159+
}
160+
}
161+
162+
if !preserve_dwarf_objects {
163+
if let Some(ref dwo_obj) = module.dwarf_object {
164+
ensure_removed(sess.diagnostic(), dwo_obj);
165+
}
166+
}
167+
};
168+
169+
let remove_temps_from_module =
170+
|module: &CompiledModule| maybe_remove_temps_from_module(false, false, module);
159171

160172
// Otherwise, always remove the metadata and allocator module temporaries.
161173
if let Some(ref metadata_module) = codegen_results.metadata_module {
@@ -177,15 +189,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
177189
debug!(?preserve_objects, ?preserve_dwarf_objects);
178190

179191
for module in &codegen_results.modules {
180-
if !preserve_objects {
181-
remove_temps_from_module(module);
182-
}
183-
184-
if !preserve_dwarf_objects {
185-
if let Some(ref obj) = module.dwarf_object {
186-
ensure_removed(sess.diagnostic(), obj);
187-
}
188-
}
192+
maybe_remove_temps_from_module(preserve_objects, preserve_dwarf_objects, module);
189193
}
190194
});
191195

0 commit comments

Comments
 (0)