-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)Area: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.Category: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
// inner.rs
/// Byte order that is selectable at runtime.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum RunTimeEndian {
/// Little endian byte order.
Little,
/// Big endian byte order.
Big,
}
// main.rs
use inner::RunTimeEndian;
fn main() {
use RunTimeEndian::*;
println!("{:?}{:?}{:?}{:?}{:?}", Little, Big, Little, Big, Little);
}
I expected to see this happen: RunTimeEndian
only appears once in the debuginfo.
Instead, this happened: RunTimeEndian
appears twice:
; dwarfdump -a /home/jyn/.local/lib/cargo/target/debug/example | rg '\sRunTimeEndian$' -B5
< 1><0x00000329> DW_TAG_namespace
DW_AT_name inner
< 2><0x0000032e> DW_TAG_enumeration_type
DW_AT_type <0x00000322>
DW_AT_enum_class yes(1)
DW_AT_name RunTimeEndian
--
< 1><0x0000002a> DW_TAG_namespace
DW_AT_name inner
< 2><0x0000002f> DW_TAG_enumeration_type
DW_AT_type <0x00000088>
DW_AT_enum_class yes(1)
DW_AT_name RunTimeEndian
Note that the original (non-minimized) example was much worse; the correctness
integration test for addr2line
has this duplicated 59 times.
cc #129722, #115455. this is not the same as either of those because it only appears across codegen units (AFAICT).
Meta
rustc --version --verbose
:
rustc 1.86.0-nightly (049355708 2025-01-18)
binary: rustc
commit-hash: 049355708383ab1b9a1046559b9d4230bdb3a5bc
commit-date: 2025-01-18
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Metadata
Metadata
Assignees
Labels
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)Area: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.Category: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.