Skip to content

Pick the max DWARF version when LTO'ing modules with different versions #136659

Merged
bors merged 2 commits intorust-lang:masterfrom
wesleywiser:dwarf_version_lto_merge_behavior
Feb 9, 2025
Merged

Pick the max DWARF version when LTO'ing modules with different versions #136659
bors merged 2 commits intorust-lang:masterfrom
wesleywiser:dwarf_version_lto_merge_behavior

Conversation

@wesleywiser
Copy link
Member

@wesleywiser wesleywiser commented Feb 6, 2025

Currently, when rustc compiles code with -Clto enabled that was built
with different choices for -Zdwarf-version, a warning will be
reported. It's very easy to observe this by compiling most anything (eg,
"hello world") and specifying -Clto -Zdwarf-version=5 since the
standard library is distributed with -Zdwarf-version=4.

This behavior isn't actually useful for a few reasons:

  • From observation, LLVM chooses to pick the highest DWARF version
    anyway after issuing the warning.
  • Clang specifies that in this case, the max version should be picked
    without a warning and as a general principle, we want to support
    x-lang LTO with Clang which implies using the same module flag merge
    behaviors.
  • Debuggers need to be able to handle a variety of versions within the
    same debugging session as you can easily have some parts of a binary
    (or some dynamic libraries within an application) all compiled with
    different DWARF versions.

This commit changes the module flag merge behavior to match Clang and
use the highest version of DWARF. It also adds a test to ensure this
behavior is respected in the case of two crates being LTO'd together and
adds a test to ensure no warning is printed.

Fixes #130041 which fails due to these warnings being printed

cc #103057

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building with -Z dwarf-version=5 causes lto debuginfo test failures

6 participants