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

    <tr>
        <th>Summary</th>
        <td>
            flang-new with libpgmath doesn't work properly on aarch64
        </td>
    </tr>

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

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

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

<pre>
    I built libpgmath in https://github.com/flang-compiler/flang, then build `llvm-flang` with `LIBPGMATH_DIR` and then tried to build the source in https://github.com/llvm/llvm-project/issues/57736#issue-1372973724 and execute the binary, but some error occurs.

```
root@7960fedcbef2:~# cat main.f90 
program foo

    complex :: c
    c = 2.0
    write(*,*) sqrt(c)

end program
root@7960fedcbef2:~# flang-new main.f90 -lpgmath
root@7960fedcbef2:~# ./a.out 
Error during math dispatch processing...
__pgmath_abort:Math dispatch table is either misconfigured or corrupted.root@7960fedcbef2:~# 
root@7960fedcbef2:~# 
```

Furthermore, I set environment variable `MTH_I_STATS=7` and `MTH_I_DEBUG=1` according to https://github.com/flang-compiler/flang/issues/1107, and got the following output.


[a.out.log](https://github.com/llvm/llvm-project/files/9894111/a.out.log)

Is this a bug in `libpgmath` or `llvm-flang`, or just my misconfiguration?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVNtu2zAM_Rr7RYjhS3x78EPatF2AFRjW7jmQZdpWJ1ueJDfN34-Sk6Udhq3bAkORSZM8JA9Zy-ZY7Ug9c2GI4PXUDdT0hI-kN2bSXrLx4lt8Om76uQ6YHPClFXTsVnifuAB1FnjxNTE9jM5ZQ7wsFOJ5WC26LCQHdGGlH3dXn-7uN48f9tvdZ6ugY7MYGsUBr_LkAWVEy1kx-AMeG-f0t5qUfAJm8JVrPYPGS5rnSebFiROsoiSPyxyPtQsML8BmAy5YzUeqjjaPejYYegACSklFJGOz0oEXbr1wczqz8PS4VyWl8dZhXmZhCw2roY0t1vwG4xJGDRkoH4O2DMnyPcLsFB1IK-VrrwR_tq4CXoi1TzaEvdKgbEviILyIDoob8OLCi7Ew1-4sif6msAAFw_tr54DpnuK-A_TS5BEOF-grsdDjHdYB1p0GEsu4fHzj6tjMio8dcRRruJ6oYb2FxEBrVATBqcT7_RJoT2uJqSSb-zcWhtYCOaEJIAtAkYFrJseWd7NC_mAcJpWaJwNN8FuQ78jjl81ezttZ2eiDVGApsyMaDIHxmSs5DjAa8kwVd0jR8B7pvts_PG4eH7CH-Zn2PzTbm6svd6iJnIZhAo2tFM7CP8zhhfpRFOYWnI3VSeNY3koh5MF6x_ZMs3lL6-VMr1zzAiE7L90il_56-lqEZBGURbmOouhMB-fxLS13GmFhMylOXWcn3W6O8yay5cCG_rxMbE4ofpo1TtbxNQGo4XL0klsfqijL8jAL07T0myppyqSkvuFGQHXhtltKl73XSNCjF-eGHKT6aqk5gRJHIkdCqWJ9tvZnJar_2EVFVmR-X7EmXEdpmhctLcuWrvMoLaKkrOskjsoiKXxBaxC6wk5gA3xexWEcR2FcRlkcJ0WQlg2EWVLQFDKa1ikSGHBORWADB1J1vqocBqypRqXg2uiLkuK8dSPA2T-dTS_RgrNjVCS-g1s5rN8B0iflhA">