Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "C++ ABI Specification" referred to in GCC's manual?

I was looking at the GCC manual for C++, and I came across the following quote:

Version 0 refers to the version conforming most closely to the C++ ABI specification. Therefore, the ABI obtained using version 0 will change in different versions of G++ as ABI bugs are fixed. (source)

As can be seen, the above passage references some sort of seemingly standard C++ ABI. As I understand it, however, no such ABI exists. What is this passage talking about? A good answer will give as thorough an explanation as practical. Putting "C++ ABI specification" into my preferred search engine gives nothing useful.

like image 727
john01dav Avatar asked Oct 20 '18 08:10

john01dav


2 Answers

We can see from the WG21 proposal N4028 Defining a Portable C++ ABI what gcc is referring to is the Common Vendor ABI (Itanium C++ ABI):

Existing Practice

Examples of existing practice include:

  • The Common Vendor ABI (Itanium C++ ABI) is a step in this direction, to specify an ABI for the language on some platforms. It is supported today by compilers such as GCC and EDG. It does not specify an ABI for the standard library, so this is necessary but insufficient to, for example, use std::string on a stable API boundary
  • Microsoft VC++ likewise has long had a de facto stable, though undocumented, ABI for the language. It does not have a stable ABI for the standard library, but rather intentionally breaks ABI compatibility on every major release, for example in order to allow continuous improvements to the implementation and to quickly implement a new standard library that contains ABI breaking changes.
  • ...

gcc also covers this in their ABI Policy and Guidelines:

... Furthermore, C++ source that is compiled into object files is transformed by the compiler: it arranges objects with specific alignment and in a particular layout, mangling names according to a well-defined algorithm, has specific arrangements for the support of virtual functions, etc. These details are defined as the compiler Application Binary Interface, or ABI. From GCC version 3 onwards the GNU C++ compiler uses an industry-standard C++ ABI, the Itanium C++ ABI. ...

like image 110
Shafik Yaghmour Avatar answered Sep 27 '22 23:09

Shafik Yaghmour


GCC uses the Itanium ABI by default: http://itanium-cxx-abi.github.io/cxx-abi/

like image 38
Alan Birtles Avatar answered Sep 28 '22 01:09

Alan Birtles