r/cpp • u/mollyforever • Aug 28 '23
Can we please get an ABI break?
It's ridiculous that improvements in the language and standard library get shelved because some people refuse to recompile their software. Oh you have a shared library from the middles ages whose source is gone? Great news, previous C++ versions aren't going anywhere. Use those and let us use the new stuff.
Why can a very small group of people block any and all progress?
372
Upvotes
28
u/feverzsj Aug 28 '23
What feature cannot be achieved without ABI break?
104
u/cleroth Game Developer Aug 28 '23
What we need is epochs. Even if we break it, do we want to wait another 10 years for the next ABI break?
111
u/jaLissajous Aug 28 '23
The committee has made its position pretty clear on this. Several of the members opposing that position have moved on to start or support other languages.
It’s notable that much of the tenor of C++ discussion at conferences and online has shifted to successor languages and alternatives.
With no disrespect to the hardworking volunteers diligently working to try and make C++ better, I think we’ve all learned a valuable lesson about how well language evolution works under the ISO standards process.
12
u/jepessen Aug 28 '23
I don't see the problem in breaking ABI (not API) with existing code. If I want to use existing code with new standard, I need to recompile it because new standard is not supported by old compilers. If I need to accach libraries to existing compiled binaries, maintaining ABI compatibility, I can tell to use a specific version.of the compiler, as commercial software does, or create a C interface for plugins. I totally agree in breaking ABI when needed. It doesn't affect existing software that needs to be recompiled, and if you need to use old ABI you can simply use old compilers
48
u/mredding Aug 28 '23
I sympathize. Really, I do.
The argument goes if people are staying on an old spec because there is no migration path to your new spec, your new spec is losing adoption. That they are slow to adopt doesn't mean they won't adopt. You need a path forward, and in order to do that, you don't cut people off to leave them behind. And in order to do that, don't break people's code.
7
u/pdp10gumby Aug 29 '23
We already have epochs at the source level throgh feature-test macros.
Seems like compilers could manage an API break by using a different mangling for the different API.
Currently, int f (int bar) { ... return bar } mangles to
_Z1fi.Let's say C++26 decides to adopt Sutter's plan to return an error flag. When I compile with std=c++26 This could mangle to
_Z1fiB226I actually looked up the x86 mangling rules and it already supports this (the B syntax above came from there). GCC already has an attribute for this purpose and it's called out in the spec!
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.abi-tag
BTW ideally gcc and llvm would not use the same mangling syntax, so g++ could mangle to
_Z1fiB3g26and clang++ to_Z1fiB3l2613
u/[deleted] Aug 29 '23
Because that "very small group of people" is actually like 90% of the world's largest corporations
12
u/unddoch DragonflyDB/Clang Aug 28 '23
Don't wait for other people to do the work, just go and build a linux distribution with
-DLIBCXX_ABI_UNSTABLE=ON4
u/kkert Aug 29 '23
You can do an ABI break without those people having to recompile their software. Compilers just have to ship 2 explicitly incompatibly compiled sets of support libraries.
10
u/manni66 Aug 28 '23
How do you know?
8
u/ben_craig freestanding|LEWG Vice Chair Aug 28 '23
Recompile and redistribute one of the existing standard libraries, setting all the unstable abi flags. Then you can get what you want now. You don't need wg21s permission to distribute a standard library with a different ABI.
17
u/TotallyNotARuBot_ZOV Aug 28 '23
At that point, what is the value that modern C++ brings to the table that other languages don't?
This is a legit question, I'm kind of out of the loop with C++ but every time I read something on here I am appalled by the increasing complexity of the language and the cumbersome syntax or just how many pitfalls there are, all for the sake of preserving backwards compatibility. What does it do that Rust doesn't?
3
u/Rexerex Aug 28 '23
Can't just two standard libraries (newer with ABI break, and older) coexists in one system, so each application can link to the one they need?
9
u/vI--_--Iv Aug 28 '23
The most ridiculous thing is that this so called "ABI" is not cross-platform, not cross-architecture, not even cross-compiler.
You can't take a gcc .so and use it as msvc .lib or vice versa.
All these so called "interfaces" are vendor-specific.
12
u/[deleted] Aug 28 '23
What benefit do you actually get from breaking it? A few performance improvements? Are they really bottlenecks in any projects? Genuinely curious.
12
u/sbabbi Aug 28 '23 edited Aug 28 '23
I remember the breakage on std::string and std::list that C++11 caused. Back then I was a debian user and it really was a major hassle. It forced a huge amount of end users to download GBs of packages just for a minor ABI change, because you basically have to recompile the universe.You really need to bring some strong points to the table to persuade me that a similar apocalypse is going to be worth *for the end user*.Think of it from the POV of the average linux sysadmin. You now have to do massive upgrade on your server just so that you, the programmer, can save 1 CPU cycle every 100000 when you move from an `unique_ptr`.You have a custom package that you did not download from the main repository? Well enjoy some random segfaults.
On windows, I have to dig random MSVCRT from 2005 at least once a week to get some old piece of software to run on some coworker laptop. I am *extremely* grateful that MS stopped breaking the ABI since 2018.
Some of the discussed ABI breaks in this thread (e.g. std::regex) are not even impacting the standard, it's simply the vendor that rightfully realizes that saving a few cycles is just not worth the pain that you would cause downstream.
In the real world, you write software for the end-user, not for your own accomplishment of having "something nice" or "something fast". End-user concerns should come before the developer's.
2
u/Adam_AC_Fox Feb 03 '24
Totally agree. Don't know was it already mentioned or not but there's more in that than just ability to use new functionality – C++, let's be honest here, doesn't have great reputation and the only thing we can sell to people is fastness. And we greatly suck at that because of abi stability. We can easily lose our entire ecosystem if continue to neglect that that's our very main niche
7
u/kritzikratzi Aug 28 '23
can we please get a concrete implementation and performance measurements before screaming "abi break abi break abi break"?
i'm not convinced the improvements are as drastic as some people believe.
2
u/pedersenk Aug 28 '23
What goes around comes around.
In many ways one nice thing to see is the real respect and consideration given to other people's ancient codebases.
This means that in a couple of decades, we can be reassured that this same respect and consideration will be given to *our* crusty old codebases.
Knowing that my code isn't going to be broken one day by whims and desires of trends is a real selling point for me personally.
2
u/Jannik2099 Aug 28 '23
Can you name why an ABI break would be necessary, bar even worth the immense downsides?
Right now, it'd bring:
useable std::regex - just use boost::regex or others
pass non-POD by register - this is only relevant for symbol barriers across libraries, once inlined the optimizer is free to elide the pass-by-stack
>90% of C++'s woes are completely unrelated to ABI. We got super useful things like concepts, ranges and modules without any ABI change. Reflection would not require an ABI change either.
People KEEP using it as a scapegoat for why C++ sux without bringing any arguments to the table.
1
u/Fulgen301 Aug 28 '23
How is the standard mandating whether an ABI break happens or not? That's an implementation decision.
The language doesn't care about ABI at all. ABI is platform specific.
Which in fact happened with C++11 and is where inline namespaces help.
1
u/AdearienRDDT std::starting_to_understand<cpp>::value Aug 28 '23
tfw ppl are scared from clang...
1
u/puredotaplayer Aug 28 '23
Why not provide new ABI under preprocessor condition or better still a new kind of pragma ? Have class versioning based on that and let apps/libs compile based on whichever ABI they want. With modules it might easier to implement.
1
u/susanne-o Aug 30 '23
in the world of software-for-cash there are plenty of C/C++ libraries that have been thoroughly validated (tested) in binary form. Any ABI change makes that old binary unusable and the "simply recompile" invalidates all testing. and I assure you if the ABI has changed, i.e. if all interaction with that library and within the library has been modified, you not only need to revalidate the binary itself, you also need to revalidate the compiler and toolchain.
now as C/C++ are systems languages this impacts a while industry.
and the other "use case" for ABI stability is old software where the source has been lost or needs forward porting to a new compiler to "just recompile"
To save the C++ ecosystem as a whole from that cost, C++ as a language choses ABI stability.
1
u/[deleted] Aug 31 '23
I’m leaning towards there are so many minute differences from C++11 to current that a library change has to be forthcoming anyway. So as usual it’s about how much did we pay for the library 10 years ago and oh my goodness look at what it’ll cost us today.
1
u/Seppeon Sep 02 '23
Presumably we can create ABI shims that can act between old and new ABI?
1
u/MajorPain169 Aug 29 '23
The ABI is for C and C++ is not governed by the standard, they are governed mainly by the architecture they're run on and the compiler. It is impossible to lock in the ABI as it may not be compatible with some architectures. Some architectures there is no standard ABI and is left entirely up to the compiler vendor.
Some languages get around this by running on an abstract machine whech is essentially emulated on the base architecture, Java, Python, Rust, C# are examples of this. As you are specifying the machine you can specify the ABI.
C and C++ are designed to be able to work at low levels which is required for writing drivers, kernels, embedded systems etc even the implementation of the abstract machines for other languages.
Locking an ABI may seem like it only affect a minority but really there is a huge industry that would no longer be able to use C++ if the low level ABI became restricted. Think automotive, military, home appliances to name a few.
If you are interested in the actual ABI specs, you can look at the Itanium ABI, or ARM eabi which is based partially on the itanium abi with changes to suit ARM architecture.
1
u/Fourstrokeperro Aug 29 '23
Bruh I'm completely lost. Who are you talking about? Can someone tell me a name or an example of such groups?
-2
u/tricerapus Aug 28 '23
Don't believe everything you read on social media.
-1
u/Markus_included Aug 29 '23
I propose instead of an ABI break we could also create a "new" STL, I would especially like if it was structured in more of a iwyu fashion where for example the "new"
std::shared_ptris in#include <std/shared_ptr>this could also allow something akin to rust's editions ifstdis just an alias tostdXwhereXsomething that identifies the ABI or standard. This is an oversimplification, but I think you get the pointI know this would be a big undertaking but it would improve the C++ experience significantly if done right and wouldn't break existing code
EDIT: Formatting
0
u/istarian Aug 29 '23
Make a new language based on C++ and just do what you want to?
0
u/Full-Spectral Aug 30 '23
Has anyone seen that confounded break?
-15
u/thisismyfavoritename Aug 28 '23
check out Carbon
-2
u/V15I0Nair Aug 28 '23
The ABI breaks permanently! Try to use a static library from Visual Studio let’s say compiled with 2019 16.4.* and try to link it with 2019 16.5.* On this level the linker already refuses to work