While it seems that GCC and Clang get along fairly well even when linking against C++ code build with the opposing compiler they don't seem to agree on RTTI (which is mostly used to implement
The only way to fix this seems to tell GCC to use Clangs C++ library and headers by using the following flags:
If your application uses intrinsics you need to add the appropriate GCC header files to the search path though as GCC will bark when trying to use Clangs intrinsic headers:
Obviously you need to adjust that path to include the appropriate versions and architecture.
Hope that saves someone a bit of time debugging.
dynamic_cast
i think). So when the application compiled with g++
calls into a system library (likely build by Clang) that tries to do a dynamic cast it will crash at a position kind of like this:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x0000000802efba18 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1
The only way to fix this seems to tell GCC to use Clangs C++ library and headers by using the following flags:
Code:
CXXFLAGS+=-nostdinc -nostdinc++ -I/usr/include/c++/v1 -I/usr/include -I/usr/local/include
Code:
LDFLAGS+=-nodefaultlibs -lc++ -lcxxrt -lthr -lm -lc -lgcc_s
If your application uses intrinsics you need to add the appropriate GCC header files to the search path though as GCC will bark when trying to use Clangs intrinsic headers:
Code:
CXXFLAG+S=-I/usr/local/lib/gcc9/gcc/x86_64-portbld-freebsd12.1/9.3.0/include
Obviously you need to adjust that path to include the appropriate versions and architecture.
Hope that saves someone a bit of time debugging.