5 ms·
Does the C++ standard guarantee binary ABI? Isn't that something that compiler and library contributors handle separately? So I think the arguments you see onli
by jdw64 2mo ago
Does the C++ standard guarantee binary ABI? Isn't that something that compiler and library contributors handle separately? So I think the arguments you see online are more accurate—vendors are the ones maintaining it.
In other words, the ABI we rely on today isn't really part of the C+ standard—it's more like the Itnaium C++ ABI or the MSVC C++ ABI.
In the end, I think the ABI stays stable because of community conventions established by compiler vendors.
- andyg_blog 2mo agoIt doesn't, and FWIW the article says that. A meta note: ABI stability is a holy war inside the C++ community. Those against it argue that it's holding back real language evolution. Herb Sutter is even working on his own C++ offshoot that shows what could be.
- Mond_ 2mo agoAfaik Herb Sutter largely stopped working on Cppfront a few months ago, and was never quite supposed to be a real thing, just a personal playground (or so Sutter claims at this point, anyway). Afaik Carbon is at this point the only attempt at a successor language that's still going?
- pjmlp 2mo agoProbably, but note that Google says they are they main customer anyway, and it is an experiment above anything else. Anyone that can reach out to Rust, Go, Java, C#, whatever, should do that preferably. There are also some efforts to tame existing C++ with profiles, and replacing UB with erroneous behaviour, and that's about it.
- jcranmer 2mo agoNo, ABI is not part of the C++ standard, although there are parts of C++ that do go "this is an ABI thing" (e.g., [[no_unique_address]]). ABI is more of OS-level thing. Most systems these days follow the SysV ABI, which is largely defined by the hardware manufacturers via the processor-specific supplements (the x86-64 one is here: https://gitlab.com/x86-psABIs/x86-64-ABI https://gitlab.com/x86-psABIs/x86-64-ABI). These largely delegate C++-specific conventions to the Itanium C++ ABI (which they likely directly reference), although the ARM ecosystem uses a somewhat different layout for the exception handling tables. Microsoft uses a different ABI for both the underlying C ABI and for the C++ compatibility layer built on top of the C ABI. One of the issues that crops up is that vendors end up needing to add extensions to the ABI for various reasons, and these extensions tend to end up being incompatible, since they're added before they've had a time to be standardized. 16-bit floats is a particular historical bugbear, as is the C23 _BitInt stuff.
- jdw64 2mo agoThank you for the kind comment. I'll make a note of it and look into it.
- rramadass 2mo agoOne more addition. There is often a distinction made between "language ABI" and "library ABI" in documentation which is highly confusing. The answer is: library API + compiler ABI = library ABI GNU libstdc++ ABI Policy and Guidelines - https://gcc.gnu.org/onlinedocs/gcc-9.2.0/libstdc++/manual/manual/abi.html https://gcc.gnu.org/onlinedocs/gcc-9.2.0/libstdc++/manual/ma...
- pjmlp 2mo agoNo, neither does the C standard. With exception of Swift, D, and bytecode based languages, the ABI is left to the vendors. For those that think ISO/IEC 9899:2024 PDF has anything related to ABI, the actual ABI used by C compilers, is the OS ABI, if the OS was written in C to start with, and naturally this overlaps quite nicely with UNIX like OSes, and Windows. It isn't like that on other platforms that decided to either use other systems languages, or expose their OS APIs in a different way, e.g. mainframes, micros, Android, ChromeOS, WebOS,...
- mohamedkoubaa 2mo agoIsn't this one reason why C is the de facto FFI? OSes happen to use it in their OS ABI and so everything is forced to speak it
- pjmlp 2mo agoOS written the C, which is what many overlook. If you are on e.g. z/OS you would be using ILE, Integrated Language Environment, on ChromeOS JS/WASM, on Android either DEX or JNI,...
- aboardRat4 2mo agoAndroid is Linux and it's written in C. Bionic is still a posix libc.
- pjmlp 2mo agoAndroid uses the Linux kernel as implementation detail, it could be changed with Zircon if Google cared, bionic is partially POSIX, only the required for ISO C, ISO C++, ART and NDK native APIs is exposed. 80% of Android APIs are exposed via Java, and even native ones have to use JNI.
- p_l 2mo agoAdditionally a lot of the APIs if you go underneath, including native code components, are exposed through few variants of Binder (BeOS-derived IPC for the uninitiated) including userspace drivers. Binder APIs very much do not follow C ABI other than the part where you deal with wrapper around ioctl()
- bluGill 2mo agoThe C++ standard doesn't say anything about binary ABI (as you say generally either Itanium or MSVC, though there are other options they are rare). However the people who write that standard are very sensitive to the vendors and users of C++ who depend on a stable binary ABI. Thus they take extreme care to ensure that no change to the standard breaks binary ABI. The C++ standard did force gcc to break the ABI of std::string (copy on write was banned - for good reason). They then watched the gcc community work through 10 years of pain to make the transition. They are also well aware that python 3 broke compatibility with Python 2 - and again it resulted in 10 years of pain for the python community to deal with that. With this history there are a lot of experts strongly against any breaking change. It might happen anyway, but only with strong justification and likely an attempt at a migration of some form (what? there are a lot of examples of migration plans that don't work that they are aware of) Again, it is not because of convention, it is because of painful experience from those who break it.
- MFHava 2mo ago> They then watched the gcc community work through 10 years of pain to make the transition. During the same time the MSVC compiler broke ABI multiple times and the world didn't end. The fact that breaking ABI was such a shitshow for libstc++ is more related to the way C++/ABI/SOs is/are handled in Linux...
- plorkyeran 2mo agoIn the time since that VC++ has switched to a frozen ABI model that’s much closer to what Linux distros have. Each version of VC++ being ABI-incompatible and requiring each application to be built with a single version and ship its c++ runtime had some significant pros and cons. Microsoft never said it outright, but I’ve always assumed the major con that made them switch was that people didn’t buy new Visual Studio versions because upgrading VS required also upgrading all of your binary blob closed-source dependencies.
- Maxatar 2mo agoThe reason the world didn't end is because people refused to upgrade Visual Studio, in particular Microsoft's bigger customers. Microsoft surveyed their users for why people weren't making the switch to VS 2013 despite all the "nice" and "new" features introduced and the predominant reason was due to all the ABI breakages. For VS 2015 they adopted a policy of having a stable ABI and have preserved ABI compatibility for over 10 years now [1]. [1] https://devblogs.microsoft.com/cppblog/binary-compatibility-and-pain-free-upgrade-why-moving-to-visual-studio-2017-is-almost-too-easy/ https://devblogs.microsoft.com/cppblog/binary-compatibility-...
- z_open 2mo agoWhen the C++ standards committee make decisions crippling the language to preserve ABI (see std::regex), it's defacto part of the standard.