Was the clang <> GCC 5 ABI incompatibility overcome at some point?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Was the clang <> GCC 5 ABI incompatibility overcome at some point?

Ces VLC
Hi!

I remember a few years ago when a change in GCC 5 caused ABI incompatibility with clang. I'm searching for updates on this, and it seems like clang applied the same change eventually, but can they considered binary compatible at this moment? Is it now safe to link object code coming from GCC and from clang?

Thanks!

César

Reply | Threaded
Open this post in threaded view
|

Re: Was the clang <> GCC 5 ABI incompatibility overcome at some point?

Ken Cunningham
> Hi!
>
> I remember a few years ago when a change in GCC 5 caused ABI
> incompatibility with clang. I'm searching for updates on this, and it seems
> like clang applied the same change eventually, but can they considered
> binary compatible at this moment? Is it now safe to link object code coming
> from GCC and from clang?
>
> Thanks!
>
> César

The issue is not so much with the compiler as with the c++ standard library.

Any compiler can use any c++ standard library.

But *by default* (1) clang will use libc++ and gcc will use libstdc++, and these are not compatible with each other.

So if you are going to mix objects (and libraries) coming out of clang and gcc, you have to be sure that they all use the same c++ standard library.

With c++ code, that is quite tricky to do properly.

If you use gcc just to build "c" code, or fortran code, there is no problem mixing those libraries or objects with clang c++ code.

Ken




1. By default, on current MacOS and on all MacOS on MacPorts. Further needless and sometimes confusing detail omitted for clarity of focus, ask if truly curious. -K
Reply | Threaded
Open this post in threaded view
|

Re: Was the clang <> GCC 5 ABI incompatibility overcome at some point?

Ces VLC
Thanks a lot, Ken. Yes, I understand that, but I believe there was some ABI incompatibility introduced with GCC 5, wasn't it? If I recall correctly, it wasn't just a matter of what C++ standard library you choose, but that even if you chose the same, GCC 5 still broke the ABI compatibility. At the time the rumors said that the reason was an attempt to break compatibility with LLVM because GCC saw it like a competitor, but that was just a rumor.

Kind regards and thanks a lot,

César


On Tue, May 19, 2020 at 5:08 PM Kenneth F. Cunningham <[hidden email]> wrote:
> Hi!
>
> I remember a few years ago when a change in GCC 5 caused ABI
> incompatibility with clang. I'm searching for updates on this, and it seems
> like clang applied the same change eventually, but can they considered
> binary compatible at this moment? Is it now safe to link object code coming
> from GCC and from clang?
>
> Thanks!
>
> César

The issue is not so much with the compiler as with the c++ standard library.

Any compiler can use any c++ standard library.

But *by default* (1) clang will use libc++ and gcc will use libstdc++, and these are not compatible with each other.

So if you are going to mix objects (and libraries) coming out of clang and gcc, you have to be sure that they all use the same c++ standard library.

With c++ code, that is quite tricky to do properly.

If you use gcc just to build "c" code, or fortran code, there is no problem mixing those libraries or objects with clang c++ code.

Ken




1. By default, on current MacOS and on all MacOS on MacPorts. Further needless and sometimes confusing detail omitted for clarity of focus, ask if truly curious. -K