<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62815>62815</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Support JIT-compiled code debugging for Release builds
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          c0d1f1ed
      </td>
    </tr>
</table>

<pre>
    The current support for [debugging JIT-compiled code](https://llvm.org/docs/DebuggingJITedCode.html) depends on GDB or LLDB to be able to observe the `__jit_debug_register_code()` function and `__jit_debug_descriptor` data structure. This only works when LLVM was built using the `Debug` or `RelWithDebInfo` configuration.

It would be great if it could also be made to work with a `Release` build, which would dramatically reduce the binary size. The JIT of a project I'm working on is 45 MB for a `Release` build, but over 1 GB for a `RelWithDebInfo` build.

The above two symbols are both defined in the [`llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp`](https://github.com/llvm/llvm-project/blob/4c7f53b99c08d03668cd455b055c64003393887c/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp) file, so in theory it should suffice to generate debug info for just that file, and ensure it gets preserved during linking and doesn't get stripped afterwards. Alternatively if we had a build flag to optionally not define them in this file but just declare them `extern`, a project which links in LLVM's JIT can define them in one of its own source files and ensure they're available in the debug info.

Does either of these options sound reasonable, or is there a better way to handle this?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklc9u4zYQxp-GvgzWkChLtg4-xOt14CCLFq3RHgOKHElMaVLgn3jdpy-GVjabtD0UvSSGMJz55pvfkCIEPVjELat3rN4vRIqj81tZqLIvUS06p67b04ggk_doI4Q0Tc5H6J0HVu8UdmkYtB3g4Xj6JN150gYVSKeQ1XvGN2OMU2DVHeMHxg_GvJyXzg-MH5STgfHD_jXBw_GE6rNTuBzj2TDegsIJrQrgLNzvd-A8PD7udxAddAii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