-
Notifications
You must be signed in to change notification settings - Fork 35
cmake: check for Cap'n Proto / Clang / C++20 incompatibility #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: check for Cap'n Proto / Clang / C++20 incompatibility #205
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
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. |
There was a problem hiding this 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
LLM linter also suggested some reasonable edits #205 (comment) |
ee5e284
to
197aef2
Compare
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. |
@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 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() |
There was a problem hiding this 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.
e1c15e0
to
657d806
Compare
@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
...even if that means we repeat a string or two. |
I tested 657d806 by updating the subtree in Bitcoin Core, and uninstalling capnp:
That's quite nice. |
Might make sense to update PR title and description to reflect broader scope of this change now |
Testing 657d806 with different settings in setting 0.9.0 in olddeps.bash warns about CVE and suggests upgrading to major or minor version or disabling
setting 0.9.0 in and export CXX=clang++ in olddeps.bash suggests upgrading to major version or disabling
setting 0.9.2 in and export CXX=clang++ in olddeps.bash suggests using gcc or updating to major version or disabling
commenting out capnproto input in shell.nix suggests installing cap'n proto or disabling
|
There was a problem hiding this 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") |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mis-indentation?
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) |
…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
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
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