Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7 #106686

Merged
merged 1 commit into from
Sep 3, 2024

Commits on Aug 30, 2024

  1. [clang] Don't add DWARF debug info when assembling .s with clang-cl /Z7

    This fixes a regression from f58330c.
    
    That commit changed the clang-cl options /Zi and /Z7 to be
    implemented as aliases of -g rather than having separate handling.
    
    This had the unintended effect, that when assembling .s files
    with clang-cl, the /Z7 option (which implies using CodeView debug
    info) was treated as a -g option, which causes `ClangAs::ConstructJob`
    to pick up the option as part of `Args.getLastArg(options::OPT_g_Group)`,
    which sets the `WantDebug` variable.
    
    Within `Clang::ConstructJob`, we check for whether explicit
    `-gdwarf` or `-gcodeview` options have been set, and if not, we
    pick the default debug format for the current toolchain. However,
    in `ClangAs`, if debug info has been enabled, it always adds DWARF
    debug info.
    
    Add similar logic in `ClangAs` - check if the user has explicitly
    requested either DWARF or CodeView, otherwise look up the toolchain
    default. If we (either implicitly or explicitly) should be producing
    CodeView, don't enable the default `ClangAs` DWARF generation.
    
    This fixes the issue, where assembling a single `.s` file with
    clang-cl, with the /Z7 option, causes the file to contain some DWARF
    sections. This causes the output executable to contain DWARF, in
    addition to the separate intended main PDB file.
    
    By having the output executable contain DWARF sections, LLDB only
    looks at the (very little) DWARF info in the executable, rather than
    looking for a separate standalone PDB file. This caused an issue
    with LLDB's tests, llvm#101710.
    mstorsjo committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    ac59e23 View commit details
    Browse the repository at this point in the history