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

    <tr>
        <th>Summary</th>
        <td>
            __cxa_init_primary_exception return type differs from libsupc++
        </td>
    </tr>

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

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

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

<pre>
    As of LLVM 18, there is a build error due to a conflict in the signature of `__cxa_init_primary_exception` in libc++abi and in gcc's libsupc++ library. The error is on a function introduced in https://github.com/llvm/llvm-project/pull/65534.

This is the compiler error I get on Ubuntu 24 after installing `all` the LLVM packages from `https://apt.llvm.org/llvm.sh`

```
/usr/lib/llvm-18/include/cxxabi.h:51:1: error: functions that differ only in their return type cannot be overloaded
 50 | extern _LIBCXXABI_FUNC_VIS __cxa_exception*
      | ~~~~~~~~~~~~~~~~
   51 | __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
 | ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/cxxabi_init_exception.h:70:7: note: previous declaration is here
   69 | __cxa_refcounted_exception*
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   70 |       __cxa_init_primary_exception(void *__object, std::type_info *__tinfo,
      |       ^
1 error generated.
```

Somehow I seem to be almost the first person to run into this on the internet, but one other case of the error was discussed here: https://github.com/iovisor/bcc/issues/5092

The return type in GCC is `__cxxabiv1::__cxa_refcounted_exception*`: https://github.com/gcc-mirror/gcc/blob/0b06abe027a78681d29a5e91daa74bf8dba39826/libstdc%2B%2B-v3/libsupc%2B%2B/cxxabi_init_exception.h#L71-L74

The return type in libc++abi is `__cxxabiv1:: __cxa_exception*`: https://github.com/llvm/llvm-project/pull/65534/files#diff-58be87d6aa8658f15e1c1f3fa40acb71d078896d857cf98033b32f9fa294c320R36

When both headers end up being included, which can happen [through googletest](https://github.com/google/googletest/blob/7d76a231b0e29caf86e68d1df858308cd53b2a66/googletest/include/gtest/internal/gtest-type-util.h#L46-L49), they conflict and produce the error above.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVtuO4yoW_RryspUI4_tDHpL0ZFRSzYzUt-m3iMt2TDcBC3Cq6uV8-xF2krqc7upzrKrYhg1e7LX2Ah6CPlrENSm3pPyw4GPsnV8rbvmP7wvh1NN6E8B1cH__9T-QNYTtIPboEXQADmLURgF67zyoESE64CCd7YyWEbRNsZC-wOPoMc1DKno4yEd-0FbHw-D1ifunAz5KHKJ2llQ0DTNaSMK2hG250MCtSo1HKQmrQ-oM43DpT2-e-6cVfO7xgkQHcBY4dKOVaVLQNnqnRonTPH2MQyD5hrA9Yfujjv0oVtKdCNsbc77eloN331FGwvbDaAxh-6os82JF6IbQzedeh_SdtD7pToM26C9fv4MjxgTgixhtHIEVwLuIHrQNkRuj7TFlgRuTFpsmmHI7cPmDHzFA590pBbyGyYe4SrBWzh8vCFehJxWd8aSH-Y-mAWPwKUiL62ISc3ttpRkVEraXj49c6FVP8k2ZkXyT_mf46eGat7Q8HkHprkMPzpqnC6Xag8c4egvxaUCQ3FoXQSC4M3rjuEJF6AZKCqTeAT5G9BYO93fb3bdvm-3dYf_lv7vD17tPMEvhmX2W1gLTlUb-8eaaO8ts6nxXRqw5O60I24ATM4s7CFGldOabBPqgbedSf5wfdjAPaF7A_PD5fx8nrClOYYiEtc8zTy8txN67B8Ka9JpvE8IEjpT_esmE0Jaw_Wp1I2XS8v6xqQ5VsTTajo_Lox0J22fFNfDNzwvyZuVfg4WO4UbpnI9bHiaGa5p-ErHWRUz3weNZuzGAQmm453ORBEiFPee4al_k2GMn3Wgjql9TNV9vCfsLdzV9Ef03GATCNofDexzOEVcWf4JppiK7VOcRLXoeUa3eVg3dfHIn7N0D3EFAPCUzEwjcnFyIU5122ocIA_rgbOr142QtDm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