llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.13k stars 12.01k forks source link

Duplicate symbols in PDB public symbol stream #50725

Open MolecularMatters opened 3 years ago

MolecularMatters commented 3 years ago
Bugzilla Link 51383
Version unspecified
OS Windows NT
CC @smithp35

Extended Description

I recently noticed that in certain cases, the PDB file produced by lld will contain symbols twice in the public symbol stream.

Here's a short repro case:

include

void Func(void) {}

int main(void) { std::thread t(&Func); return 0; }

Compile and link the above with clang-cl and lld-link, respectively. Note that the PDB file will contain the symbol ??_Gbad_array_new_length@std@@UEAAPEAXI@Z twice in the public symbol stream.

I've noticed this with other symbols as well, but the above repro should be the easiest to reproduce.

I have never seen any duplicate symbol in PDBs produced by MSVC, and the public symbol stream is meant to contain only unique, external symbols with their RVA and mangled name, so I don't think this is intentional. It might trip up some tools working with PDB files, as it did Live++.

MolecularMatters commented 3 years ago

In case it should matter, here are the command line arguments used for invoking clang-cl:

-c -Zi -JMC -nologo -W0 -WX- -diagnostics:column -Od -Oy- -D_DEBUG -D_WINDOWS -D_UNICODE -DUNICODE -EHs -EHc -RTC1 -MDd -GS -Zc:wchar_t -Zc:forScope -Zc:inline -Zc:rvalueCast -GR- -openmp- -Gd -TP -FC -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\Include\um" -X

And here they are for lld-link: /ERRORREPORT:PROMPT /OUT:%outDir%\Repro.exe /INCREMENTAL:NO /NOLOGO /FUNCTIONPADMIN /MANIFEST "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FULL /PDB:%outDir%\Repro.pdb /SUBSYSTEM:CONSOLE /OPT:NOREF /OPT:NOICF /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\lib\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\atlmfc\lib\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\lib\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64"

llvmbot commented 2 years ago

@llvm/issue-subscribers-lld-coff