This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Sub lib compatibility with g++


Hi Kumar,

> I understand that gcc C++ and Sun Studio C++ are not ABI compatible, but was wondering if there is anything at all I can do to get around this problem, short of requesting for a gcc compiled 3rd party lib and/or I having to change my compiler to Sun Studio.

Yes, there is a solution.  Since the C ABI is the same on both compilers, you can write a thunking library using the Sun C++ compiler that has C harness routines that call the Sun C++ compiled library methods.

And on the GCC side, you can either use those C routines directly, which, effectively, treats that C++ library as if it were a C library (via the thunking library).

Or in addition, you could also write a thunking C++ proxy wrapper on the GCC side, that behaves as-if it were the objects in the Sun space.

Some of the issues that the thunking library has to handle is catching ALL exceptions, translating (flattening) those exceptions into something that can be presented over the C barrier (the Sun-side thunking library).  Flattening all vectors, strings, and other Standard C++ Library (STL) objects that are used by the Sun C++ libraries interface (if any).  Flattening all non-POD parameters, and and all returned results.

It's a lot of work.  I've done it before several times, even once again in the past couple months.  I don't recommend it, if you can avoid it.

> I have access to the sun compiler and sun C++ runtime.

If you didn't, the challenge would be insurmountable!

> For instance - Is it possible to set some options to gcc to indicate - make use of the Sun name mangling style ?

No, GCC doesn't have that option.

But it's not just that "mangling is different" (although that is a big factor too).  The Standard C++ Library (std::vector, std::string, et cetera) is different too.  Iterators are different.  Exception handling mechanics are different.  Stack unwinding is different.  Parameter passing is different.  Result propagation is different.  Inlining is different.  Free store (C++ heap) management is different.  Streams (fstream, iostream, stringstream) are different.  Non-C POD like bool and wchar_t may be different.

All those things are part-and-parcel of the C++ ABI, which is different in Sun and GCC.

HTH,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]