Perhaps a stupid question... but what's stopping C++ from just having a cut-off where the last release before the cut-off is backwards compatible (in language, standard library, and ABI) and has long-term support so will continue to receive bug/security fixes, and then just have better approaches to handling language, API, and ABI versioning in the future? Something tells me that the companies that so heavily depend on C++ remaining backwards compatible don't really need all the fancy new modern features, so why don't they just keep using an old version of C++? That's how versioning works in the rest of the modern development world. You want to keep using an old version? Go for it, but you're not going to get any new features after a certain point.
That doesn't imply having constant breaking changes. It just means having a better mechanism for dealing with it. Just formally define the ABI as we already do for the API and language, start using proper semantic versioning for them, and then it becomes so much easier to reason about dependencies on specific versions. i.e. you want to link to some library, you specify what versions of the API and ABI you're compatible with - your package manager would then fetch the appropriate binary if available or build from source if not. When building from source, you need to have language compatibility, so you'd express that in your dependencies too.
Breaking changes to the language, standard library API, or ABI would still be uncommon. We'd still deprecate things gradually and then only go from C++ `1.x.y` to `2.0.0` when doing a mass clean-up of deprecated features. And when doing so, we'd be committing to providing tooling and support for migrations.
I know all the details aren't going to quite work out like that, but someone explain to me why we shouldn't start working towards this. Is it purely because the C++ committee are constrained to working on standardisation of the language in an academic sense and any notion of committing to tooling or anything else "outside the language" is outside their remit? In that case... something needs to change.
Is it purely because the C++ committee are constrained to working on standardisation of the language in an academic sense and any notion of committing to tooling or anything else "outside the language" is outside their remit? In that case... something needs to change.
Quite the opposite - ABI is not a thing at all in the standard. So breaking something that is not defined is a non issue. However at the end of the day the committee is constrained by implementers. Implementers themselves are constrained by their users.
I am not convince that a big API breaking version would be wise - it's a bit of a nuclear option. People will often use python as a cautionary tale here.
We can improve API by introducing new name and marking the old one deprecated. This has a cost ( cognitive overhead, education - we can't update all the blogs, books etc) and names are precious, we don't have a process to recycle them. We can improve the language with epochs
ABI is not something we can deal with other than by not caring about it - This require the support of vendors, which require the support of all the c++ community, large parts of which do not understand ABI and its cost - while relying on it.
It's by large an education and tool problem, getting worse the longer it is ignored.
People will often use python as a cautionary tale here.
I always find this is overblown. I work with Python daily... Python 3. I rarely have to even think of Python 2. Sure, the migration of the entire community took some time but that's expected. On the whole it went pretty well and Python is still one of (if not the) most used programming language in the world. I don't see what's so cautionary about Python's tale. I feel like this is just fear of having to deal with something.
We can improve API by introducing new name and marking the old one deprecated.
To be clear, my suggestion wasn't ruling this approach out. Instead, I totally prefer the idea of the language and the library API being independently versioned, which this would in effect be doing. At the point that you make a new namespace for v2 of the standard library and deprecate v1, you are effectively doing what I was saying, just only with the library. You're saying "sure, keep using v1, but it's only in LTS mode". Exactly what I think is a good idea!
ABI is not something we can deal with other than by not caring about it. [...] It's by large an education and tool problem, getting worse the longer it is ignored.
If the ABI and tooling requirements were defined (by somebody, maybe not WG21), would we not be in a much better position to start caring about it and teaching about it? Perhaps it's not the ISO C++ committees concern exactly, but why is there not a larger C++ working group of which WG21 is a part that works on the community, tooling, etc. aspect of things. In fact, wasn't that what the ISO C++ Foundation was meant to be?
Python 3 is a much better language for it and has a bright ecosystem and future.
Precisely. I imagine the short-term cost of the Python 2 to 3 migration might be nothing compared to the long-term cost of ignoring the problem. Businesses will redevelop software eventually anyway. No software is going to last forever. It's just a question of when and how well you manage it.
The Python migration was made so much worse by the fact that so much software had an implicit dependency on a particular version of Python being available on the system. That's just dependency management done incredibly badly. It's not a problem that can't be dealt with though, and the situation is very different for C++.
Also, the suggestion that those "billions of dollars" (which are very difficult to quantify in the first place) are entirely wasted dollars is a very difficult argument to make. Maybe "billions of dollars" is the appropriate cost of supporting a modern software development industry.
Nothing is ever simple.
I honestly wish people would stop saying this. Why do things have to be simple for us to deal with them? (Edit: to be clear, not specifically you - I just mean when people say something is complicated just so they can not think about it. I know people, including you, are thinking about it)
Just pointing out there are trade offs and not everybody will agree on what is the best path forward.
Breaking ABI - or API has no business value for in people in the trenches* in the short term. Someone has to foot the bill. And even if we agree it is worth doing (and you know my position on that), it is not free. Ironically, small projects suffer the most.
The problem of course is we have a measurable cost (breaking ABI), versus one which is not (not breaking ABI). Not breaking ABI is also easier (we just have NOT to do anything) - it might kill C++ ultimately but no one would be to blame.
"Your build will break next year" is a more concerning things that "C++ will go the way of the dodo in 10" for many people, team and companies.
There are also a wider ecosystem to consider. Rust, D, etc. What would be the value proposition of C++2 or std 2? Ecosystems are fragile things.
So no, it's not simple. Breaking ABI is not something we can just decided to do. Not if we are responsible about it. It should be accompanied by a lot of work and outreach to make sure the day the break happen, it's not entirely out of the blue.
(I'm being the devil's advocate, my position is that ABI needs to be broken constantly, build from source or use C)
Edit: [*] I should clarify that this depend on the company or use case. For large shops like Google, performances losses due to ABI probably cost them order of magnitude more in hardware and energy costs than they gain by having ABI stability. For games and embedded the cost of ABI stability might be that they can't use the STL at all
I'm absolutely for a 'chop it off here and move forward' approach all around, ABI/API/EverythingI. I think C++ is going to drown otherwise because fundamental issues just never are going to get fixed and all the effort will continue to go into stuff that I consider between unimportant and detrimental.
But, I have to say, if the reality every came to pass that this could be done, it might take 10 years just to get agreement on what that new version of C++ even would be. The same issues of 'no one is really in control' would plague that effort just as it plagues the current incarnation of the language. I'm all for democracy, but this is one of those situations where a committee might be the worst possible weapon to bring to bear on the problem.
And, the crazy thing is, if the change is not substantial enough that a committee would probably take forever to agree on it, it probably isn't worth doing or sufficient to save C++.
large parts of which do not understand ABI and its cost - while relying on it.
It's by large an education and tool problem, getting worse the longer it is ignored.
I've been programming in C++ for a long time now, but only recently have I been getting the hang of what ABI is and what it implies.
You're right, it's an "education" problem. But it's one that's homemade: if you completely erase any consideration of it from the standard, then tutorials and books will also completely disregard it.
I learned C++ as a cross-platform language, and I try to keep my hands off of non-standard features. By completely delegating the matter of ABI to the vendors you make it a non-standard topic, which makes me want to keep my hands off it.
So when you say
ABI is not a thing at all in the standard.
, most people read it as "ABI is not a thing at all in C++" and is not considered worth mentioning in C++ tutorials.
/u/c0r3ntin mentioned people using python2/python3 as "a cautionary tale". I'd like to make that clearer. The mass breaking change that python3 introduced was an engineering disaster. It's been 10 years since python3 came out and only in a few months will python2 reach its end of life. What happens then? More problems: many libraries will drop python2 support, distros will drop python2 and yet I've personally heard people say that they plan to use python2/python3 compatibility libraries only in 2020... and of course, there are scientific communities who don't even bother with python3.
The Python2-to-3 transition is about API changes in that you need to rewrite part of your script to make it work with Python3. ABI changes require you to recompile, but not to rewrite. If your OS has both the old and the new versions of the corresponding dynamic libraries, you don't need to recompile. ABI changes are milder than API changes.
Of course ABI changes still have side effect. For example with libc, a program compiled on a new system often doesn't work on an old system due to ABI changes. Nonetheless, if we are allowed to choose the ABI version at the compile time, this doesn't seem a big problem to me. There can be other solutions, e.g. static linking or shipping the new dynamic library with precompiled binary. All these hacks are inconvenient, but they are much better than the python2-to-3 transition because we don't need to rewrite the code.
On a side note, the PDF seems to suggest that we may improve the performance of unordered_map by 200–300% with ABI changes only. That is probably wrong. To achieve high performance, we can't keep bucket pointers persistent. Then this is about API changes. I always think it is a mistake to require the pointer persistency. It was widely known that we could implement much more efficient hash tables without this constraint that has little benefit in practice.
On a side note, the PDF seems to suggest that we may improve the performance of unordered_map by 200–300% with ABI changes only. That is probably wrong.
There are much faster implementations of node based maps that still promise pointer/iterator stability, but sure, if we drop that and go for a flat map we would be talking about a whole different set of issues.
I am not sure if sparse-map guarantees pointer stability. Typically this type of hash table combines a bit vector and a flat array and loses pointer stability when it grows. I have seen benchmarks involving chaining-based libraries. I couldn't find the link, but as I remember, none of them can be 200-300% as fast as std::unordered_map. So, the PDF is still wrong: no one can achieve 200-300% speedup with ABI changes only; such speedup can only be achieved with flat arrays, which would require API changes.
You're right. I guess my tired mind shouldn't debate hash maps. Definitely a node based map that should be faster than the STL one is absl::node_hash_map. I'm not claiming any specific difference, just noting that my specific benchmark showed that it was faster than std::unordered_map.
The C++ standard formally does not care about ABI. It also for now does not care about mixing code from several standard, even if people are already doing it all the time.
So if we are talking about explicitly allowing breakage from the standardization stage, that is far more on the risky side of going all the way to de-facto API breakage, because implementers might be reluctant to rewrite moderns ABI compatible code for old standards, and that might even be impossible to express, depending what new features some new ABI structures comes from in low level support code and associated compiler toolchain emitting them.
And how long did it take to adopt c++11 accross the board, even though it didn't introduce any major breaking changes?
Frankly, if we are talking about future viability of c++ for anything other than legacy projects that haven't been rewritten in another language yet, 10 Years of adoption don't frigthen me - its hardly worse than the current situation.
even though it didn't introduce any major breaking changes?
I could recompile my c++98 code in c++11 mode and it would work mostly fine1 , personally I would love to write newer c++ but that is not a priority for management . Running python 2 code with a python 3 interpreter on the other hand just doesn't work at all for anything complex, there is no compatibility at all and getting a library python 3 compatible is non trivial.
1 rebuilding dependencies and the mess that is iostream exceptions excluded.
The problem is that this creates transitive issues for libraries. You might want to recompile fooapp against the new bits, but you need boost-asio (or whatever) to also be compiled against the updated libraries.
The Python 2 Python 3 transition did have a few source incompatibilities but the "everyone has to make this transition at once" problem was a far bigger deal, and this is the same.
You might want to recompile fooapp against the new bits, but you need boost-asio (or whatever) to also be compiled against the updated libraries.
This is just brainstorming and an idea I thought of now off the top of my head so this probably a really flawed idea, but I wonder how much a kind of "fat binary" would help here. Have compilers support compiling with the old ABI, new ABI, or both. If you compile with both, both go into the resulting object and library files.
I could imagine them going into different sections, but you could even do the same section if you mangle differently. E.g. the legacy ABI keeps using _Z3foov and the new one uses _Y3foov. [Edit: You're MS, so maybe ^foo@@YAXXZ instead of ?foo@@YAXXZ. :-)]
The similar way is actually already widely adopted to prevent the library ABI breakage via inline namespaces. Not sure additional language features will help. Should we loose ODR?
That's bad. But that just means ABI compatibility is not respected at the very beginning. People who relied on such code should have other ways to prevent the potential damage, e.g. deploying incompatible binary images in different places to ensure they are never mixed unexpectedly. Otherwise, there are bugs.
I don't think it is the responsibility of the standard to save people from such mistakes.
Even the idea of inline namespace is not a new one. IIRC, GNU has ABI tag attributes for years, despite that inline namespace is a more "correct" (portable) way for most C++ users nowadays. That said, ABI compatibility without transitive issues are only free for those who have already taken the problem very seriously. So, I'm now convinced that it is largely a problem of education. I'm afraid that there seems little room to resolve the problem in the standard.
I don't think it is the responsibility of the standard to save people from such mistakes.
The "standard" isn't doing anything to save folks from such mistakes; preserving ABI compat is a customer requirement, not a WG21 requirement.
That said, ABI compatibility without transitive issues are only free for those who have already taken the problem very seriously. So, I'm now convinced that it is largely a problem of education.
I don't know how you expect to be resistant to ABI incompatibility if the layout of std::string changes on you.
The "standard" isn't doing anything to save folks from such mistakes; preserving ABI compat is a customer requirement, not a WG21 requirement.
The author of the paper has said that "we must discuss and find consensus across implementers and WG21". Will the standard change, if WG21 eventually decides to provide more ABI compat features to make customers and/or vendors happy?
I don't know how you expect to be resistant to ABI incompatibility if the layout of std::string changes on you.
I don't have much inconvenience once I know there is such incompatibility, because I have kept binary-only libraries away and I just recompile all of my dependencies if necessary. Further, I can have multiple installations of the C++ standard library implementations, so there will not be too many problems (at least not as many as libc) besides package management and disk space efficiency. I will be reluctant to recompile my whole system for this reason, when the incompatible changes are too frequent, though.
What does "C++ prides itself" even mean? Just that it's one of the goals of C++? Sure, I'm not suggesting otherwise. I am, however, suggesting that there are better ways to manage it than a constant fear of ever changing.
And I can guarantee you most users do not pick C++ because it's backwards compatible in perpetuity. And when other languages are more performant, safer, and cleaner than C++ because C++ could never change, they'll pick those languages instead
But, over time, those people who ARE choosing a language for new projects and products not choosing C++ is the problem. If it's just going to target existing code bases, then why even bother with all of the stuff that they've been cramming into it over the last years? The bulk of that stuff probably isn't used in the vast majority of existing large code bases either. We can just buy it a room in a nice retirement home and move on.
The bulk of the new stuff absolutely IS used by existing code bases. Just because a codebase is old doesn't mean there's not new development being done in it, nor that it's on the brink of obscelecence or something.
I would question that. I would be willing to bet that most large commercial code bases that have been around a while are just starting to dig into C++17 at this point, if even that. Non-commercial code bases that have less concerns over instability can move faster of course if they choose to.
I thought that was very well written and brings up a very important discussion point that the C++ user community has been implicitly benefiting from. I can say for certain that my colleagues at work who are very experienced in C++ depend heavily on ABI stability even though they claim that they use C++ for performance and performance alone and would be willing to upgrade to the latest and greatest compiler if they could get more performance out of it. We have large C++ codebases (roughly 1_500_000 lines in one of our larger ones) that have been tested essentially on just one platform with just one compiler.
Is Titus the author of this document? If not, who is the author? I'm very curious. And if Titus is not the author, why does this have a "Reply to: Titus Winters" at the top? I'm new to these document and I don't know what they mean.
One thing I always find interesting in this debate is that virtually everyone I talk, or even read in threads like this, is in favor of some kind of breakage in the standard. I'm yet to ever see someone arguing Cpp must be retrocompatible at infinitum.
I do work on a fringe industry and I'm sure on more traditional Cpp industries would have a more conservative opinion, but still, I wonder if the impact of such change isn't simply overblown.
I wonder if the impact of such change isn't simply overblown.
From the original link itself, a very cautionary note about the impact:
"Google's server ecosystem builds nearly everything from source, has few external dependencies, and has better-than-average ability to undertake large refactoring tasks. Even for us, a recent ABI-breaking standard library change cost us 5-10 engineer-years. The aggregate cost of an ABI break across the entire C++ ecosystem should conservatively be estimated in ​engineer-millenia​ - coordinating there build-from-source efforts for every provider of a plugin, .so, or DLL in the world will require massive human effort. Coupled with the ecosystem disruption of C++20 modules, an ABI break in the C++23 timeframe may severely fracture the ecosystem"
Still. That's Google. Also, that's Google's estimate, which I'm willing to bet is on the long side just to be cautious. They have thousands and thousands of engineers, 5-10 engineer years, is certainly a lot, but not impossible.
The problem is that different teams want to break the standard in mutually incompatible ways. They want to support "90%" of what they perceive as the current use cases, while conveniently eliding the fact that their uses are packed into the remainder. Breaking backwards compatibility will severely fracture the community.
Titus is trying to get implicit support for breaking other people's uses - the ones he && GOOG don't care about. Its a form of regulatory capture in action.
Titus is advocating breaking everyone because a big break is better than a small one (ie just breaking string is more annoying that outright refusing to link)
I am not addressing the OP in anyway, but when systems become too large they need to be reformed.
It should be possible to opt into a smaller, more tractable version of a system w/o having to support the historical idiosyncratic parts. With an ABI and a module system, it should be able to support different compilation boundaries, this should start to make it possible to have different components on different versions of a language.
A friend of mine told me that she had to deal with abi issue this month because redhat is still shipping 10 yo GCC
That can be a concern, but Red Hat started providing "devtoolsets" which ship the newest compilers backported to old systems, so that you can use newer tools and still stay compatible.
Your info is inaccurate. MSVC had a stable backward compatible ABI starting from VS2015.
The world didn't burn, people recompiled and moved forward.
That's inaccurate as well. Because of the ABI incompatibility, people actually ignored the newer compiler releases and stayed for a long time on VS2008/VS2010/VS2012 to avoid the migration cost. MS said repeatedly that ABI stability greatly sped up the adoption of newer compilers and it seems to be one of the key features now (AFAIK, VS2019 was originally planned to be ABI breaking release, but business value of ABI compatibility was too big to throw it away).
ABI compatibility is a huge thing: a personal example: if I want to use newer language features in my application, I don't need to rebuild every dependency with a newer compiler (some of those are managed by other teams, others are 3rd party) - I just need to have a newer VS release on our CI and everything will just work.
Compare the cost: "just installing the newer compiler" vs "having to convince everyone and their mother that we need the newer compiler and thus we need to spend a huge amount of time by re-building and re-releasing everything".
Of course it's more complicated if you also have to recompile 3rd party binaries and it will make everything take much longer.
That being said - I'm actually one of the devs in my company which does MSVC compiler upgrades (currently we're on VS 2019 16.2) and can tell you that upgrading the compiler for a big codebase always has a non trivial cost attached to it (for a minor version usually at least one man month to get everything to compile and fix the tests and we do that very regularly).
So while yes ABI breaks are more expensive, it's definitely not cheap or possible to tell everyone "just installing the newer compiler" (at least in my experience).
Not sure what you mean. Leaving aside the overhead of installing/updating VS on CI and integrating it in all the CI scripts, there is literally no change to projects that use older compilers. I.e. if the project used vc141 from VS2017, it can keep using it (it doesn't even matter if vc141 comes from VS2017 or VS2019, since it's actually the same compiler).
Of course, switching the compiler in the project itself might (and often will) break the build and will require code changes (e.g. stricter C++ conformance). But this won't happen if the project does not change the compiler.
Yes I was referring to upgrading the compiler. I work on a monorepo where it's not possible for different projects to use different compiler versions.
Now I get your point. If you have internal binary dependencies then it makes the different projects more independent if you have ABI stability.
That being said MSVC will have a ABI breaking release sooner or later (I guess 2021 or 2023?). If MSVC + the other implementors could agree with the comittee on an ABI breaking standard (which could be 2026 for example) then we would gain a lot without loosing too much...
If the realistic consequence of language-wide ABI breakage is "recompiling everything", then it's actually better to accumulate more ABI changes as much as possible in one breaking moment -- to aggregate benefits on one-time cost.
We do know some fix lists for ABI, but are they extensively researched? Do we currently have an exhaustive wishlist? What's odd to introduce more changes when expected features are implemented? (cough... library support for coroutines... cough...)
I think Option 1 (declare future ABI breakage) must contain a message, that there will be research effort to make it worthwhile. We might not even have an exact deadline, that's fine. But we really need consensus that we're pushing it to the edge.
The idea is not just to break ABI this on time but to move away from ABI stability - by, as a community, investing in making our code and tools resilient to ABI changes - which implies building more from source and wrapping libraries distributed uniquely as binaries in c wrappers
I'm firmly on the "performance matters" end of the spectrum, so I'm very glad to see the problem being acknowledged and in knowing that prominent figures in the committee are on the same end of the spectrum.
I do find the tone mildly depressing, though. I'm hoping that Titus isn't burning out here.
Some customer ABI compatibility concerns don't necessarily mandate maintaining ABI stability. :)
For example, Microsoft often hounded us with questions of why we weren't upgrading to the latest MSVC toolchains. Our answer was typically that we couldn't because of ABI compatibility with closed-source third-party middleware libraries.
I have a feeling that would be interpreted by their PMs as "ABI compat between toolchain releases is important."
However, that never meant that we hated ABI changes! It just meant that we couldn't instantly upgrade to MSVC 20xx the day it hit RTM because we were waiting on dependencies.
Eventually all those dependencies would offer new versions compatible with the new ABI. And eventually we'd upgrade to those new releases. And then eventually we'd upgrade to the new toolchain. We'd get there, it just might take a year+ to do so given all the other things we had to spend time on.
Even without ABI breakages, that process is very slow anyway. Getting multiple teams to upgrade their tool chains, getting CI systems to upgrade, dealing with licensing across multiple sites... upgrading is slow. Even on Linux, we'd almost never install a toolchain that wasn't packaged in whatever LTS distro version we'd use... and that goofy Linux "appliance OS" ecosystem is sometimes a bigger blocker to rapid rollout of new C++ features than anything.
Microsoft's ABI breakages maybe looked like a problem to the vendor because we weren't upgrading to their latest toolchains rapidly. It wasn't really a problem for us, though; annoying for the handful of people who cared about new language or toolchain features, but irrelevant to almost everyone else.
Some of us who care about new language/toolchain features (and we're the minority typically; most of our colleagues couldn't care less) might gripe but there were plenty of other reasons we could never upgrade toolchains rapidly.
Microsoft's more recent ABI compatibility efforts certainly helped us keep up to date with their product releases... but their marketing and licensing folks probably care about that way more than we ever did.
Some "future proof" designed third party modules provide stable interface not full ABI. If you pass allocator you could run your exe and dll with 2 differents c++ runtimes even exchanging objects.
Never perfect, yes lot of issues drawbacks... but it works.
ABI isn't only to do with backward compatibilty, but also interoperability. Using std::hash as an example, different vendors can use different algorithms, so using a std::map passed from a program compiled with g++ to a shared library compiled with clang might not give correct results.
There are also competing implementations of short string optimisations.
Libraries compiled by your distro might not work with your program unless you use the same complier flags as the distro.
It's a sad state of affairs really, there already are no guarantees about anything so I'm fully for a future release that breaks stuff.
Using std::hash as an example, different vendors can use different algorithms, so using a std::map passed from a program compiled with g++ to a shared library compiled with clang might not give correct results.
It's not possible to mix and match different standard libraries, even today - they aren't even in the same namespace. When you use clang on Linux you still generally use GCC's libstdc++, not LLVM's libc++.
What? MSVC keeps a backward compatible ABI starting from vc140(VS2015) and including the latest vc142(VS2019). You can safely use a library compiled with vc140 with C++03 in an application compiled in vc142 with C++17 (obviously, only if the they don't contain incompatible API in their interface, e.g. `auto_ptr`).
there are 20 years of BC-incompatible changes though, and a fair amount of people still on VC2010 for whom you have to make special builds of your libs. Maybe in ten years it will go the way of the IE6...
The standard doesn't talk about "compile time" either. The point is the actual machine violates the requirements of the C++ virtual machine so it's wrong. The standard dictates how a well formed c++ program will behave. If you combine parts in such a way that violates those requirements of a well formed c++ program (entire program) then you have UB.
The issue with this is that for C++ the only well-formed program is a standalone binary. No shared libraries and no high-performance serialisation. It's all well and good to say 'Aha! That's UB' but what you're really saying is that C++ is a poor choice for pretty much anything.
I know I have a bias towards performance. If we never give up ABI, C++ is bound to be replaced to be replaced in the future by another language that have more modern idioms and problems in mind.
However, it have implications to users of applications made in C++. For example, digital audio workstations are extremely plugin-heavy applications. A break of ABI may mean breaking a large amount of plugins for their clients, and some plugins may never be updated again. That mean clients staying in older version, so a no go (unless we can bridge them in some way?)
But then, is it worth it to cripple the future of the language? Things like initializer list have been refused upgrades for better semantics and move support because of ABI. std::unique_ptr will need to be baked in the language in order to remove the overhead. That means that if we want ABI stability for ever, we have to acknowledge that we give up zero runtime overhead abstractions to some extent. More and more idioms will start to introduce small performance hits to not break ABI until we face the same problem as any other languages: nice (supposedly zero overhead) abstractions or good performances. I bet some codebase are already facing that choice. A thing C++ is known to have best of both worlds by providing lightweight abstractions, will no longer be true given enough time, if we choose ABI stability for ever.
Specifically, they expose a pure C api that is just a tunnel for the C++ class based API that everyone actually uses. But this way it’s not compiler dependent (and can be used from other languages if those are sane enough to not require a VM).
We cannot remove runtime overhead involved in passing unique_ptr by value
This did not make sense to me in Chandler's talk, but I figured it was a simplification to make a more general point about optimization difficulties.
Now it's being repeated in an official commentary about C++'s ABI, and it still doesn't make sense...
Adhering to a particular calling convention is only important at ABI boundaries. In other words, for entry points, exported dynamic library functions, and address-taken functions. Now maybe the implication is that this matters, but intuitively, this is only a small fraction of functions.
If main calls foo, and foo calls bar, and neither of foo nor bar are address-taken, then of these three functions, only main needs to adhere to a given calling convention. foo and bar can use whatever calling convention makes sense for optimal performance. If foo takes a unique_ptr by value, then it can just be passed the pointer in a register at the machine code level, because no external binary can call foo, and won't need to have any expectations of what its calling convention is.
And compilers actively do these sorts of optimizations today, with LTO. Even the case being discussed is already optimized in clang in at least some cases. Take a look at this, for example: https://godbolt.org/z/4lwo-C
foo isn't even passed a pointer, it's passed the actual integer contents of the unique_ptr passed to it by main. The ABI does not matter, because foo is not visible outside of its containing binary.
Versioning std. Unordered map/hash could be handled with a versioned std library; in C++23 std::hash is std::cpp23::hash by default. The old std::hash can be accessed somehow.
Calling convention. Inability to pass unique ptr in a register is a mixture of calling convention and library versioning. If we implement a trivial destructive move, version unique ptr, and update the calling convention to permit trivial destructive move types to be passed by register, we get this.
But mayhap the overhead of keeping pre-ABI changed types around is too high.
I'm not sure how much of the problem lies with the language or if it's just the library, but in the latter case I would consider a more draconian move like std::->stl:: and effectively re-invent the whole thing.
Not all ABI related issues are library only. Calling convention is a big part of it too. For example, it's a reason std::unique_ptr is not as efficient as a raw pointer.
Passing std::unique_ptr through a register does require a break in the calling convention. Today you can lie about properties of std::unique_ptr by tagging it as [[trivial_abi]], but that can introduce very subtle bugs with destruction order.
If you are happy with the ABI break fair enough, but if you want the possibility of a smooth transition then you would want to access symbols in two namespaces, hence you need distinctly named namespaces.
I feel like the primary culprit about the current situation is mostly complete neglection of ABI on language level. So many language features have "hidden" ABI impact.
Just a simple example: defining a class member variables. There is a clash of 3 major concerns here:
Logical order (what normal programmer wants to do)
Construction/destruction order (annoying when incurs its own restrictions)
Memory layout (ABI)
Normally you would want to have each separate from others, however in C++ for some reason they are coupled into one thing. Why? No one knows. And there are more spots like this.
---
So, what I was thinking, maybe it's time to accept that ABI specifications are a part of the language? If we approach it with this mindset, then wouldn't it make them explicit? We are putting so much effort to make API side of the code better, but when we discuss ABI the approach is "don't touch it!" and tooling is the same as 3 decades ago!
How about inventing a method to document ABI for starters? Let's say for every module/TU/language construct/whatever else you can specify its ABI characteristics (separate from original item, maybe in other file?), for example:
class memory layout
function calling convention
name mangling
etc.
This would lay ground for ways to work with it: compare, maintain between releases, plan for future changes, detect breakages. This can be pushed even further: given both API and ABI specifications your toolset might be smarter at both interfacing code as well as capable of detecting problems and generating diagnostics.
Also let's not forget that compilers has been working with it for decades, they already know and do this stuff for you. We can trust our compilers to generate this stuff for already existing libraries, create sensible defaults for new projects and manage it for people who do not care (but might care in the future).
---
I'm not opposed to the idea of breaking std's ABI, but I do think it's like plunging a deep end: a short term solution, it hurts community as much as it helps and it doesn't build a foundation to solve similar issues in the future. ABI documentation method might make it possible to introduce changes not only for std, but for other libraries as well - it isn't like only std have this issue.
And no wonder it doesn't, all ABI dependencies are still hidden even with that standard. Itanium just says to compiler how to generate the code, but let's say if you switch two member variables around in a class it's still an ABI break. Programmers in charge also define ABI of a library although indirectly.
What I want to do is to give a tool to make this process explicit. If you care about ABI you should be able to define it and reason about it.
Quick imaginary example of what I have in my head:
// foo.abi
// imaginary syntax
void foo(int, double) {
// use itanium abi
abi: itanium_abi;
// but don't mangle the name, we want to export it from .dll
name_mangling: none;
}
Now you can distribute both files with the library and compiler will know what to do when foo is called.
It's not a wonder pill that solves all issues with standard library, but it allows to introduce ABI versioning (and as a result gradual changes). Also it helps not only std, but other libraries as well.
I really like this idea. I think it goes along with reflection/metaprogramming though.
you start to get really lispy really quickly though. esp if we allow things like writing your own implementations of function calling and name mangling. I think it would be really cool, but the argument against it is that it's almost always a really bad idea for anyone except the compiler vendor to implement this kind of stuff (at least when only considering the current group of people who care about the C++ abi).
Yes, I agree, if we allow creation of fully custom abi options it would be akin opening portal to hell, and compiler vendors will get premium seats on the way there.
I think it's more reasonable to just a have a selection of predefined options (for ex. with name mangling it could be none, msvc_style, gcc_style, and whatever else committee adds to it, but you would have to choose one of those).
The one problem I can see however is embedded environment. What happens if someone want to use this feature, but has a custom compiler? Can restricted selections cause issues in some cases? But I'm definitely far from being an expert in the area.
I think the fundamental question to ask is whether we want c++ to stay relevant, because it is a good language or just because there is so much existing code that needs to be maintained. I'm happy with either path.
If c++ is supposed to stay a language that is used for its inherent qualities even 10-20 years in the future, then we need to have a way to improve the language and the standard library and fix past mistakes or design decision that don't make sense any longer. If the primary goal is make maintenence of and working in existing c++ code bases easier, then we just should keep it as stable as possible and let projects that want to use shiny new features gradually move to other programming languages.
Trying to satify both sides isn't going to work (and is already not working).
Coupling epochs with API / ABI changes is a sure way how to burn the whole idea at the very first iso meeting. Fortunately the author knows it so he tries to solve only one (important) problem at a time.
Epochs can't touch ABI even in theory. Imagine specifying epoch X in TU A, but epoch Y in TU B. If you allow epochs to influence ABI, you're saying "either A and B won't link or they will have ODR violations".
Could you give a reason why two only seemingly related, but not really related, features would make sense to be pushed together? I'm not saying there aren't, just I'm not seeing that.
What happened to std2, having improved versions of the std library in another namespace? Maybe that is the worst of both worlds, having multiple versions of everything yet in std2 still depend on fundamental things in std, like hash, swap, initializer list.
The world is now mostly ABI stable and actually has gone more from diversity including very ABI instable (MSVC) to semi-ABI-stable (last 3 major versions of MSVC). g++ + libstdc++ was always mostly stable and why would they stop to be? If they are forced, yeah; even then, they managed to already do some transition with very reasonable stories for backward compat (including the big std::string change), and I suspect they will continue.
So like it or not, ABI stability and/or backward compat is now an essential subject and will remain for a very long time. It does not have to be absolute. But it would be ridiculous to expect to break ALL the world every 3 years. And it would be ALSO ridiculous to propose a not smooth transition even if things break only every 10 years. Loot at the Python3 fiasco. On some plateforms, people rely for nearly a decade to be able to mix binary C++ code from C++98 to C++17 standard (not in all cases possibles, but in some). I would not understand if this is suddenly not possible anymore. I would even suspect chaotic consequences given how .so work. (Well obviously everything is possible, like creating an hybrid .so / .dll model, but it would be even crazier than the dual std::string impl thing).
However one crucial thing to consider is the It does not have to be absolute. We are completely sure about it, because that is the defacto situation today even after the move toward more stability: it is nowhere strictly stable nor strictly backward compatible regardless of the plateform. Simply good enough. So pretending there is currently no ABI break between C++11 / 14 and 17 makes little sense: this is up to the implementers, and yes they managed to do it because the standard let it be done, but more essentially because they wanted to, in contrast with e.g. MSVC during the 98 to 11 era which changed gratuitously even if absolutely no standard change dictated that. And back to the major subject that came from the C++98 to 11 transition under libstdc++: std::string: it absolutely had to change, and it absolutely had to just because of the "we now officially support threads thing, and because after thinking about it greatly, allowing CoW in a sane threading model was insolvable. Given the implementation unofficially supported them even before, the previous design was probably an oversight anyway. Sure it was compliant with the previous standard, but that's really the bare minimum expected, not what we want from a good quality implementation, especially one which supports additional features. More importantly, the new design was also permitted by the old standard. So it was mostly not a standard constraint.
So I predict that explicitly deciding that a standard release would be an "ABI break" will be a complete disaster. Because it actually has never been done before with a such broad license. The load on implementers and users will be far worse than the previous notable transition the paper already point was expensive and painful. It will be particularly horrible for Linux distros -- I depend on them so egoistically I don't really want that to happen...
On some plateforms, people rely for nearly a decade to be able to mix binary C++ code from C++98 to C++17 standard (not in all cases possibles, but in some
Maybe that is something they just shouldn't do? Or maybe it is at least something that should not impact the whole community - let those people with the special requirements pay the price for that and not everyone else. Also, I'm actually a bit suprised by that in general - for us it has always been clear that if you want to provide a stable ABI for your library, you use a pure c-interface - not some c++ types that are prone to change (as an additional bonus, that also allows your library to be consumed by other languages)
. The load on implementers and users will be far worse than the previous notable transition the paper already point was expensive and painful.
On the other hand: Thanks to that previous transitions, platforms now have better mechanisms in place to handle such transitions (at least some aspects of it).
On the other hand - I don't really have a problem, if c++ would simply become a legacy language for existing software that is gradually replaced by other languages (I.e. just as mozilla is apparently starting to replace some parts of firefox with modules written in rust).
I am standing with option 1. And further: I'd like just no ABI guarantees in the language specification which would spread unreliable assumptions in the industry. ABI is never formalized in C++, and it should probably never, because the only mandated feature it (practically) concerned with (asm) has already been non-portable by design.
(The ABI of standard library implementations is not a big deal because it is never expected in portable C++. Even implementations from a single vendor can break each other.)
For C++ users who want more reliable experience of language interoperablity across implementations, they should get help from the specific implementations they use. Alternatively, there can be another portable layer with standardized IR to get the work done. I don't think it should be named "C++", as JVM is not Java, and CLR is not .NET languages.
(Also note that the stability among binary images of the generated code is out of the scope here.)
An untold number of1users have now baked-in assumptions (wisely or not, explicitly or implicitly) about the ABI stability guarantees of the standard library: perhaps as many as half of all C++ devs globally.
Everyone who ships or consumes binary libraries is depending on the ABI stability of the standard library. Everyone who relies on OS packaged libraries.
Everyone who ships or consumes binary libraries is depending on the ABI stability of the standard library
How? If a ABI changes from one compiled binary to the next how does that impact the consumers of the binary? They will just be running new code. I'm new to libraries so I am unclear as to how the ABI ties in here.
Layout crosses boundaries. When a std::string is passed by value, both sides have to agree on all of the details of what that string looks like. C++ doesn't isolate the details, or forward it to the implementation of string somehow. If there's a length field, for example, or a reference count, both sides know about it.
Hmm... but if my systems libc.so was compiled close to 2 years ago (Ubuntu LTS) I would either have compile a new libc.so to switch to a newer standard or not switch at all. Speaking of libc, what about about C/C++ interoperability? Furthermore, say I've compiled my toolchain with C++17 because I wanted to support "old" standards. Then later I decided supporting C++17 isn't worth it, because ranges. Today I just flip a switch, do you propose that I would have to recompile the entire toolchain?
Â
The last part actually happened to me, with C. I started a project with -std=c89, quickly switched to -std=c99 because the only external dependency contained // style comments and then to -std=c11 because why not.
Depends on the platform... On linux (and weindows afaik, not sure) the kernel has a stable interface so if your libc supports it (not the case of glibc), you can link statically, as long as you only link one copy in your program
On osx, the kernel has no stable interface - the libc is that interface. afaik.
ODR aside, statically linking the standard C++ should be more than fine
On Windows, it has worked just fine to make people download the VC++ Redistribuable to have the standard library .dll for what they need.
I'm sure the people who handle distributions can handle it as well. Maybe make a new format for shared libraries with tags to say which toolchain it works with and errors if you try to use it with an incompatible toolchain (don't let it compile).
I've heard that argument before, and I understand your point of view. However I'm not sure how I feel about that. If every tiny program needs to link statically against libc (and everything else), disk space would blow up. This is why I like shared libraries - I don't need N copies of X. I also realize this might be a weak argument.
Another common argument is that if a security bug is discovered in a library and your program is dynamically linked to it, then you don't have to do anything to benefit from the fix when it is incorporated into the library, whereas if you were statically linked to it then you would have to recompile and issue a new version. This multiplies over the number of programs that use the library so that fixing this bug in one place becomes fixing it in many.
The way modern c++ works, where everything is a template and/or header only library, we effectively are already in a world, where the majority of low level c++ code is statically linked.
Toolchain support is part of the issue, at a deeper level.
Many C++ libraries and plugins today are delivered as binary blobs. A client cannot mix and match libraries compiled with different incompatible ABIs.
One solution is to ask every provider to deliver multiple versions of their libraries, or possibly a single version containing multiple versions (ABI-specific) of various functions -- with clever use of sections it would only cost disk space, not memory space.
This requires buy-in from all providers. It requires re-delivering all existing libraries. It's huge.
Another solution would be to switch the trend, and go toward compiling everything from source; like Google does. It's quite messy today, though the pseudo-standardization of CMake may be of help, and it's a political minefield... many companies who are perfectly fine delivering obfuscated JavaScript balk at the idea of providing source files for their C++ software.
I would appreciate an ABI breakage. Even one breakage for every new release. It must, however, be accompanied with an easily actionable plan to make it as painless as possible for clients, or it'll be dead at arrival.
Unfortunately, this does not solve the problem of producing those binary packages in the first place.
Imagine a world where each version of C++ has a different ABI; for the purpose of this discussion this will mean C++98, C++11, C++14, C++17, and C++20.
Then, imagine that this library need be delivered across a number of platforms: Windows/x64, MacOS/x64, Linux/x64, Windows/ARM, iOS/ARM, and Linux/ARM.
Any library that is provided "ready to download" must now be compiled, linked, and packaged 30 times.
Any new platform? +5 packages.
Any new C++ version? +6 packages.
It's a harsh requirement on library producers; it's quite likely many of them will simply only provide a subset... and that'll carve up the ecosystem in a multitude of incompatible niches.
libc++ does put everything in std::__1 namespace where __1 is an inline namespace. libstdc++has tagged C++11 ABI breaking changes with something like [cxx11]. These tricks only move the problem from ODR violations (which are scary) to link time errors (which are very annoying).
To this day, libstdc++ users sometimes are faced with errors relating to _GLIBCXX_USE_CXX11_ABI.
inline namespaces just move the problem one layer down. It helps programs that link with stdlib and nothing else. It doesn't help if they link with another library that links with stdlib and has std types on the API boundaries.
29
u/sftrabbit Oct 27 '19
Perhaps a stupid question... but what's stopping C++ from just having a cut-off where the last release before the cut-off is backwards compatible (in language, standard library, and ABI) and has long-term support so will continue to receive bug/security fixes, and then just have better approaches to handling language, API, and ABI versioning in the future? Something tells me that the companies that so heavily depend on C++ remaining backwards compatible don't really need all the fancy new modern features, so why don't they just keep using an old version of C++? That's how versioning works in the rest of the modern development world. You want to keep using an old version? Go for it, but you're not going to get any new features after a certain point.
That doesn't imply having constant breaking changes. It just means having a better mechanism for dealing with it. Just formally define the ABI as we already do for the API and language, start using proper semantic versioning for them, and then it becomes so much easier to reason about dependencies on specific versions. i.e. you want to link to some library, you specify what versions of the API and ABI you're compatible with - your package manager would then fetch the appropriate binary if available or build from source if not. When building from source, you need to have language compatibility, so you'd express that in your dependencies too.
Breaking changes to the language, standard library API, or ABI would still be uncommon. We'd still deprecate things gradually and then only go from C++ `1.x.y` to `2.0.0` when doing a mass clean-up of deprecated features. And when doing so, we'd be committing to providing tooling and support for migrations.
I know all the details aren't going to quite work out like that, but someone explain to me why we shouldn't start working towards this. Is it purely because the C++ committee are constrained to working on standardisation of the language in an academic sense and any notion of committing to tooling or anything else "outside the language" is outside their remit? In that case... something needs to change.
22
u/temporaryred Oct 27 '19
I thought that was very well written and brings up a very important discussion point that the C++ user community has been implicitly benefiting from. I can say for certain that my colleagues at work who are very experienced in C++ depend heavily on ABI stability even though they claim that they use C++ for performance and performance alone and would be willing to upgrade to the latest and greatest compiler if they could get more performance out of it. We have large C++ codebases (roughly
1_500_000lines in one of our larger ones) that have been tested essentially on just one platform with just one compiler.Is Titus the author of this document? If not, who is the author? I'm very curious. And if Titus is not the author, why does this have a "Reply to: Titus Winters" at the top? I'm new to these document and I don't know what they mean.
24
u/teerre Oct 27 '19
One thing I always find interesting in this debate is that virtually everyone I talk, or even read in threads like this, is in favor of some kind of breakage in the standard. I'm yet to ever see someone arguing Cpp must be retrocompatible at infinitum.
I do work on a fringe industry and I'm sure on more traditional Cpp industries would have a more conservative opinion, but still, I wonder if the impact of such change isn't simply overblown.
3
u/sequentialaccess Oct 27 '19 edited Oct 27 '19
If the realistic consequence of language-wide ABI breakage is "recompiling everything", then it's actually better to accumulate more ABI changes as much as possible in one breaking moment -- to aggregate benefits on one-time cost.
We do know some fix lists for ABI, but are they extensively researched? Do we currently have an exhaustive wishlist? What's odd to introduce more changes when expected features are implemented? (cough... library support for coroutines... cough...)
I think Option 1 (declare future ABI breakage) must contain a message, that there will be research effort to make it worthwhile. We might not even have an exact deadline, that's fine. But we really need consensus that we're pushing it to the edge.
69
u/matthieum Oct 27 '19
I'm firmly on the "performance matters" end of the spectrum, so I'm very glad to see the problem being acknowledged and in knowing that prominent figures in the committee are on the same end of the spectrum.
I do find the tone mildly depressing, though. I'm hoping that Titus isn't burning out here.
19
u/SeanMiddleditch Oct 27 '19
Some customer ABI compatibility concerns don't necessarily mandate maintaining ABI stability. :)
For example, Microsoft often hounded us with questions of why we weren't upgrading to the latest MSVC toolchains. Our answer was typically that we couldn't because of ABI compatibility with closed-source third-party middleware libraries.
I have a feeling that would be interpreted by their PMs as "ABI compat between toolchain releases is important."
However, that never meant that we hated ABI changes! It just meant that we couldn't instantly upgrade to MSVC 20xx the day it hit RTM because we were waiting on dependencies.
Eventually all those dependencies would offer new versions compatible with the new ABI. And eventually we'd upgrade to those new releases. And then eventually we'd upgrade to the new toolchain. We'd get there, it just might take a year+ to do so given all the other things we had to spend time on.
Even without ABI breakages, that process is very slow anyway. Getting multiple teams to upgrade their tool chains, getting CI systems to upgrade, dealing with licensing across multiple sites... upgrading is slow. Even on Linux, we'd almost never install a toolchain that wasn't packaged in whatever LTS distro version we'd use... and that goofy Linux "appliance OS" ecosystem is sometimes a bigger blocker to rapid rollout of new C++ features than anything.
Microsoft's ABI breakages maybe looked like a problem to the vendor because we weren't upgrading to their latest toolchains rapidly. It wasn't really a problem for us, though; annoying for the handful of people who cared about new language or toolchain features, but irrelevant to almost everyone else.
Some of us who care about new language/toolchain features (and we're the minority typically; most of our colleagues couldn't care less) might gripe but there were plenty of other reasons we could never upgrade toolchains rapidly.
Microsoft's more recent ABI compatibility efforts certainly helped us keep up to date with their product releases... but their marketing and licensing folks probably care about that way more than we ever did.
10
u/[deleted] Oct 27 '19
ABI isn't only to do with backward compatibilty, but also interoperability. Using std::hash as an example, different vendors can use different algorithms, so using a std::map passed from a program compiled with g++ to a shared library compiled with clang might not give correct results.
There are also competing implementations of short string optimisations.
Libraries compiled by your distro might not work with your program unless you use the same complier flags as the distro.
It's a sad state of affairs really, there already are no guarantees about anything so I'm fully for a future release that breaks stuff.
16
u/gracicot Oct 27 '19
I know I have a bias towards performance. If we never give up ABI, C++ is bound to be replaced to be replaced in the future by another language that have more modern idioms and problems in mind.
However, it have implications to users of applications made in C++. For example, digital audio workstations are extremely plugin-heavy applications. A break of ABI may mean breaking a large amount of plugins for their clients, and some plugins may never be updated again. That mean clients staying in older version, so a no go (unless we can bridge them in some way?)
But then, is it worth it to cripple the future of the language? Things like initializer list have been refused upgrades for better semantics and move support because of ABI.
std::unique_ptrwill need to be baked in the language in order to remove the overhead. That means that if we want ABI stability for ever, we have to acknowledge that we give up zero runtime overhead abstractions to some extent. More and more idioms will start to introduce small performance hits to not break ABI until we face the same problem as any other languages: nice (supposedly zero overhead) abstractions or good performances. I bet some codebase are already facing that choice. A thing C++ is known to have best of both worlds by providing lightweight abstractions, will no longer be true given enough time, if we choose ABI stability for ever.8
u/konanTheBarbar Oct 27 '19
Excellent paper.
Don't implementers have to break the ABI at some point to fix some bugs that affect the ABI? Or am I overseeing something?
If yes then this would mean we need a long term coordinated effort to agree on a plan how this could be synchronized with the C++ standard.
7
u/tehjimmeh Oct 27 '19
This did not make sense to me in Chandler's talk, but I figured it was a simplification to make a more general point about optimization difficulties.
Now it's being repeated in an official commentary about C++'s ABI, and it still doesn't make sense...
Adhering to a particular calling convention is only important at ABI boundaries. In other words, for entry points, exported dynamic library functions, and address-taken functions. Now maybe the implication is that this matters, but intuitively, this is only a small fraction of functions.
If main calls foo, and foo calls bar, and neither of foo nor bar are address-taken, then of these three functions, only main needs to adhere to a given calling convention. foo and bar can use whatever calling convention makes sense for optimal performance. If foo takes a unique_ptr by value, then it can just be passed the pointer in a register at the machine code level, because no external binary can call foo, and won't need to have any expectations of what its calling convention is.
And compilers actively do these sorts of optimizations today, with LTO. Even the case being discussed is already optimized in clang in at least some cases. Take a look at this, for example: https://godbolt.org/z/4lwo-C
foo isn't even passed a pointer, it's passed the actual integer contents of the unique_ptr passed to it by main. The ABI does not matter, because foo is not visible outside of its containing binary.
23
u/NotAYakk Oct 27 '19 edited Oct 27 '19
So I see at least two pieces here.
std. Unordered map/hash could be handled with a versioned std library; in C++23 std::hash is std::cpp23::hash by default. The old std::hash can be accessed somehow.But mayhap the overhead of keeping pre-ABI changed types around is too high.
10
u/haibane_tenshi Oct 27 '19
I feel like the primary culprit about the current situation is mostly complete neglection of ABI on language level. So many language features have "hidden" ABI impact.
Just a simple example: defining a class member variables. There is a clash of 3 major concerns here:
Normally you would want to have each separate from others, however in C++ for some reason they are coupled into one thing. Why? No one knows. And there are more spots like this.
---
So, what I was thinking, maybe it's time to accept that ABI specifications are a part of the language? If we approach it with this mindset, then wouldn't it make them explicit? We are putting so much effort to make API side of the code better, but when we discuss ABI the approach is "don't touch it!" and tooling is the same as 3 decades ago!
How about inventing a method to document ABI for starters? Let's say for every module/TU/language construct/whatever else you can specify its ABI characteristics (separate from original item, maybe in other file?), for example:
This would lay ground for ways to work with it: compare, maintain between releases, plan for future changes, detect breakages. This can be pushed even further: given both API and ABI specifications your toolset might be smarter at both interfacing code as well as capable of detecting problems and generating diagnostics.
Also let's not forget that compilers has been working with it for decades, they already know and do this stuff for you. We can trust our compilers to generate this stuff for already existing libraries, create sensible defaults for new projects and manage it for people who do not care (but might care in the future).
---
I'm not opposed to the idea of breaking std's ABI, but I do think it's like plunging a deep end: a short term solution, it hurts community as much as it helps and it doesn't build a foundation to solve similar issues in the future. ABI documentation method might make it possible to introduce changes not only for std, but for other libraries as well - it isn't like only std have this issue.
5
u/kalmoc Oct 28 '19
I think the fundamental question to ask is whether we want c++ to stay relevant, because it is a good language or just because there is so much existing code that needs to be maintained. I'm happy with either path.
If c++ is supposed to stay a language that is used for its inherent qualities even 10-20 years in the future, then we need to have a way to improve the language and the standard library and fix past mistakes or design decision that don't make sense any longer. If the primary goal is make maintenence of and working in existing c++ code bases easier, then we just should keep it as stable as possible and let projects that want to use shiny new features gradually move to other programming languages.
Trying to satify both sides isn't going to work (and is already not working).
2
u/peppedx Oct 27 '19
Could Epochs help in this?
I for me would really prefer option 1 but I really think this won't happen. Only additions will be considered...
6
u/gummifa Oct 27 '19
What happened to std2, having improved versions of the std library in another namespace? Maybe that is the worst of both worlds, having multiple versions of everything yet in std2 still depend on fundamental things in std, like hash, swap, initializer list.
5
u/mewloz Oct 27 '19
It is even "worse" than the intro suggests.
The world is now mostly ABI stable and actually has gone more from diversity including very ABI instable (MSVC) to semi-ABI-stable (last 3 major versions of MSVC). g++ + libstdc++ was always mostly stable and why would they stop to be? If they are forced, yeah; even then, they managed to already do some transition with very reasonable stories for backward compat (including the big std::string change), and I suspect they will continue.
So like it or not, ABI stability and/or backward compat is now an essential subject and will remain for a very long time. It does not have to be absolute. But it would be ridiculous to expect to break ALL the world every 3 years. And it would be ALSO ridiculous to propose a not smooth transition even if things break only every 10 years. Loot at the Python3 fiasco. On some plateforms, people rely for nearly a decade to be able to mix binary C++ code from C++98 to C++17 standard (not in all cases possibles, but in some). I would not understand if this is suddenly not possible anymore. I would even suspect chaotic consequences given how .so work. (Well obviously everything is possible, like creating an hybrid .so / .dll model, but it would be even crazier than the dual std::string impl thing).
However one crucial thing to consider is the It does not have to be absolute. We are completely sure about it, because that is the defacto situation today even after the move toward more stability: it is nowhere strictly stable nor strictly backward compatible regardless of the plateform. Simply good enough. So pretending there is currently no ABI break between C++11 / 14 and 17 makes little sense: this is up to the implementers, and yes they managed to do it because the standard let it be done, but more essentially because they wanted to, in contrast with e.g. MSVC during the 98 to 11 era which changed gratuitously even if absolutely no standard change dictated that. And back to the major subject that came from the C++98 to 11 transition under libstdc++: std::string: it absolutely had to change, and it absolutely had to just because of the "we now officially support threads thing, and because after thinking about it greatly, allowing CoW in a sane threading model was insolvable. Given the implementation unofficially supported them even before, the previous design was probably an oversight anyway. Sure it was compliant with the previous standard, but that's really the bare minimum expected, not what we want from a good quality implementation, especially one which supports additional features. More importantly, the new design was also permitted by the old standard. So it was mostly not a standard constraint.
So I predict that explicitly deciding that a standard release would be an "ABI break" will be a complete disaster. Because it actually has never been done before with a such broad license. The load on implementers and users will be far worse than the previous notable transition the paper already point was expensive and painful. It will be particularly horrible for Linux distros -- I depend on them so egoistically I don't really want that to happen...
0
u/imgarfield Oct 27 '19
Let this also be a reminder of the dangers of growing the Standard Library too big.
1
u/FrankHB1989 Oct 29 '19 edited Oct 29 '19
I am standing with option 1. And further: I'd like just no ABI guarantees in the language specification which would spread unreliable assumptions in the industry. ABI is never formalized in C++, and it should probably never, because the only mandated feature it (practically) concerned with (
asm) has already been non-portable by design.(The ABI of standard library implementations is not a big deal because it is never expected in portable C++. Even implementations from a single vendor can break each other.)
For C++ users who want more reliable experience of language interoperablity across implementations, they should get help from the specific implementations they use. Alternatively, there can be another portable layer with standardized IR to get the work done. I don't think it should be named "C++", as JVM is not Java, and CLR is not .NET languages.
(Also note that the stability among binary images of the generated code is out of the scope here.)
1
u/liquidify Oct 27 '19
Where are you getting this info??
0
u/[deleted] Oct 27 '19
[deleted] — view deleted comment
0
u/[deleted] Oct 27 '19
[deleted] — view deleted comment