public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC ABI versions
@ 2018-08-29 10:06 Igor Chudov
  2018-08-29 10:08 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Igor Chudov @ 2018-08-29 10:06 UTC (permalink / raw)
  To: gcc-help

Hello colleagues!

I'm trying to build solib written in C++ on CentOS with different ABI versions and with different compilers (GCC 4.4, GCC 4.8, GCC 5.2, GCC 6.3 and GCC 7.3). On more recent compiler versions (GCC 5.2 and higher) we're using flag -D_GLIBCXX_USE_CXX11_ABI=0 and -D_GLIBCXX_USE_CXX11_ABI=1 .

AFAIK there is a flag -fabi-version which allows to switch between ABI versions too but as far as I understood the documentation, it switches not C++98/C++11 ABI but another kind of things. I'm striving to eliminate the need to build the solib using different versions of compilers and to correctly specify the needed version of ABI.

Could someone possibly help me with determining the ABI versions used by the specified versions of GCC so I will be able to remove the unneeded compilers?

---
With best regards,
Igor Chudov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC ABI versions
  2018-08-29 10:06 GCC ABI versions Igor Chudov
@ 2018-08-29 10:08 ` Jonathan Wakely
  2018-08-29 11:11   ` Igor Chudov
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2018-08-29 10:08 UTC (permalink / raw)
  To: Igor_Chudov; +Cc: gcc-help

On Wed, 29 Aug 2018 at 11:06, Igor Chudov <Igor_Chudov@epam.com> wrote:
>
> Hello colleagues!
>
> I'm trying to build solib written in C++ on CentOS with different ABI versions and with different compilers (GCC 4.4, GCC 4.8, GCC 5.2, GCC 6.3 and GCC 7.3). On more recent compiler versions (GCC 5.2 and higher) we're using flag -D_GLIBCXX_USE_CXX11_ABI=0 and -D_GLIBCXX_USE_CXX11_ABI=1 .
>
> AFAIK there is a flag -fabi-version which allows to switch between ABI versions too but as far as I understood the documentation, it switches not C++98/C++11 ABI but another kind of things.

It's completely unrelated.

> I'm striving to eliminate the need to build the solib using different versions of compilers and to correctly specify the needed version of ABI.
>
> Could someone possibly help me with determining the ABI versions used by the specified versions of GCC so I will be able to remove the unneeded compilers?

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
should be clear.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: GCC ABI versions
  2018-08-29 10:08 ` Jonathan Wakely
@ 2018-08-29 11:11   ` Igor Chudov
  2018-08-29 11:27     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Igor Chudov @ 2018-08-29 11:11 UTC (permalink / raw)
  To: gcc-help

-----Original Message-----
From: Jonathan Wakely <jwakely.gcc@gmail.com> 
Sent: Wednesday, August 29, 2018 2:08 PM
To: Igor Chudov <Igor_Chudov@epam.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: GCC ABI versions

> On Wed, 29 Aug 2018 at 11:06, Igor Chudov <Igor_Chudov@epam.com> wrote:
> >
> > Hello colleagues!
> >
> > I'm trying to build solib written in C++ on CentOS with different ABI versions and with different compilers (GCC 4.4, GCC 4.8, GCC 5.2, GCC 6.3 and GCC 7.3). On more recent compiler versions (GCC 5.2 and higher) we're using flag -D_GLIBCXX_USE_CXX11_ABI=0 and -D_GLIBCXX_USE_CXX11_ABI=1 .
> >
> > AFAIK there is a flag -fabi-version which allows to switch between ABI versions too but as far as I understood the documentation, it switches not C++98/C++11 ABI but another kind of things.
> 
> It's completely unrelated.
> 
> > I'm striving to eliminate the need to build the solib using different versions of compilers and to correctly specify the needed version of ABI.
> >
> > Could someone possibly help me with determining the ABI versions used by the specified versions of GCC so I will be able to remove the unneeded compilers?
> 
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
> should be clear.

Okay. I understood that the flag switches between different implementations of symbols with names in std::__cxx11 namespace.

Could you possibly explain the purpose of -fabi-version option? Honestly, I read the documentation at https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html but still have questions left.  Does it has any meaning to lock C++ ABI version on older versions of ABI using -fabi-version=3 (for example) and use -D_GLIBCXX_USE_CXX11_ABI=0 so the users of the solib will be able to use it (link against it) both under old and recent versions of GCC with both -std c++98 and c++11 ? Does it possible to link application with different libraries which use different -D_GLIBCXX_USE_CXX11_ABI ?

Also is it possible to somehow link solib after -D_GLIBCXX_USE_CXX11_ABI=0 with application being built using -D_GLIBCXX_USE_CXX11_ABI=1?

P. S.: I understand that questions may be totally incorrect but currently I have a mess in my head regarding full understanding of how GCC operates with DSO ABI.

---
With best regards,
Igor Chudov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC ABI versions
  2018-08-29 11:11   ` Igor Chudov
@ 2018-08-29 11:27     ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2018-08-29 11:27 UTC (permalink / raw)
  To: Igor_Chudov; +Cc: gcc-help

On Wed, 29 Aug 2018 at 12:11, Igor Chudov <Igor_Chudov@epam.com> wrote:
>
> -----Original Message-----
> From: Jonathan Wakely <jwakely.gcc@gmail.com>
> Sent: Wednesday, August 29, 2018 2:08 PM
> To: Igor Chudov <Igor_Chudov@epam.com>
> Cc: gcc-help <gcc-help@gcc.gnu.org>
> Subject: Re: GCC ABI versions
>
> > On Wed, 29 Aug 2018 at 11:06, Igor Chudov <Igor_Chudov@epam.com> wrote:
> > >
> > > Hello colleagues!
> > >
> > > I'm trying to build solib written in C++ on CentOS with different ABI versions and with different compilers (GCC 4.4, GCC 4.8, GCC 5.2, GCC 6.3 and GCC 7.3). On more recent compiler versions (GCC 5.2 and higher) we're using flag -D_GLIBCXX_USE_CXX11_ABI=0 and -D_GLIBCXX_USE_CXX11_ABI=1 .
> > >
> > > AFAIK there is a flag -fabi-version which allows to switch between ABI versions too but as far as I understood the documentation, it switches not C++98/C++11 ABI but another kind of things.
> >
> > It's completely unrelated.
> >
> > > I'm striving to eliminate the need to build the solib using different versions of compilers and to correctly specify the needed version of ABI.
> > >
> > > Could someone possibly help me with determining the ABI versions used by the specified versions of GCC so I will be able to remove the unneeded compilers?
> >
> > https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
> > should be clear.
>
> Okay. I understood that the flag switches between different implementations of symbols with names in std::__cxx11 namespace.
>
> Could you possibly explain the purpose of -fabi-version option? Honestly, I read the documentation at https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html but still have questions left.

Because you're looking in the wrong place. -fabi-version is a compiler
option, so it's not going to be documented in the libstdc++ manual.
Try https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html


> Does it has any meaning to lock C++ ABI version on older versions of ABI using -fabi-version=3 (for example) and use -D_GLIBCXX_USE_CXX11_ABI=0 so the users of the solib will be able to use it (link against it) both under old and recent versions of GCC with both -std c++98 and c++11 ?

The "cxx11" ABI is orthogonal to -std=c++98 or -std=c++11. If that
isn't clear then you need to read
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
again.


>Does it possible to link application with different libraries which use different -D_GLIBCXX_USE_CXX11_ABI ?

No, -fabi-version has nothing to do with _GLIBCXX_USE_CXX11_ABI. It's
completely unrelated. I've already said that.

> Also is it possible to somehow link solib after -D_GLIBCXX_USE_CXX11_ABI=0 with application being built using -D_GLIBCXX_USE_CXX11_ABI=1?

Yes, but only if the API of the library never uses any types that are
different in the cxx11 ABI. If the library API is written purely in
terms of extern "C" functions, it doesn't matter if it uses the
gcc4-compatible ABI internally, and the application uses the cxx11
ABI. If the application tries to pass objects like std::string or
std::list to the library, they need to agree on the ABI.


> P. S.: I understand that questions may be totally incorrect but currently I have a mess in my head regarding full understanding of how GCC operates with DSO ABI.

Fundamentally it's just like any other library.

If your application uses:

struct Foo { int i; };

and your library uses:

struct Foo { double d; };

then you're going to have problems, aren't you?

If you only want to build your library once and allow it to be used by
applications built with different versions of GCC then just build your
library with the oldest GCC version you intend to support. That is
necessary anyway, even if you completely ignore the cxx11 ABI. If the
oldest version is GCC 4.4 then build it with that. It will use the
gcc4-compatible ABI (because GCC 4.4 doesn't support anything else
anyway). Then your applications will need to use the gcc4-compatible
ABI if they want to pass strings and lists to the library.

Alternatively, build one version of your shared library with GCC 4.4
and build another with GCC 5 (using the cxx11 ABI, which is the
default). Then depending on which ABI your application uses, link to
the appropriate shared library.

Alternatively, build your shared library separately for each different
toolchain, and don't mix versions at all. When the application is
built with GCC 4.4 use the library built with 4.4, and when the
application is built with GCC 5.2 use the library built with 5.2 etc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-29 11:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29 10:06 GCC ABI versions Igor Chudov
2018-08-29 10:08 ` Jonathan Wakely
2018-08-29 11:11   ` Igor Chudov
2018-08-29 11:27     ` Jonathan Wakely

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).