public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "John (Eljay) Love-Jensen" <eljay@adobe.com>
To: "Kumar Bhaskar" <akumargolf2000@yahoo.com>, <gcc-help@gcc.gnu.org>
Subject: RE: Sub lib compatibility with g++
Date: Sun, 16 Dec 2007 14:18:00 -0000	[thread overview]
Message-ID: <EDC8DDD212FEB34C884CBB0EE8EC2D9103B25E7B@namailgen.corp.adobe.com> (raw)
In-Reply-To: <131146.25616.qm@web46015.mail.sp1.yahoo.com>

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

  reply	other threads:[~2007-12-16 14:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-16  8:20 Kumar Bhaskar
2007-12-16 14:18 ` John (Eljay) Love-Jensen [this message]
2007-12-16 23:52 Kumar Bhaskar
2007-12-17  0:24 ` John (Eljay) Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EDC8DDD212FEB34C884CBB0EE8EC2D9103B25E7B@namailgen.corp.adobe.com \
    --to=eljay@adobe.com \
    --cc=akumargolf2000@yahoo.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).