Skip to content

[Clang] Compiling and linking with -gdwarf generates PDB on Windows #165614

@Nerixyz

Description

@Nerixyz

When using -gdwarf Windows and linking with clang, a PDB file will be generated, because the linker is invoked with -debug. The PDB will only contain the S_PUB32 entries for the symbols from the object files (plus records from the PDBs of the default libraries), but it's confusing that this is generated when DWARF debug info is requested.

To reproduce:

> echo "int main(void){}" > test.c
> clang test.c -gdwarf -fuse-ld=lld -v
clang version 21.1.2
Target: x86_64-pc-windows-msvc
Thread model: posix
[...]
 "C:\\Users\\johannes\\scoop\\apps\\llvm-full\\21.1.2\\bin\\lld-link" -out:a.exe -defaultlib:libcmt -defaultlib:oldnames -libpath:[...] -nologo -debug "C:\\Users\\johannes\\AppData\\Local\\Temp\\test-0a0970.o"

The flag is added here:

if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
CmdArgs.push_back("-debug");

Is this expected/intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'platform:windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions