-
Notifications
You must be signed in to change notification settings - Fork 6
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: Add MULTIPROCESS
option
#118
Conversation
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.
cr ACK a08579d
- New CI added as mentioned in description;
- Setting
multiprocess
option ON; - Added new macro
generate_from_capnp
incmake/module/GenerateMPCode.cmake
; - Added new CMakeLists.txt for
IPC
directory; - Added new
IPC
library into linking forbitcoin-gui
targets whenmultiprocess
is enabled.
Doc reference for multiprocess
and IPC
.
Other than that, new CI is running successfully:

Where in the CI details can be seeing the multiprocess
optional package enabled
in the configuration summary (Generate build system
task):
...
Optional packages:
GUI ................................. Qt5
external signer ..................... ON
multiprocess ........................ ON
...
You may also be interested in this PR :) |
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 a08579d.
Seems like a nice change. I do agree with the "TODO: Switch to find_package() command" comment. It would be nice to avoid using pkgconfig and ideally find the package using the ${libdir}/cmake/libmultiprocess-*.cmake
files that are installed.
Unfortunately, those target import files do not propagate dependency targets. As such, they have to be handled separately which increases complexity. |
a08579d
to
8e739cd
Compare
Thank you for your valuable review! I've reworked the branch basing on your suggestion. Now it looks much cleaner :) |
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.
re ACK 8e739cd
Addressed @ryanofsky's feedback since my last review, mainly replacing macro generate_from_capnp capnp_relpath
by function target_capnp_sources
.
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 8e739cd
re: #118 (comment)
Unfortunately, those target import files do not propagate dependency targets. As such, they have to be handled separately which increases complexity.
Hmm, what does this mean specifically? It seems like the installed cmake files are calling add_library
and add_executable
to add targets and setting the needed properties. Does something need to be improved in https://github.com/chaincodelabs/libmultiprocess/blob/master/CMakeLists.txt, because current install(EXPORT...)
lines are not enough?
depends/toolchain.cmake.in
Outdated
set(MULTIPROCESS ON CACHE STRING "") | ||
endif() | ||
if(NOT MPGEN_PREFIX) | ||
set(MPGEN_PREFIX "${CMAKE_FIND_ROOT_PATH}/native" CACHE PATH "") |
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.
I don't really understand what this is doing, might be helpful to add a comment. Particularly what is the last "" argument?
EDIT: I guess last "" arguments are for documentation? Are these arguments actually required? If they are it seems like it would be helpful to change them to something like "Set by depends build" to document where they are coming from
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.
This command uses the following signature:
set(<variable> <value>... CACHE <type> <docstring> [FORCE])
where the <docstring>
is mandatory. It allows the user to override its value with -DMPGEN_PREFIX=...
in the command line.
What about "libmultiprocess codegen tool prefix"?
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.
What about "libmultiprocess codegen tool prefix"?
Well "libmultiprocess codegen tool prefix" already seems to be the documentation string for this option in cmake/optional.cmake
so that seems very good.
But I'm confused about why any documentation string is required at all in depends/toolchain.cmake.in
which should just be overriding values, not defining new options. If I understand https://cmake.org/cmake/help/latest/command/set.html correctly, in-memory values naturally override cached values, so it seems like the ideal thing would be to stop specifying CACHE <type> <docstring> arguments in this file, and just set the values in memory. If writing the cache here really is necessary though, I'd think appropriate doc string might be be something like "Overridden by depends build" to indicate that cached values have been overridden.
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.
If writing the cache here really is necessary though...
It is. Otherwise, the user won't be able to override a build option via command line.
For example, passing -DMULTIPROCESS=OFF
won't have any effect.
This is a specific of toolchain files.
... I'd think appropriate doc string might be be something like "Overridden by depends build" to indicate that cached values have been overridden.
Docstrings are available via -LH
command-line option or in cmake-gui
. And you are right that they shouldn't be empty.
However, its content must just be copy-pasted from the option()
commands from the main CMakeLists.txt
file. Otherwise, for example, when the user passes -DMULTIPROCESS=OFF
, it ends with:
// Overridden by depends build
MULTIPROCESS:STRING=OFF
which is misleading.
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.
... you are right that they shouldn't be empty.
Fixed in #122.
cmake/module/GenerateMPCode.cmake
Outdated
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or https://opensource.org/license/mit/. | ||
|
||
function(target_capnp_sources target) |
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.
This function seems generally useful, so it would be great to move this module to https://github.com/chaincodelabs/libmultiprocess/tree/master/cmake /module, and use it upstream to replace hardcoded add_custom_command
calls, and install it so it could be reused by the bitcoin build.
8e739cd
to
3542d08
Compare
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 3542d08
depends/toolchain.cmake.in
Outdated
set(MULTIPROCESS ON CACHE STRING "") | ||
endif() | ||
if(NOT MPGEN_PREFIX) | ||
set(MPGEN_PREFIX "${CMAKE_FIND_ROOT_PATH}/native" CACHE PATH "") |
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.
What about "libmultiprocess codegen tool prefix"?
Well "libmultiprocess codegen tool prefix" already seems to be the documentation string for this option in cmake/optional.cmake
so that seems very good.
But I'm confused about why any documentation string is required at all in depends/toolchain.cmake.in
which should just be overriding values, not defining new options. If I understand https://cmake.org/cmake/help/latest/command/set.html correctly, in-memory values naturally override cached values, so it seems like the ideal thing would be to stop specifying CACHE <type> <docstring> arguments in this file, and just set the values in memory. If writing the cache here really is necessary though, I'd think appropriate doc string might be be something like "Overridden by depends build" to indicate that cached values have been overridden.
The targets from the include(CMakeFindDependencyMacro)
find_dependency(CapnProto) |
840e494 fixup! build: Generate `share/toolchain.cmake` in depends (Hennadii Stepanov) Pull request description: See discussion in #118 (comment). Can be tested in the following ways: - applying the `-LH` command line option - using `cmake-gui` - direct observing of the `CMakeCache.txt` file content ACKs for top commit: pablomartin4btc: tACK 840e494 Tree-SHA512: fd441457dc4df44b54c5fe98119786126db6b592f58ce7bca642a65921ffb9572d0e2afca07471666f425b647ef69f860228b8a0d61d02468d41edccad25627b
3542d08
to
0ef581f
Compare
Rebased due to the conflicts and undrafted. Added lacking docstrings. |
0ef581f
to
69d3f7a
Compare
Rebased. |
66643d8 cmake, refactor: Use `target_capnp_sources` for examples (Hennadii Stepanov) bd2dfe2 cmake, refactor: Use `target_capnp_sources` for `mptest` target (Hennadii Stepanov) d9ec22f cmake: Add `LibmultiprocessMacros` module (Hennadii Stepanov) Pull request description: This PR introduces the `LibmultiprocessMacros` module that is used internally and might be exported as a part of the (future) `LibmultiprocessGen` package (it is a subject of the follow-up [PR](#96)). Also see a discussion in hebasto/bitcoin#118. ACKs for top commit: ryanofsky: Code review ACK 66643d8 Tree-SHA512: b97fcb2ce7b2085b3a041c422e3f51f06b8bf7a0abaa5baa7f39db2bf03491447bf7af073c95fb8bb6bc602d30e0c8856ae523954980cdb85afd87442c0b909a
69d3f7a
to
4b5fb0d
Compare
Reworked in a clean CMake's way using the recent updates in the https://github.com/chaincodelabs/libmultiprocess repository. However, not using the last commit due to an issue with package search. |
Not using the latest commit 3f8483b61a5eee3e958328d90f25f29a1a61ae7b due to bitcoin-core/libmultiprocess#97 (comment)
Add "Linux 64-bit, multiprocess" task.
Rebased. |
While I'm still looking into the recent changes in the upstream repo, do you think it is reasonable to proceed with this PR as it is to unblock the following work on the CI stuff? Anyway, we're likely to revisit this code, once the upstream packaging improvements conclude. |
Of course, do you need anything from me? |
Approval? :) |
Hmm, I'm not sure if you want me to literally ACK the PR since it is just going into a private branch. The thing I still don't understand is why the depends system is defining cache options like |
If depends set such options as non-cache variables, the user won't be able to override them in the command line, for example, with
That is no longer the case in general. But documentation is missed for |
I don't have a better implementation for now. |
So this is to accomodate someone who does a depends build, specifically enabling multiprocess, who then wants to use the toolchain file, but also disable multiprocess? |
Understood, and I don't have one either. I think you should definitely proceed with you have and if there is anything I can do to help just let me know. |
Yes, it is. |
Shouldn't they just not enable multiprocess in the first place? |
Of course, they should not. I'll take more time to think about it. |
I'm going to merge this PR as it is. However, handling of the build configuration variables in the depends toolchain file should be revisited. |
Also a new "Linux 64-bit, multiprocess" CI task has been added.
Also see: bitcoin#29665.