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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][ExecutionEngine] Static destructors from shared libries not run
        </td>
    </tr>

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

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

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

<pre>
    When you load a shared library into `mlir-cpu-runner` (in this case, the library is the HIP runtime, which is linked in by the MLIR ROCm runtime wrappers), that library's functions that have `attribute(destructor)` on them are not run at any point.

In the specific case that led to me finding this issue, this causes a thread leak (and maybe unknown other resource leaks)

LLVM's JIT seems to have some mechanism for gathering and running such destructors, but I can't work out how to plumb it in to MLIR's usage of the JIT.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxMU01v2zgU_DXU5SEGRVmWddChbWqsixS76Ba75yfqWeRaIgXyMV731xdkEiQXfYDD4cy8IcZoZ0c0iPazaB8rTGx8GK7h1z3-krIa_XQf_jXk4O4TLB4nQIgGA02w2DFguIN17EEc5LrY8KC39BCScxTEQYJQR-uAjY2gMZJQX4ANve-M5feP818QkmO7FsTNWG3y2mLdlSawDsZ7AX5_Ov-AH39-Wd_gcAu4bRSiUP0LOfIbu1BdhEtymq138WXJ4DNlqcgc7JiYhDpOFDkkzT5kkoMEnxXTChgInOd8FiADujts3jreCfko5KeX57mAIW6k7cXqYvNVBk3AHlaCi3WTdfNLDjbG9BpESSVFioDAJhBOsBBec2roJljxPhIkd3X-5sCzoQCBok9BUwEW1x-0PD398724_nb-CZFojVlA8Rz9SrCSNuhsXOHiA8yYGbOufFieWf6OSRt4jyRmpWNiOINGJ1THcPPhCj4xGH_L_NuS1hEs5zmxLzMqIlLEmcBfSj7fzj931TQ0U9_0WNFQd6o-NkfZN5UZ6NjoHg_NRHWHTadU0-lWUq32PWLX9JUdlFR72al9fVB1o3bHFlHWh0aOR9lS3Yu9pBXtsluW53Xnw1yVmIdayn29rxYcaYml40rlmgqlctvDkPEPY5qj2MvFRo7vDGx5KfeibGgfRfv56_-kU67TVzdbR6J9hL8Z2eqPicEl-PXjHbEU33pUpbAMhnmLovkk1Emo02zZpHGn_SrUKR_--nrYgv-PNAt1Kl6iUKdXO8-D-h0AAP__GZI9IQ">