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

    <tr>
        <th>Summary</th>
        <td>
            [HIP] -fmath-errno causes undefined symbol expf
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    https://godbolt.org/z/nTfccd1Tr

after https://github.com/llvm/llvm-project/commit/5f1d3834a2bc3b77e126a278a0e7f00bce5576fc

currently HIP expf function is implemented as `__builtin_expf`. When `-fmath-errno` is specified, `__builtin_expf` is emitted as a call of external lib function `expf` by clang codegen. Since ROCm device libs does not implement `expf`. This results in undefined symbol.

Before https://github.com/llvm/llvm-project/commit/5f1d3834a2bc3b77e126a278a0e7f00bce5576fc, HIP expf function is implemented by `__ocml_exp_f32`, therefore did not have such issue.

I kind of think it is not good to go back to `__ocml_exp_f32` since it does not handle errno any way. I think probably we should just do not pass `-fmath-errno` to clang -cc1 for amdgpu since we do not support it.

@arsenm @b-sumner 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VMtu5DYQ_Brq0hiBQ71mDjrs2hisT1kkBnI0-GhKXFOkwIdt5esDymPYuzGwt1wkAmR1dVcXisdoJoc4ku4r6W4rntPsw7i9RL5Ykyvh1TbOKa2RNF8IuxB2mbwS3qbah4mwyz-EXdy9llId7wOht4R-ef1ynTDAL1CT5ixq6RfCLtY-vf0Oa_A_UCbCLtIviymHTh9Vc2pazoRsxDDgkfWcDSdOcdCUColdN_RafuSUOQR0yW7w7e474MuqQWcnk_EOTASzrBYXdAkV8Aikpw8PIhubjHsoj0lPa_h7RleuDnrhaT5gCM6TnhZ8XFEabVARdvMpujzCxaQrAQfJrQWvAV8SBsctWCPeWyI9fQOKDaTlbgLpFU7oavjLOInw5x83Cyh8MhILNoLyGMH59D7MhzI13M8mQsCYbYpgHGSnUBuHCuK2CG_rj3J9Re0D_h87Yje_34jYXjX1crFF0AfdMNLTgk0zhtdelVH79DN_QohZzmBizPjTWHfwaJwqsqfZuEcwqVAV1OS9guRh8iC4fCzHzygh7tqb9K72zJ2yCLsbgLsNnvlWw92VYQ1ecGE3eEaIs89WwY8cC3wHrzzGzyyV_HXpBymPoH0AvqhpzVf-Z3wrEPO6-pDApJ8GJS3lIaJbgLRUHGJeHAao1Nioc3PmFY7HgbXNqe2GrppHhSd2bs6iHag690dUp47rjratbHirUVRmZJS19MQa2rSs62rRNnikuj-fRD8gU6SluHBj62KIEgDVrv54pN0w9JXlAm3co4Qxh8-vuyGMlWQJ4-4ikadIWmpNTPG9TDLJ7hn07e476W7ho1IgeY4Y_2Pl3U1VDvbXfPq9gfe-ImGXa-NPI_s3AAD__313pZs">