cmake: check for Cap’n Proto / Clang / C++20 incompatibility #205

pull willcl-ark wants to merge 2 commits into bitcoin-core:master from willcl-ark:clang-capnp-incompat changing 1 files +50 −5
  1. willcl-ark commented at 10:13 am on September 3, 2025: member

    Cap’n Proto 0.9.x and 0.10.x are incompatible with Clang 16+ when using C++20 due to P2468R2 implementation. This was fixed in Cap’n Proto 1.0+.

    Generate a helpful error when these combinations are detected.

    See: #199 for more context

  2. DrahtBot commented at 10:14 am on September 3, 2025: none

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK ryanofsky
    Concept ACK hebasto

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. willcl-ark commented at 10:14 am on September 3, 2025: member
    I’ve left direct reference to Bitcoin Core in the error message as, although this library is pretty generic, it seems that Bitcoin Core is the primary (or perhaps only) user, and therefore worth including for the tip on disabling IPC to bypass.
  4. in CMakeLists.txt:54 in ee5e284cca outdated
    49+    "Cap'n Proto ${CapnProto_VERSION} is incompatible with Clang ${CMAKE_CXX_COMPILER_VERSION} when using C++20.\n"
    50+    "To resolve this issue, choose one of the following:\n"
    51+    "  1. Upgrade to Cap'n Proto version 1.0 or newer (recommended)\n"
    52+    "  2. Downgrade to Cap'n Proto version 0.8 or earlier\n"
    53+    "  3. Use GCC instead of Clang\n"
    54+    "  4. For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n"
    


    Sjors commented at 10:26 am on September 3, 2025:
    This wording seems fine.
  5. ryanofsky approved
  6. ryanofsky commented at 10:06 pm on September 3, 2025: collaborator

    Code review ACK ee5e284cca563eb43ec3587d114586865db70b43. This seems like it should be a helpful change.

    The approach suggested https://github.com/bitcoin/bitcoin/pull/33290#issuecomment-3249470528 could potentially be used to avoid needing to mention the bitcoin core option here, and could be a followup

  7. ryanofsky commented at 10:07 pm on September 3, 2025: collaborator
    LLM linter also suggested some reasonable edits #205 (comment)
  8. in CMakeLists.txt:36 in ee5e284cca outdated
    35@@ -36,6 +36,25 @@ if(CapnProto_VERSION STREQUAL "0.7.0"
    36   ")
    


    maflcko commented at 6:55 am on September 4, 2025:
    just a nit: Maybe the common part of the error message could be shared and also be shown here?

    willcl-ark commented at 7:01 am on September 4, 2025:

    Do you mean this part?

    0/usr/include/capnp/blob.h:176:74: error: invalid operands to binary expression ('const char *' and 'kj::StringPtr')
    

    maflcko commented at 7:07 am on September 4, 2025:

    Sorry for being unclear, I meant to append:

    0    "To resolve this issue, choose one of the following:\n"
    1    "  1. Upgrade your version of Cap'n Proto to a patched minor version (0.7.1, 0.8.1, 0.9.2, 0.10.3, or any later major version)\n"
    2    "  2. For Bitcoin Core compilation, build with -DENABLE_IPC=OFF to disable multiprocess support\n"
    
  9. in CMakeLists.txt:52 in ee5e284cca outdated
    47+   (CMAKE_CXX_STANDARD EQUAL 20))
    48+  message(FATAL_ERROR
    49+    "Cap'n Proto ${CapnProto_VERSION} is incompatible with Clang ${CMAKE_CXX_COMPILER_VERSION} when using C++20.\n"
    50+    "To resolve this issue, choose one of the following:\n"
    51+    "  1. Upgrade to Cap'n Proto version 1.0 or newer (recommended)\n"
    52+    "  2. Downgrade to Cap'n Proto version 0.8 or earlier\n"
    


    fanquake commented at 9:23 am on September 4, 2025:

    Downgrade to Cap’n Proto version 0.8 or earlier

    I think this should say 0.8.1, so it’s clear we aren’t suggesting to downgrade to 0.8.0, which wont work, given the check for CVEs above. Although I think ideally, we wouldn’t suggest downgrading at all.

  10. willcl-ark force-pushed on Sep 4, 2025
  11. willcl-ark commented at 3:12 pm on September 4, 2025: member

    OK, I am a bit of a cmake language noob, so apologies in advance if I’ve butchered this, but I’ve tried to share the common error message in 197aef2e2b4a4dd35ffa2bf5783ba6fe636ea48d to along with @fanquake’s suggestion of not recommending downgrading (which seems sensible).

    To avoid also the situation where we have two seperate checks which a user could fail sequentially (but only after installing a second version of capnproto!), I have tried to merge them into a single check, with logic for each check type.

    This way a user should only ever fail on this version check once, and should be shown appropriate options.

  12. ryanofsky commented at 3:16 pm on September 4, 2025: collaborator

    @willcl-ark I started to look at 197aef2e2b4a4dd35ffa2bf5783ba6fe636ea48d which seems like a nice approach.

    Any interested in extending it to replace https://github.com/bitcoin/bitcoin/pull/33290? It would be great to show a better error message when find_package(CapnProto) fails here and it looks like the new code you’ve written could be easily extended to do it.

    I think you would just need to replace

    0find_package(CapnProto 0.7 REQUIRED NO_MODULE)
    

    with

    0find_package(CapnProto 0.7 QUIET NO_MODULE)
    1if (NOT CapnProto_FOUND)
    2   # ... custom handling here ...
    3endif()
    
  13. ryanofsky approved
  14. ryanofsky commented at 3:28 pm on September 4, 2025: collaborator
    Code review ACK ee5e284cca563eb43ec3587d114586865db70b43. New code is clean and pretty straightforward and I really like the approach because it clearly spells out the solutions instead of requiring users and developers to look for them.
  15. cmake: check for Cap'n Proto / Clang / C++20 incompatibility
    Cap'n Proto 0.9.x and 0.10.x are incompatible with Clang 16+ when using C++20 due to P2468R2 implementation.
    This was fixed in Cap'n Proto 1.0+.
    
    Generate a helpful error when these combinations are detected.
    
    See: https://github.com/bitcoin-core/libmultiprocess/issues/199
    d314057775
  16. cmake: capnproto pkg missing helpful error
    Add a helpful error when we fail to find the package at all.
    657d80622f
  17. willcl-ark force-pushed on Sep 4, 2025
  18. willcl-ark commented at 6:34 pm on September 4, 2025: member

    @ryanofsky I added the suggested check here.

    I did look at having a single giant “check package, then version compatibility” section (i.e. extending what is there currently), but the code is much cleaner using a specific

    0find_package(CapnProto 0.7 QUIET NO_MODULE)
    1 if(NOT CapnProto_FOUND)
    2   message(FATAL_ERROR
    

    …even if that means we repeat a string or two.

  19. Sjors commented at 7:36 am on September 5, 2025: member

    I tested 657d80622f81ba3258780b2157a2771195ee4988 by updating the subtree in Bitcoin Core, and uninstalling capnp:

    0CMake Error at src/ipc/libmultiprocess/CMakeLists.txt:18 (message):
    1  Cap'n Proto is required but was not found.
    2
    3  To resolve, choose one of the following:
    4
    5    - Install Cap'n Proto (version 1.0+ recommended)
    6    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support
    

    That’s quite nice.

  20. ryanofsky commented at 1:16 pm on September 5, 2025: collaborator
    Might make sense to update PR title and description to reflect broader scope of this change now
  21. ryanofsky commented at 1:36 pm on September 5, 2025: collaborator

    Testing 657d80622f81ba3258780b2157a2771195ee4988 with different settings in olddeps.bash and it seems to work well.

     0$ rm -rvf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
     1[...]
     2CMake Error at CMakeLists.txt:76 (message):
     3  The version of Cap'n Proto detected: 0.9.0 has known compatibility issues:
     4
     5  - CVE-2022-46149 security vulnerability (details:
     6  https://github.com/advisories/GHSA-qqff-4vw4-f6hx)
     7
     8  To resolve, choose one of the following:
     9
    10    - Upgrade to Cap'n Proto version 1.0 or newer (recommended)
    11    - Upgrade to a patched minor version (0.7.1, 0.8.1, 0.9.2, 0.10.3, or later)
    12    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support
    
     0$ rm -rf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
     1[...]
     2CMake Error at CMakeLists.txt:76 (message):
     3  The version of Cap'n Proto detected: 0.9.0 has known compatibility issues:
     4
     5  - CVE-2022-46149 security vulnerability (details:
     6  https://github.com/advisories/GHSA-qqff-4vw4-f6hx)
     7
     8  - Incompatible with Clang 20.1.5 when using C++20
     9
    10  To resolve, choose one of the following:
    11
    12    - Upgrade to Cap'n Proto version 1.0 or newer (recommended)
    13    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support
    
     0$ rm -rf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
     1[...]
     2CMake Error at CMakeLists.txt:76 (message):
     3  The version of Cap'n Proto detected: 0.9.2 has known compatibility issues:
     4
     5  - Incompatible with Clang 20.1.5 when using C++20
     6
     7  To resolve, choose one of the following:
     8
     9    - Upgrade to Cap'n Proto version 1.0 or newer (recommended)
    10    - Use GCC instead of Clang
    11    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support
    
    0$ rm -rf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
    1[...]
    2CMake Error at CMakeLists.txt:18 (message):
    3  Cap'n Proto is required but was not found.
    4
    5  To resolve, choose one of the following:
    6
    7    - Install Cap'n Proto (version 1.0+ recommended)
    8    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support
    
  22. in CMakeLists.txt:66 in d314057775 outdated
    61+    string(APPEND RESOLUTION_OPTIONS "  - Upgrade to a patched minor version (0.7.1, 0.8.1, 0.9.2, 0.10.3, or later)\n")
    62+  elseif(CAPNPROTO_CLANG_INCOMPATIBLE AND NOT CAPNPROTO_CVE_AFFECTED)
    63+    string(APPEND RESOLUTION_OPTIONS "  - Use GCC instead of Clang\n")
    64+  endif()
    65+
    66+  string(APPEND RESOLUTION_OPTIONS "  - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n")
    


    ryanofsky commented at 1:47 pm on September 5, 2025:

    In commit “cmake: check for Cap’n Proto / Clang / C++20 incompatibility” (d314057775a552391b439f164fd23e8b7458cbeb)

    This might be more readable with a comma after “compilation”. Also I think the “if you do not need IPC functionality” phrasing from https://github.com/bitcoin/bitcoin/pull/33290 might make the effects of this easier to understand than “to disable multiprocess support”. Maybe my suggestion would be to change this to something like “If building Bitcoin Core and you do not need IPC functionality, configure cmake with -DENABLE_IPC=OFF” here in and in the next commit.

    This also seems fine for now though, and later we can drop if “If building Bitcoin Core” part by supporting a MP_SUBPROJECT_ERROR variable as suggested in the other issue.

  23. ryanofsky approved
  24. ryanofsky commented at 1:52 pm on September 5, 2025: collaborator
    Code review ACK 657d80622f81ba3258780b2157a2771195ee4988. Thanks for these changes! I think they should very helpful and prevent unnecessary confusion.
  25. in CMakeLists.txt:24 in 657d80622f
    20+     "Cap'n Proto is required but was not found.\n"
    21+     "To resolve, choose one of the following:\n"
    22+     "  - Install Cap'n Proto (version 1.0+ recommended)\n"
    23+     "  - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n"
    24+   )
    25+ endif()
    


    hebasto commented at 3:09 pm on September 5, 2025:
    mis-indentation?
  26. hebasto commented at 3:09 pm on September 5, 2025: member

    Concept ACK.

    As a follow-up, all code related to handling the CapnProto package could be encapsulated in a cmake/FindCapnProto.cmake module.

  27. ryanofsky commented at 7:42 pm on September 5, 2025: collaborator
    I think I’ll go ahead and merge this now, and we can iterate and improve in future PRs. There are good ideas above for fixing up an indent, changing wording, and moving code to a module. There is also the MP_SUBPROJECT_ERROR idea from https://github.com/bitcoin/bitcoin/pull/33290#issuecomment-3249470528 and possibility of extending this to detect an incompatible netbsd package from #196 (comment)
  28. ryanofsky merged this on Sep 5, 2025
  29. ryanofsky closed this on Sep 5, 2025

  30. ryanofsky referenced this in commit a334bbe9b7 on Sep 5, 2025
  31. fanquake referenced this in commit 9c6fa07b12 on Sep 8, 2025
  32. Sjors referenced this in commit 132621fc01 on Sep 23, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-04 19:30 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me