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: C++ binary compatibility between different versions of gcc


Hi Jonathan,

thanks for the definitive answers.

> On 4 March 2013 19:01, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> > On 4 March 2013 16:48,  <Heiko.Papenfuss@uniserv.com> wrote:
> 
> > 2.) [1] states that starting with GCC 3.2, there is a default C++ ABI (the
> > vendor-neutral C++ ABI) that GCC tries to adhere to. However, there is not
> > a hint of which versions did or did not, or with which versions of GCC an
> > incompatible change of the ABI has happened.
> 
> The manual for each version tells you the default value for -fabi-version

I noticed that but being confused with the library ABI issue and by some
posts on the internet that seemed to indicate otherwise, I did not 
trust it as much as I should have. 

> > [3] indicates then that "It's pretty easy to see when the ABI has changed
> > because we bump the major release number in the soname." of libstdc++.so
> > and as one can figure out looking at [2], this has not happened since
> > libstdc++.so.6.0.0, which came with GCC 3.4.0. From that, I am willing to
> > draw the conclusion that the compiler ABI has been stable since then. Is
> > this correct and is it therefore save to say that a library compiled with
> > GCC 3.4.x can be linked against (dynamically or statically) with GCC
> > 4.y.z, if we assume that all ABI-affecting compiler flags have been the
> > same (esp. -fabi-version=2)?
> 
> Yes.  (Technically if the object files were compiled with
> ABI-compatible GCC versions then what matters at link-time is not
> which version of GCC you use to do the link, it's which version of
> libstdc++.so you link against, but that is usually determined by the
> version of GCC used, unless you specifically force GCC to link to a
> different libstdc++.so)

Does this mean that it would be possible to link with any GCC that
supports -fabi-version=2 against any libstdc++.so.6.x.y?

> 
> > Does the reverse hold, too?
> 
> What is the reverse case?  If you are asking whether a library
> compiled with GCC 4.x can be linked against using GCC 3.4 the answer
> is no, libstdc++.so ABI compatibility only goes backwards, not
> forwards.
> 
> If any object in your program (or any object in any library it links
> to) was compiled with GCC version X then at run-time the program must
> be linked to the libstdc++.so from GCC X or later.  You cannot compile
> with GCC X then use libstdc++.so from GCC X-1 at run-time.
> 

That was the question, yeah.

Another question comes to my mind here: Let's assume I have two object files
or libraries that have been compiled separately and were compiled with
different versions of GCC thus needing different versions of libstdc++.so
at run-time. Do I read [2], "Multiple ABI Testing", correctly that I should
be able to compile and run a program which uses both libraries provided that
the most current libstdc++.so that any library depends on is present at
run-time?

Heiko


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