Description
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 #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: iovisor/bcc#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, they conflict and produce the error above.