diff --git a/crates/cranelift/src/debug/write_debuginfo.rs b/crates/cranelift/src/debug/write_debuginfo.rs index a82796cb34..561b90ef00 100644 --- a/crates/cranelift/src/debug/write_debuginfo.rs +++ b/crates/cranelift/src/debug/write_debuginfo.rs @@ -54,6 +54,9 @@ fn emit_dwarf_sections( sections.for_each_mut(|id, s| -> anyhow::Result<()> { let name = id.name(); let body = s.writer.take(); + if body.is_empty() { + return Ok(()); + } let mut relocs = vec![]; ::std::mem::swap(&mut relocs, &mut s.relocs); result.push(DwarfSection { name, body, relocs });