Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ ABI issues list

Tags:

c++

I've seen a lot of discussion about how C++ doesn't have a Standard ABI quite in the same way that C does. I'm curious as to what, exactly, the issues are. So far, I've come up with

  1. Name mangling
  2. Exception handling
  3. RTTI

Are there any other ABI issues pertaining to C++?

like image 997
Puppy Avatar asked Sep 20 '11 21:09

Puppy


People also ask

Does C have a stable ABI?

C does not have a standard ABI.

What is ABI breaking?

For the standard library the primary issues causing potential ABI breakage are those which change the layout of a class or a class template or the changing the behavior of typically inlined functions.

What does ABI mean in C++?

As C++ evolved over the years, the Application Binary Interface (ABI) used by a compiler often needed changes to support new or evolving language features. Consequently, programmers were expected to recompile all their binaries with every new compiler release.

What is compiler ABI info?

An ABI can define a standard way of encoding the name of a function so that programs built with a different language or compiler can locate what they need. When you use extern "c" in a C++ program, you're instructing the compiler to use a standardized way of recording names that's understandable by other software.


2 Answers

Off the top of my head:

C++ Specific:

  • Where the 'this' parameter can be found.
  • How virtual functions are called
    • ie does it use a vtable or other
    • What is the layout of the structures used for implementing this.
  • How are multiple definitions handled
    • Multiple template instantiations
    • Inline functions that were not inlined.
  • Static Storage Duration Objects
    • How to handle creation (in the global scope)
    • How to handle creation of function local (how do you add it to the destructor list)
    • How to handle destruction (destroy in reverse order of creation)
  • You mention exceptions. But also how exceptions are handled outside main()
    • ie before or after main()

Generic.

  • Parameter passing locations
  • Return value location
  • Member alignment
  • Padding
  • Register usage (which registers are preserved which are scratch)
  • size of primitive types (such as int)
  • format of primitive types (Floating point format)
like image 115
Martin York Avatar answered Oct 16 '22 00:10

Martin York


The big problem, in my experience, is the C++ standard library. Even if you had an ABI that dictates how a class should be laid out, different compilers provide different implementations of standard objects like std::string and std::vector.

I'm not saying that it would not be possible to standardize the internal layout of C++ library objects, only that it has not been done before.

like image 20
Lindydancer Avatar answered Oct 16 '22 01:10

Lindydancer