<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - PDB emission fails with thin-lto"
   href="https://bugs.llvm.org/show_bug.cgi?id=34499">34499</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>PDB emission fails with thin-lto
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>COFF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Alberto.Magni@microsoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19107" name="attach_19107" title="Reproducer">attachment 19107</a> <a href="attachment.cgi?id=19107&action=edit" title="Reproducer">[details]</a></span>
Reproducer

Given the reproducer attached, the following sequence of commands

clang-cl /c /Zi /O2 -flto=thin foo.c
clang-cl /c /Zi /O2 -flto=thin main.c
lld-link /OUT:prog.exe /DEBUG /PDB:prog.pdb /subsystem:CONSOLE /entry:main
foo.obj main.obj

produces this error:

Native PDB Error: The entry already exists.  The specified module already
exists

The following commands, with full LTO, work correctly:

clang-cl /c /Zi /O2 -flto foo.c
clang-cl /c /Zi /O2 -flto main.c
lld-link /OUT:prog.exe /DEBUG /PDB:prog.pdb /subsystem:CONSOLE /entry:main
foo.obj main.obj

I am using:
<a href="https://github.com/llvm-mirror/clang.git">https://github.com/llvm-mirror/clang.git</a>
3f0db6ed816c5fae9bf6a7b2b1711e8fc57b8589
<a href="https://github.com/llvm-mirror/llvm.git">https://github.com/llvm-mirror/llvm.git</a>
aba02efc6c6441eddd72388638f70cbb17e39b96
<a href="https://github.com/llvm-mirror/lld.git">https://github.com/llvm-mirror/lld.git</a>:
d470133e80e2090b7281880320ddead759c7fa2d</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>