<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 - Invalid checksum computation when compiling from preprocessed output"
   href="https://bugs.llvm.org/show_bug.cgi?id=41215">41215</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid checksum computation when compiling from preprocessed output
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lambert.clara@yahoo.fr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21662" name="attach_21662" title="Fix">attachment 21662</a> <a href="attachment.cgi?id=21662&action=edit" title="Fix">[details]</a></span>
Fix

When clang-cl compiles an object from preprocessed output, the checksum of the
individual files that were included in it will be incorrect in the generated
debug info, since it will be the checksum of the preprocessed file, instead of
being the one from the files themselves.

This leads to an error when debugging from visual studio, since the files will
be considered different from their source, we get a popup with the message "The
source file is different from when the module was built. Would you like the
debugger to use it anyway?".

This can be reproduced with those steps:
- Create two files, main.cpp and lib.h
- Include lib.h in main.cpp
- Generate the pp output with `clang-cl /c main.cpp /Z7 /P"
- Compile the generated pp output to an obj
- Link and generate an exe and pdb
- Use `cvdump -sf main.pdb`
- Notice that under the main.obj module, each file's MD5 is the same:

** Module: "E:\RD\tests\clang_hash\main.obj"

     0 E:\RD\tests\clang_hash\lib.h (MD5: 136293700AE501A1FB76EBD273C8D288)
     1 C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h
(MD5: 136293700AE501A1FB76EBD273C8D288)
     2 E:\RD\tests\clang_hash\main.cpp (MD5: 136293700AE501A1FB76EBD273C8D288)
     3 C:\Program Files (x86)\Windows
Kits\10\Include\10.0.17763.0\ucrt\corecrt_stdio_config.h (MD5:
136293700AE501A1FB76EBD273C8D288)




MSVC compiler clears out the checksum field in that instance:

** Module: "E:\RD\tests\clang_hash\main.obj"

     0 c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\stdio.h
(None)
     1 c:\program files (x86)\windows
kits\10\include\10.0.17763.0\ucrt\corecrt_wstdio.h (None)
     2 c:\program files (x86)\windows
kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h (None)
     3 c:\program files (x86)\microsoft visual
studio\2017\professional\vc\tools\msvc\14.16.27023\include\vcruntime_new.h
(None)
     4 e:\rd\tests\clang_hash\main.cpp (None)
     5 e:\rd\tests\clang_hash\lib.h (None)

I've attached a patch for that issue, that makes the behavior of clang match
the one from MSVC.</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>