build: Add --enable-c++20 option #24169

pull MarcoFalke wants to merge 4 commits into bitcoin:master from MarcoFalke:2201-ciCpp20 changing 6 files +39 −8
  1. MarcoFalke commented at 7:04 PM on January 26, 2022: member

    This is for CI and devs only and doesn't change that C++17 is the standard we are currently using. The option --enable-c++20 allows CI to check that the C++17 code in the repo is also valid C++20. (There are some cases where valid C++17 doesn't compile under C++20).

    Also, it allows developers to easily play with C++20 in the codebase.

  2. MarcoFalke added the label Build system on Jan 26, 2022
  3. MarcoFalke added this to the milestone Future on Jan 26, 2022
  4. PastaPastaPasta commented at 8:28 AM on January 27, 2022: contributor

    You may or may not be interested in one of my PRs to dash that did this https://github.com/dashpay/dash/pull/4600

    I was planning on doing the equivalent here, but didn't want to until we could merge #23340 which if I recall correctly is required to fix cxx20 builds

  5. jonatack commented at 4:34 PM on January 27, 2022: contributor

    Concept ACK

  6. luke-jr cross-referenced this on Jan 31, 2022 from issue Autotools dependency version undocumented by luke-jr
  7. fanquake commented at 10:02 AM on February 11, 2022: member

    Support for c++20 has now been merged into the ax_cxx_compile_stdcxx.m4 macro upstream: https://github.com/autoconf-archive/autoconf-archive/pull/244.

  8. MarcoFalke force-pushed on Feb 11, 2022
  9. MarcoFalke renamed this:
    [WIP DRAFT] build: Add --enable-c++20 option
    build: Add --enable-c++20 option
    on Feb 11, 2022
  10. MarcoFalke marked this as ready for review on Feb 11, 2022
  11. MarcoFalke removed this from the milestone Future on Feb 11, 2022
  12. MarcoFalke marked this as a draft on Feb 11, 2022
  13. DrahtBot cross-referenced this on Feb 15, 2022 from issue util: Revert back `MoveFileExW` call for MinGW-w64 by hebasto
  14. DrahtBot commented at 8:01 AM on February 15, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  15. DrahtBot cross-referenced this on Feb 17, 2022 from issue util: Work around libstdc++ create_directories issue by laanwj
  16. DrahtBot added the label Needs rebase on Feb 17, 2022
  17. MarcoFalke force-pushed on Feb 17, 2022
  18. MarcoFalke force-pushed on Feb 17, 2022
  19. MarcoFalke force-pushed on Feb 17, 2022
  20. MarcoFalke cross-referenced this on Feb 17, 2022 from issue bench: Avoid deprecated use of volatile += by MarcoFalke
  21. DrahtBot removed the label Needs rebase on Feb 17, 2022
  22. MarcoFalke force-pushed on Feb 21, 2022
  23. MarcoFalke force-pushed on Feb 21, 2022
  24. MarcoFalke force-pushed on Feb 21, 2022
  25. DrahtBot cross-referenced this on Feb 21, 2022 from issue test: Fix Wambiguous-reversed-operator compiler warnings by MarcoFalke
  26. DrahtBot cross-referenced this on Feb 21, 2022 from issue refactor: Remove confusing P1008R1 violation in ATMPArgs by MarcoFalke
  27. MarcoFalke force-pushed on Feb 23, 2022
  28. MarcoFalke force-pushed on Feb 23, 2022
  29. fanquake commented at 11:49 AM on February 23, 2022: member

    If you want to split the macro update off, happy to merge that earlier, given it's a mechanical change.

  30. MarcoFalke force-pushed on Mar 2, 2022
  31. MarcoFalke cross-referenced this on Mar 2, 2022 from issue build: update ax_cxx_compile_stdcxx to serial 14 by MarcoFalke
  32. felipsoarez commented at 4:34 PM on March 2, 2022: none

    utACK

  33. fanquake referenced this in commit cc70f65d21 on Mar 4, 2022
  34. sidhujag referenced this in commit b8252ff751 on Mar 5, 2022
  35. MarcoFalke force-pushed on Mar 7, 2022
  36. MarcoFalke force-pushed on Mar 7, 2022
  37. MarcoFalke force-pushed on Mar 7, 2022
  38. MarcoFalke cross-referenced this on Mar 7, 2022 from issue Add missing fs::u8path wrap by MarcoFalke
  39. MarcoFalke marked this as ready for review on Mar 10, 2022
  40. MarcoFalke force-pushed on Mar 10, 2022
  41. MarcoFalke cross-referenced this on Mar 10, 2022 from issue Discussion: Upgrading to C++20 by MarcoFalke
  42. fanquake commented at 10:56 AM on March 11, 2022: member

    Concept ACK. I think having the developer option, and carrying some number of code changes to support c++20 compilation is fine, but it's going to be a long time before we can make it a requirement.

  43. MarcoFalke force-pushed on Mar 17, 2022
  44. MarcoFalke force-pushed on Mar 17, 2022
  45. MarcoFalke commented at 1:03 PM on March 17, 2022: member

    Force pushed to address feedback: #24531 (review)

  46. in src/fs.h:54 in fa73ff980e outdated
      50 | @@ -51,12 +51,26 @@ class path : public std::filesystem::path
      51 |      // Disallow std::string conversion method to avoid locale-dependent encoding on windows.
      52 |      std::string string() const = delete;
      53 |  
      54 | +    std::string u8string() const
    


    fanquake commented at 1:15 PM on March 17, 2022:

    @ryanofsky or @hebasto you might be interested in the fs changes here?

  47. MarcoFalke force-pushed on Mar 17, 2022
  48. MarcoFalke force-pushed on Mar 17, 2022
  49. ryanofsky approved
  50. ryanofsky commented at 8:08 PM on March 17, 2022: contributor

    Code review ACK fa442133f1ea37edb7c769590da9592b541fce6c. All these changes look safe to me, and it is definitely better if the code is tested with c++20 and compiles without changes.

    A lot of changes are made in the PR without an explanation about the reason, though. Like the enum-enum warning change and scheduler lambda change. Ideally the changes would be broken up more, with one change per commit, and the commit messages would explain the reasons behind the changes, or at least give hints.

  51. MarcoFalke force-pushed on Mar 17, 2022
  52. MarcoFalke commented at 8:56 PM on March 17, 2022: member

    Thx, done. (No code changes)

  53. ryanofsky approved
  54. ryanofsky commented at 9:02 PM on March 17, 2022: contributor

    Code review ACK fab63ca14298d37022e23d3e9747bc4bf94121c9. Thanks for the descriptions, I understand this much better now!

  55. fanquake commented at 10:54 AM on March 18, 2022: member

    @theuni you might also be interested here

  56. theStack approved
  57. theStack commented at 5:34 PM on March 19, 2022: contributor

    Concept and code-review ACK fab63ca14298d37022e23d3e9747bc4bf94121c9 :two: :zero:

    Tested --enable-c++20 compilation with clang 11.1.0 (OpenBSD 7.0).

  58. hebasto commented at 7:22 AM on March 21, 2022: member

    Concept ACK.

  59. hebasto cross-referenced this on Mar 21, 2022 from issue qt: Avoid potential -Wdeprecated-enum-enum-conversion warnings by hebasto
  60. hebasto commented at 10:21 AM on March 21, 2022: member

    Approach ACK fab63ca14298d37022e23d3e9747bc4bf94121c9, except for the fa08f8b8cd4eb13cc5904d33e027f6c485b9f4b1 "Set -Wno-deprecated-enum-enum-conversion" commit. An alternative has been suggested in #24624.

  61. MarcoFalke commented at 8:10 AM on March 22, 2022: member

    I'd say the two pull requests are mostly orthogonal. If one is merged before the other, the one merged second can drop the temporary -Wno commit.

  62. hebasto approved
  63. hebasto commented at 9:56 AM on March 22, 2022: member

    ACK fab63ca14298d37022e23d3e9747bc4bf94121c9

    I'd say the two pull requests are mostly orthogonal. If one is merged before the other, the one merged second can drop the temporary -Wno commit.

    Agree.

  64. MarcoFalke referenced this in commit f05cf59d91 on Mar 22, 2022
  65. MarcoFalke commented at 12:44 PM on March 22, 2022: member

    Removed a commit. Should be trivial to re-ACK.

  66. MarcoFalke force-pushed on Mar 22, 2022
  67. hebasto approved
  68. hebasto commented at 1:34 PM on March 22, 2022: member

    ~re-ACK fa6bc3b2ccb7386ed496dd8be6b748e95c28b957~

    CI failure?

  69. MarcoFalke commented at 3:39 PM on March 22, 2022: member

    <strike>Please review #24641 first, while this fails to compile.

  70. MarcoFalke marked this as a draft on Mar 22, 2022
  71. scheduler: Capture ‘this’ explicitly in lambda
    Without the changes, g++ will warn to compile under C++20:
    
    scheduler.cpp:114:21: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
      114 |     scheduleFromNow([=] { Repeat(*this, f, delta); }, delta);
          |                     ^
    scheduler.cpp:114:21: note: add explicit ‘this’ or ‘*this’ capture
    fae2220f4e
  72. Make fs.h C++20 compliant
    Without the changes, the file will fail to compile under C++20 because
    char8_t can not be converted to char implicitly.
    fabb7c4ba6
  73. MarcoFalke marked this as ready for review on Mar 24, 2022
  74. Add CSerializedNetMsg::Copy() helper
    This makes code that uses the helper less verbose.
    
    Moreover, this makes net_processing C++20 compliant. Otherwise, it would
    lead to a compile error (see below). C++20 disables aggregate
    initialization when any constructor is declared. See
    http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1008r1.pdf
    
    net_processing.cpp:1627:42: error: no matching constructor for initialization of 'CSerializedNetMsg'
                m_connman.PushMessage(pnode, CSerializedNetMsg{ser_cmpctblock.data, ser_cmpctblock.m_type});
                                             ^                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fae679065e
  75. build: Add --enable-c++20 option 999982b06c
  76. MarcoFalke force-pushed on Mar 24, 2022
  77. ryanofsky approved
  78. ryanofsky commented at 12:20 PM on March 24, 2022: contributor

    Code review ACK 999982b06ce1d1280e5ce48f9253c6c536f41a12. Since last review was rebased, and enum-conversion change was dropped, and CSerializedNetMsg copy workaround was added

  79. MarcoFalke cross-referenced this on Mar 24, 2022 from issue Re-enable C++20 aggregate initialization for CSerializedNetMsg by MarcoFalke
  80. fanquake approved
  81. fanquake commented at 1:00 PM on March 24, 2022: member

    utACK 999982b06ce1d1280e5ce48f9253c6c536f41a12

  82. fanquake merged this on Mar 24, 2022
  83. fanquake closed this on Mar 24, 2022

  84. MarcoFalke deleted the branch on Mar 24, 2022
  85. Sjors cross-referenced this on Mar 26, 2022 from issue u8path<std::string> deprecation with libc++ and c++20 by Sjors
  86. Sjors commented at 9:26 AM on March 26, 2022: member

    Nice! Though macOS trips over a deprecation (warning), see #24682.

  87. sidhujag referenced this in commit aad46d4291 on Apr 2, 2022
  88. bitcoin locked this on Mar 26, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:53 UTC