Skip to content

-Cdebuginfo=1 wastefully produces full type descriptions. #69074

Closed
@eddyb

Description

This example makes -Cdebuginfo=1 emit the variant (see godbolt output):

pub enum Foo {
    ThisShouldNotBeInDebugInfo([u8; 1337])
}

impl Foo {
    pub fn foo() {}
}

Its resulting LLVM IR shows all of these DebugInfo metadata nodes:

!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !8, file: !7, size: 10696, align: 8, elements: !{!10}, identifier: "65d4d9f1044eb0325dc66254af8523df")
!10 = !DICompositeType(tag: DW_TAG_variant_part, scope: !8, file: !7, size: 10696, align: 8, elements: !{!12}, templateParams: !4, identifier: "65d4d9f1044eb0325dc66254af8523df_variant_part")
!12 = !DIDerivedType(tag: DW_TAG_member, name: "ThisShouldNotBeInDebugInfo", scope: !10, file: !7, baseType: !13, size: 10696, align: 8)
!13 = !DICompositeType(tag: DW_TAG_structure_type, name: "ThisShouldNotBeInDebugInfo", scope: !6, file: !7, size: 10696, align: 8, elements: !{!15}, templateParams: !4, identifier: "65d4d9f1044eb0325dc66254af8523df::ThisShouldNotBeInDebugInfo")
!15 = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: !13, file: !7, baseType: !16, size: 10696, align: 8)
!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 10696, align: 8, elements: !{!19})
!17 = !DIBasicType(name: "u8", size: 8, encoding: DW_ATE_unsigned)
!19 = !DISubrange(count: 1337)

But at -Cdebuginfo=1, this is really what we want to see:

!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !8, file: !7)

If this doesn't work we can always just use DINamespace instead.


IIUC, this specific example is caused from the way we handle inherent impls, but there might be others, so we probably want to make the debuginfo generating infrastructure ICE when it's trying to generate non-trivial type debuginfo but -Cdebuginfo=1 is set.

Oh, and, I found this because librustc_driver-*.so is 1GB with debuginfo-level=1 (and debug-assertions=1) in config.toml, and most of that is type debuginfo.

cc @rust-lang/compiler @alexcrichton

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions