llvm / llvm/llvm-project

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

Open
#165,614 1 comment 0 reactions 0 assignees View on GitHub
clang:driver platform:windows
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

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:
```console
> 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:
https://github.com/llvm/llvm-project/blob/7b98280b6b7cb89b141a5874ff9ee3ce72dab92a/clang/lib/Driver/ToolChains/MSVC.cpp#L167-L168

Is this expected/intentional?

Contributor guide

Open the contributing guide

Research direction

Reproduce the Windows case with clang test.c -gdwarf -fuse-ld=lld -v and inspect clang/lib/Driver/ToolChains/MSVC.cpp at the linked lines where -debug is added. Determine the intended interaction between -gdwarf and linker PDB generation; done means the behavior is resolved and covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.