Skip to content

Determine ABI stability timeline for C++20 #1814

Closed

Description

We're in a novel situation: never before have we completed a Standard so rapidly. Adding to this concern, <format> is both ABI-sensitive and performance-sensitive, and WG21 is expected to mandate ABI-breaking changes soon.

(C++17 was different; we finished <charconv> in 2019 having completed all other features much earlier, and while it was performance-sensitive, we had time to extensively test and tune it, and its function-oriented nature means that it has no ABI concerns and can be revised in the future.)

We were initially planning to declare ABI stability when finishing C++20 (along with the addition of /std:c++20 as distinct from the always-experimental /std:c++latest), to align with the user expectation that non-experimental features supported for production use are also ABI stable. However, if this locks us into an implementation that can't keep up with retroactive changes to C++20, or freezes an implementation before it's had a chance for significant performance tuning, that will ultimately be harmful to users.

We should consider asking our bosses and boss-like entities for a change of plans: we will still declare C++20 to be feature-complete and ready for production use when we're done (as indicated by the feature-test macros), but we can announce that its ABI will potentially change for some defined period of time (3 months, 6 months, 1 year?) or number of releases (e.g. Dev17 17.x for some specific value of X). This will have no effect for /std:c++14 and /std:c++17 users, and we can expect that, at least initially, the population of /std:c++20 users will be the most eager upgraders for whom rebuilding the world is the least onerous.

Additionally, to mitigate mix-and-match problems, we could add a #pragma detect_mismatch to <format> right now, allowing us to revise it in the future and have the linker detect any OBJ/static LIB mixing.


Update: We arrived at a plan, see the comment below.

Activity

  1. added
    high priority
    decision needed
    format
    on Apr 9, 2021
  2. sylveon commented on Apr 9, 2021

    @sylveon
    Contributor

    I personally think something like keeping the ABI unstable until the non-preview release of Dev17 would be a good idea.

    Freezing it now will lead to major differences between standard libraries because the new changes to the standard library require ABI breakage, meaning some libraries and consumers might be reluctant to adopting C++20 because of inconsistency between compilers/standard library implementations, and this will ultimately be detrimental to the MSVC ecosystem.

  3. timsong-cpp commented on Apr 9, 2021

    @timsong-cpp
    Contributor

    As Barry Revzin (@brevzin) noted, there are three Ranges papers in flight with ABI implications as well (split, default construction, and join).

  4. jovibor commented on Apr 9, 2021

    @jovibor
    Contributor

    We should consider asking our bosses and boss-like entities for a change of plans: we will still declare C++20 to be feature-complete and ready for production use when we're done (as indicated by the feature-test macros), but we can announce that its ABI will potentially change for some defined period of time

    Nothing but hoping for your bosses' good sanity😎

  5. hatcat commented on Apr 9, 2021

    @hatcat
    Contributor

    We're in a novel situation: never before have we completed a Standard so rapidly.

    I have high hopes for C++23...

  6. miscco commented on Apr 9, 2021

    @miscco
    Contributor

    We're in a novel situation: never before have we completed a Standard so rapidly.

    I have high hopes for C++23...

    Will be finished in 22

  7. Lectem commented on Apr 9, 2021

    @Lectem

    If this can help take a decision or convince anybody:
    Out of the 5 last clients I worked with, 4 said they stopped using some of STL types due to either runtime performance or compile time performance, that could be fixed by changing ABI such as is done in vNext. I'm thinking mainly about debug iterators and regexp.
    If std::format isn't fast enough (to compile or at runtime) compared to fmt::format, I'm afraid this will only keep fueling arguments against using the STL (and std library in general, whatever implementation it is).

    While I am sympathetic to having some kind of ABI stability, I don't think "rushing" a release just to be able to put the "c++ latest compliant" stamp is a good idea if QoI improvements can't follow due to the same ABI stability.
    An upgrade path must be kept, or some rupture planned to finally take this opportunity to break ABI, just as was done in the past.

  8. MikeGitb commented on Apr 10, 2021

    @MikeGitb

    Personally, I'm not even that concerned about performance, exactly because there is fmt and the STL is rarely the best performing solution for a given problem anyway.

    What I do care about though is correctness and portability. Effectively locking down the ABI before having any significant user contact, real-world testing and (ideally) a second implementation to compare against seems a very risky choice for something so fundamental - especially when people are still trying to "fix" the standard itself.

  9. jovibor commented on Apr 10, 2021

    @jovibor
    Contributor

    Personally, I'm not even that concerned about performance, exactly because there is fmt and the STL is rarely the best performing solution for a given problem anyway.

    By this logic, there is no value in using STL at all, because every piece of it has more performant counterpart somewhere anyway. The only reason would be that it's available out-of-the box.

    If the performance question is not about years of researching or some rocket science, but only delaying ABI locking by month or so I would definitely consider it as the way to go.

  10. MikeGitb commented on Apr 10, 2021

    @MikeGitb

    By this logic, there is no value in using STL at all, because every piece of it has more performant counterpart somewhere anyway. The only reason would be that it's available out-of-the box.

    That's pretty much the way it is. Yes. Except for

    there is no value in using STL at all

    Just because there is something faster somewhere doesn't mean the STL doesn't have value. Using 3rd party dependencies comes with it's own costs and even in c++ code, performance is not the only relevant metric.

    But that gets off topic.

  11. vitaut commented on Apr 12, 2021

    @vitaut
    Contributor

    Personally, I'm not even that concerned about performance, exactly because there is fmt and the STL is rarely the best performing solution for a given problem anyway.

    It's more complicated in case of fmt/std::format compared to, say, containers because here we have the formatter extension point. It would be really unfortunate if we ended up in the world with two sets of incompatible formatter specializations and resulting interoperability problems. I think it's worth taking time and addressing performance differences before ABI is frozen or at least making sure that they can be addressed in the future without ABI breakage.

  12. MikeGitb commented on Apr 13, 2021

    @MikeGitb

    It's more complicated in case of fmt/std::format compared to, say, containers because here we have the formatter extension point. It would be really unfortunate if we ended up in the world with two sets of incompatible formatter specializations and resulting interoperability problems.

    So far we have rarely been using a library provided operator<< for printing (except for printf debugging or quick prototyping), because most of the time we had our own format requirements anyway. In a similar fashoin, I'm not sure how much I'm going to use a 3rd party fmt/std::formatter specialization in a context, where performance matters. Also, performance aside, I expect fmt to stay ahead of std::format feature and compatibility wise for the forseable future, so we'll probably have to live with this duality for quite some time anyway.

    Anyway, as I wrote previously: I'm also very much against locking down the ABI right away - just that performance isn't my primary reason for that.

  13. vitaut commented on Apr 13, 2021

    @vitaut
    Contributor

    far we have rarely been using a library provided operator<< for printing

    You maybe, others have been using them extensively.

    we'll probably have to live with this duality for quite some time anyway.

    The important thing is the long term, not the next few years. In the long term I expect fmt::formatter to go away.

  14. 42 remaining items

  15. added a commit that references this issue on Dec 11, 2021
  16. added a commit that references this issue on Feb 4, 2022
    371f91b
  17. added a commit that references this issue on Feb 7, 2022
    53d4f93
  18. added
    fixed
    on Feb 7, 2022
  19. CaseyCarter commented on Feb 7, 2022

    @CaseyCarter
    Contributor

    FYI, I've closed this issue despite that there's still work to be done to backport <ranges> and <format> to VS 2019 16.11, because all of the work that will take place in this repository is now complete.

  20. SamVanheer commented on Feb 11, 2022

    @SamVanheer

    Since this issue is closed, is #2492 the issue to keep an eye on for the backporting work?

  21. GF-Huang commented on May 3, 2022

    @GF-Huang

    Why I can't use std::format in VS2022? Namespace std has no member format!!!

    image

    image

  22. sylveon commented on May 3, 2022

    @sylveon
    Contributor

    std::format under /std:c++20 is available in VS 17.2. For now, 17.2 is in preview. It should release to the stable branch at some point.

  23. JonSuper commented on May 20, 2022

    @JonSuper

    Why I can't use std::format in VS2022? Namespace std has no member format!!!

    image

    image

    需要 VS 2019 16.11.14 or VS 2022 17.2 above

  24. StephanTLavavej commented on May 22, 2022

    @StephanTLavavej
    MemberAuthor

    Maxer (@JonSuper) It should be present in those versions. Are you sure you're looking at the properties for the configuration that you're actually building? I recommend looking at the build log and verifying whether /std:c++20 is on the command line.

    You can also inspect the STL's macros to check its version and Standard mode. Include <version> and test _MSVC_STL_UPDATE - it should be exactly 202105L for VS 2019 16.11.14 or any later patch, and it should be 202203L or greater for VS 2022 17.2 or greater. Finally, after including <version>, you can inspect _HAS_CXX20 which will be defined to 1 if the STL believes that it's in C++20 mode (otherwise it will be 0).

    Hopefully this should allow you to track down whether you're using an unexpected version or an unexpected compiler option.

  25. JonSuper commented on May 24, 2022

    @JonSuper

    Maxer (@JonSuper) It should be present in those versions. Are you sure you're looking at the properties for the configuration that you're actually building? I recommend looking at the build log and verifying whether /std:c++20 is on the command line.

    You can also inspect the STL's macros to check its version and Standard mode. Include <version> and test _MSVC_STL_UPDATE - it should be exactly 202105L for VS 2019 16.11.14 or any later patch, and it should be 202203L or greater for VS 2022 17.2 or greater. Finally, after including <version>, you can inspect _HAS_CXX20 which will be defined to 1 if the STL believes that it's in C++20 mode (otherwise it will be 0).

    Hopefully this should allow you to track down whether you're using an unexpected version or an unexpected compiler option.

    image
    @StephanTLavavej
    It will compiled fail while using VS 2022 17.2 with Visual Studio 2019 (v142) Toolset
    the yvals_core.h here :

    #if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395 and GH-1814
    #define __cpp_lib_format 201907L
    #endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

    but using VS 2019 16.11.15 with Visual Studio 2019 (v142) Toolset is OK

  26. StephanTLavavej commented on May 25, 2022

    @StephanTLavavej
    MemberAuthor

    Ah, then the issue is that the VS 2022 IDE's selectable option of the VS 2019 v142 toolset hasn't been updated to the 16.11.14 or later bits. I believe this will happen at some point but I don't have an ETA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedformathigh priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions