Fredrik Ullner
Fredrik Ullner

Reputation: 2156

GCC ABI compatibility

As far as I've understood, it is not possible to link libraries that use different versions of GCC's Application Binary Interface (ABI). Are there ABI changes to every version of GCC? Is it possible to link a library built with 4.3.1 if I use, say, GCC 4.3.2? Is there a matrix of some sort that lists all the ways I can combine GCC versions?

Upvotes: 32

Views: 42531

Answers (3)

ablaeul
ablaeul

Reputation: 2798

The official ABI page points to an ABIcheck. This tool may do, what you want.

Upvotes: 16

user3603401
user3603401

Reputation: 69

Ugh, yikes.
How can you tell which gcc compiled a given binary? Here is the death notice from gcc-4.7.2-1-mingw32.README.txt :

Binary incompatibility notice!

The C and C++ ABI changed in GCC 4.7.0, which means in general you can't link together binaries compiled with this version of the compiler and with versions before GCC 4.7.0. In particular:

  • The option -mms-bitfields is enabled by default, which means the bitfield layout follows the convention of the Microsoft compiler.

  • C++ class-member functions now follow the __thiscall calling convention.

  • The compiler now assumes that the caller pops the stack for the implicit arguments pointing to an aggregate return value. This affects functions returning structs by value, like the complex math type.

Upvotes: 4

AProgrammer
AProgrammer

Reputation: 52284

Since gcc-3.4.0, the ABI is forward compatible. I.E. a library made using an older release can be linked with a newer one and it should work (the reverse doesn't). Obviously, there could be bugs, but there is only one mentionned in the documentation: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33678

Upvotes: 22

Related Questions