<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 - DebugInfo Stripping sometimes causes a Broken Input Module"
   href="https://bugs.llvm.org/show_bug.cgi?id=49522">49522</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DebugInfo Stripping sometimes causes a Broken Input Module
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>reverett@digital.ai
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24619" name="attach_24619" title="Source code from Boost::Spirit (I think) that leaves Debug Metadata after stripping">attachment 24619</a> <a href="attachment.cgi?id=24619&action=edit" title="Source code from Boost::Spirit (I think) that leaves Debug Metadata after stripping">[details]</a></span>
Source code from Boost::Spirit (I think) that leaves Debug Metadata after
stripping

With the latest LLVM source and the recent Xcode 12.5 betas, we've noticed that
stripping debug info from certain object files is broken both in the clang++
frontend and when directly calling llvm::StripDebugInfo or using
llvm::createStripSymbolsPass(true). The error seen after lowering a stripped
object file with embedded bitcode:

DICompileUnit not listed in llvm.dbg.cu
!3714 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !10,
producer: "clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
023b5c1ed8d1577bf0cf298b64a0a047b13fc418)", isOptimized: false, runtimeVersion:
0, emissionKind: FullDebug, enums: !3715, retainedTypes: !3729, globals:
!29030, imports: !29860, splitDebugInlining: false, nameTableKind: None,
sysroot:
"/Applications/Xcode_12.5b2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk",
sdk: "MacOSX.sdk")
warning: ignoring invalid debug info in spirit.stripped.o
DICompileUnit not listed in llvm.dbg.cu
!3714 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !10,
producer: "clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
023b5c1ed8d1577bf0cf298b64a0a047b13fc418)", isOptimized: false, runtimeVersion:
0, emissionKind: FullDebug, enums: !3715, retainedTypes: !3729, globals:
!29030, imports: !29860, splitDebugInlining: false, nameTableKind: None,
sysroot:
"/Applications/Xcode_12.5b2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk",
sdk: "MacOSX.sdk")
llc: error: 'spirit.stripped.o': input module cannot be verified

With the latest Xcode 12.5 beta (or using the swift/release/5.4 branch), the
llc error becomes "error: input module is broken!"

Additionally after performing llvm::StripDebugInfo(), a subsequent call to
llvm::verifyModule() will not report any errors and debug_compile_units() is
empty. However writing the stripped bitcode to a file and then running llvm-dis
on said file, the DICompileUnits are clearly visible in the Debug Metadata.

I've attached a reproducible source file that can compiled with:
clang++ spirit.cpp -c -g -emit-llvm -isysroot "" spirit.o
opt spirit.o -strip-debug -o spirit.stripped.o
lld spirit.stripped.o -o spirit.out
Also I'm sorry the source file is rather large, but it's the only thing I've
found to consistently reproduce the problem.</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>