Skip to content

Conversation

willcl-ark
Copy link
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

@DrahtBot
Copy link

DrahtBot commented Sep 3, 2025

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.

@willcl-ark
Copy link
Member Author

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.

Copy link
Collaborator

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

The approach suggested bitcoin/bitcoin#33290 (comment) could potentially be used to avoid needing to mention the bitcoin core option here, and could be a followup

@ryanofsky
Copy link
Collaborator

LLM linter also suggested some reasonable edits #205 (comment)

@willcl-ark
Copy link
Member Author

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 197aef2 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.

@ryanofsky
Copy link
Collaborator

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

Any interested in extending it to replace bitcoin/bitcoin#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

find_package(CapnProto 0.7 REQUIRED NO_MODULE)

with

find_package(CapnProto 0.7 QUIET NO_MODULE)
if (NOT CapnProto_FOUND)
   # ... custom handling here ...
endif()

Copy link
Collaborator

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK ee5e284. 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.

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: bitcoin-core#199
Add a helpful error when we fail to find the package at all.
@willcl-ark
Copy link
Member Author

@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

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

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

@Sjors
Copy link
Member

Sjors commented Sep 5, 2025

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

CMake Error at src/ipc/libmultiprocess/CMakeLists.txt:18 (message):
  Cap'n Proto is required but was not found.

  To resolve, choose one of the following:

    - Install Cap'n Proto (version 1.0+ recommended)
    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support

That's quite nice.

@ryanofsky
Copy link
Collaborator

Might make sense to update PR title and description to reflect broader scope of this change now

@ryanofsky
Copy link
Collaborator

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

setting 0.9.0 in olddeps.bash warns about CVE and suggests upgrading to major or minor version or disabling

$ rm -rvf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
[...]
CMake Error at CMakeLists.txt:76 (message):
  The version of Cap'n Proto detected: 0.9.0 has known compatibility issues:

  - CVE-2022-46149 security vulnerability (details:
  https://github.com/advisories/GHSA-qqff-4vw4-f6hx)

  To resolve, choose one of the following:

    - Upgrade to Cap'n Proto version 1.0 or newer (recommended)
    - Upgrade to a patched minor version (0.7.1, 0.8.1, 0.9.2, 0.10.3, or later)
    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support

setting 0.9.0 in and export CXX=clang++ in olddeps.bash suggests upgrading to major version or disabling

$ rm -rf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
[...]
CMake Error at CMakeLists.txt:76 (message):
  The version of Cap'n Proto detected: 0.9.0 has known compatibility issues:

  - CVE-2022-46149 security vulnerability (details:
  https://github.com/advisories/GHSA-qqff-4vw4-f6hx)

  - Incompatible with Clang 20.1.5 when using C++20

  To resolve, choose one of the following:

    - Upgrade to Cap'n Proto version 1.0 or newer (recommended)
    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support

setting 0.9.2 in and export CXX=clang++ in olddeps.bash suggests using gcc or updating to major version or disabling

$ rm -rf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
[...]
CMake Error at CMakeLists.txt:76 (message):
  The version of Cap'n Proto detected: 0.9.2 has known compatibility issues:

  - Incompatible with Clang 20.1.5 when using C++20

  To resolve, choose one of the following:

    - Upgrade to Cap'n Proto version 1.0 or newer (recommended)
    - Use GCC instead of Clang
    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support

commenting out capnproto input in shell.nix suggests installing cap'n proto or disabling

$ rm -rf build-olddeps; CI_CONFIG=ci/configs/olddeps.bash ci/scripts/run.sh
[...]
CMake Error at CMakeLists.txt:18 (message):
  Cap'n Proto is required but was not found.

  To resolve, choose one of the following:

    - Install Cap'n Proto (version 1.0+ recommended)
    - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support

Copy link
Collaborator

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 657d806. Thanks for these changes! I think they should very helpful and prevent unnecessary confusion.

string(APPEND RESOLUTION_OPTIONS " - Use GCC instead of Clang\n")
endif()

string(APPEND RESOLUTION_OPTIONS " - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "cmake: check for Cap'n Proto / Clang / C++20 incompatibility" (d314057)

This might be more readable with a comma after "compilation". Also I think the "if you do not need IPC functionality" phrasing from bitcoin/bitcoin#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.

@ryanofsky ryanofsky mentioned this pull request Sep 5, 2025
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

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

Comment on lines +17 to +24
if(NOT CapnProto_FOUND)
message(FATAL_ERROR
"Cap'n Proto is required but was not found.\n"
"To resolve, choose one of the following:\n"
" - Install Cap'n Proto (version 1.0+ recommended)\n"
" - For Bitcoin Core compilation build with -DENABLE_IPC=OFF to disable multiprocess support\n"
)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mis-indentation?

@ryanofsky
Copy link
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 bitcoin/bitcoin#33290 (comment) and possibility of extending this to detect an incompatible netbsd package from #196 (comment)

@ryanofsky ryanofsky merged commit 13424cf into bitcoin-core:master Sep 5, 2025
8 checks passed
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Sep 5, 2025
…f2ecc1

13424cf2ecc1 Merge bitcoin-core/libmultiprocess#205: cmake: check for Cap'n Proto / Clang / C++20 incompatibility
72dce118649b Merge bitcoin-core/libmultiprocess#200: event loop: add LogOptions struct and reduce the log size
85003409f964 eventloop: add `LogOptions` struct
657d80622f81 cmake: capnproto pkg missing helpful error
d314057775a5 cmake: check for Cap'n Proto / Clang / C++20 incompatibility
878e84dc3030 Merge bitcoin-core/libmultiprocess#203: cmake: search capnproto in package mode only
1a85da5873c2 Merge bitcoin-core/libmultiprocess#202: doc: correct the build instructions for the example
df01873e1ecb Merge bitcoin-core/libmultiprocess#197: ci: Add freebsd and macos build
3bee07ab3367 cmake: search capnproto in package mode only
b6d3dc44194c doc: correct the build instructions for example
fa1ac3000055 ci: Add macos and freebsd task

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: 13424cf2ecc1e5eadc85556cf1f4c65e915f702a
fanquake added a commit to bitcoin/bitcoin that referenced this pull request Sep 8, 2025
a334bbe Squashed 'src/ipc/libmultiprocess/' changes from 1b8d4a6f1e54..13424cf2ecc1 (Ryan Ofsky)

Pull request description:

  Includes:

  - bitcoin-core/libmultiprocess#197
  - bitcoin-core/libmultiprocess#202
  - bitcoin-core/libmultiprocess#203
  - bitcoin-core/libmultiprocess#200
  - bitcoin-core/libmultiprocess#205

  These changes should give better feedback when there are build errors, and also make IPC logs more readable.

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

ACKs for top commit:
  Sjors:
    ACK a4ee70e

Tree-SHA512: ddddd0ed44522ade98a5b94f44b57210794d64f8c378a00438082b8c377f41e9b86c0c5ed29add45472549758f7478ab220af8e268b90b30f57a236c639497d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants