Skip to content

Commit b2bb27f

Browse files
committed
Merge bitcoin/bitcoin#31741: multiprocess: Add libmultiprocess git subtree
babb9f5 depends: remove non-native libmultiprocess build (Cory Fields) 5d105fb depends: Switch libmultiprocess packages to use local git subtree (Ryan Ofsky) 9b35518 depends, moveonly: split up int_get_build_id function (Ryan Ofsky) 2d373e2 lint: Add exclusions for libmultiprocess subtree (Ryan Ofsky) e88ab39 doc: Update documentation to explain libmultiprocess subtree (Ryan Ofsky) d4bc563 cmake: Fix clang-tidy "no input files" errors (Ryan Ofsky) abdf3cb cmake: Fix warnings from boost headers (Ryan Ofsky) 8532fcb cmake: Fix ctest mptest "Unable to find executable" errors (Ryan Ofsky) d597ab1 cmake: Support building with libmultiprocess subtree (Ryan Ofsky) 69f0d4a scripted-diff: s/WITH_MULTIPROCESS/ENABLE_IPC/ in cmake (Ryan Ofsky) a2f28e4 Squashed 'src/ipc/libmultiprocess/' content from commit 35944ffd23fa (Ryan Ofsky) d6244f8 depends: Update libmultiprocess library to simplify cmake subtree build (Ryan Ofsky) Pull request description: This adds the [libmultiprocess](https://github.com/chaincodelabs/libmultiprocess) library and code generator as a subtree in `src/ipc/libmultiprocess` and allows it to be built with the cmake `-DENABLE_IPC` option, which is disabled by default. This PR does not entirely remove the depends system [libmultiprocess package](https://github.com/bitcoin/bitcoin/blob/master/depends/packages/native_libmultiprocess.mk) because the package is useful when cross compiling. (A cross-compiling cmake build cannot easily build and run a native code generation tool.) However, it does update the depends package to build from the new git subtree, instead of being downloaded separately from github, so the same sources are used to build both the runtime library and the code generator. This PR includes the following manual changes (not created automatically with `git subtree add`) which just update the build system and documentation: - [`d6244f85c509` depends: Update libmultiprocess library to simplify cmake subtree build](bitcoin/bitcoin@d6244f8) - [`69f0d4adb72c` scripted-diff: s/WITH_MULTIPROCESS/ENABLE_IPC/ in cmake](bitcoin/bitcoin@69f0d4a) - [`d597ab1dee6b` cmake: Support building with libmultiprocess subtree](bitcoin/bitcoin@d597ab1) - [`8532fcb1c30d` cmake: Fix ctest mptest "Unable to find executable" errors](bitcoin/bitcoin@8532fcb) - [`abdf3cb6456f` cmake: Fix warnings from boost headers](bitcoin/bitcoin@abdf3cb) - [`d4bc5639829f` cmake: Fix clang-tidy "no input files" errors](bitcoin/bitcoin@d4bc563) - [`e88ab394c163` doc: Update documentation to explain libmultiprocess subtree](bitcoin/bitcoin@e88ab39) - [`2d373e27071f` lint: Add exclusions for libmultiprocess subtree](bitcoin/bitcoin@2d373e2) - [`9b35518d2f3f` depends, moveonly: split up int_get_build_id function](bitcoin/bitcoin@9b35518) - [`5d105fb8c3ff` depends: Switch libmultiprocess packages to use local git subtree](bitcoin/bitcoin@5d105fb) - [`babb9f5db641` depends: remove non-native libmultiprocess build](bitcoin/bitcoin@babb9f5) --- Previous minisketch subtree PR #23114 may be useful for comparison Instructions for subtree verification can be found: - https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees - https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh TL&DR: ```sh git remote add --fetch libmultiprocess https://github.com/chaincodelabs/libmultiprocess.git test/lint/git-subtree-check.sh -r src/ipc/libmultiprocess ``` --- This PR is part of the [process separation project](bitcoin/bitcoin#28722). ACKs for top commit: Sjors: re-ACK babb9f5 TheCharlatan: tACK babb9f5 vasild: ACK babb9f5 Tree-SHA512: 43d4eecca5aab63e55c613de935965666eaced327f9fe859a0e9c9b85f7685dc16c5c8d6e03e09ca998628c5d468633f4f743529930b037049abe8e0101e0143
2 parents a4fd565 + babb9f5 commit b2bb27f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+6030
-62
lines changed

CMakeLists.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ option(BUILD_DAEMON "Build bitcoind executable." ON)
9494
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
9595
option(BUILD_CLI "Build bitcoin-cli executable." ON)
9696

97-
option(BUILD_TESTS "Build test_bitcoin executable." ON)
97+
option(BUILD_TESTS "Build test_bitcoin and other unit test executables." ON)
9898
option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS})
9999
option(BUILD_UTIL "Build bitcoin-util executable." ${BUILD_TESTS})
100100

@@ -153,8 +153,9 @@ endif()
153153

154154
cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF)
155155

156-
option(WITH_MULTIPROCESS "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
157-
if(WITH_MULTIPROCESS)
156+
option(ENABLE_IPC "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
157+
cmake_dependent_option(WITH_EXTERNAL_LIBMULTIPROCESS "Build with external libmultiprocess library instead of with local git subtree when ENABLE_IPC is enabled. This is not normally recommended, but can be useful when cross-compiling or making changes to the upstream project." OFF "ENABLE_IPC" OFF)
158+
if(ENABLE_IPC AND WITH_EXTERNAL_LIBMULTIPROCESS)
158159
find_package(Libmultiprocess REQUIRED COMPONENTS Lib)
159160
find_package(LibmultiprocessNative REQUIRED COMPONENTS Bin
160161
NAMES Libmultiprocess
@@ -648,14 +649,14 @@ message("Configure summary")
648649
message("=================")
649650
message("Executables:")
650651
message(" bitcoind ............................ ${BUILD_DAEMON}")
651-
if(BUILD_DAEMON AND WITH_MULTIPROCESS)
652+
if(BUILD_DAEMON AND ENABLE_IPC)
652653
set(bitcoin_daemon_status ON)
653654
else()
654655
set(bitcoin_daemon_status OFF)
655656
endif()
656657
message(" bitcoin-node (multiprocess) ......... ${bitcoin_daemon_status}")
657658
message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}")
658-
if(BUILD_GUI AND WITH_MULTIPROCESS)
659+
if(BUILD_GUI AND ENABLE_IPC)
659660
set(bitcoin_gui_status ON)
660661
else()
661662
set(bitcoin_gui_status OFF)
@@ -674,6 +675,16 @@ if(ENABLE_WALLET)
674675
endif()
675676
message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")
676677
message(" ZeroMQ .............................. ${WITH_ZMQ}")
678+
if(ENABLE_IPC)
679+
if (WITH_EXTERNAL_LIBMULTIPROCESS)
680+
set(ipc_status "ON (with external libmultiprocess)")
681+
else()
682+
set(ipc_status ON)
683+
endif()
684+
else()
685+
set(ipc_status OFF)
686+
endif()
687+
message(" IPC ................................. ${ipc_status}")
677688
message(" USDT tracing ........................ ${WITH_USDT}")
678689
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
679690
message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}")

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"ENABLE_WALLET": "ON",
8282
"WARN_INCOMPATIBLE_BDB": "OFF",
8383
"WITH_BDB": "ON",
84-
"WITH_MULTIPROCESS": "ON",
84+
"ENABLE_IPC": "ON",
8585
"WITH_QRENCODE": "ON",
8686
"WITH_USDT": "ON",
8787
"WITH_ZMQ": "ON"

cmake/libmultiprocess.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2025 The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
function(add_libmultiprocess subdir)
6+
# Set BUILD_TESTING to match BUILD_TESTS. BUILD_TESTING is a standard cmake
7+
# option that controls whether enable_testing() is called, but in the bitcoin
8+
# build a BUILD_TESTS option is used instead.
9+
set(BUILD_TESTING "${BUILD_TESTS}")
10+
add_subdirectory(${subdir} EXCLUDE_FROM_ALL)
11+
# Apply core_interface compile options to libmultiprocess runtime library.
12+
target_link_libraries(multiprocess PUBLIC $<BUILD_INTERFACE:core_interface>)
13+
target_link_libraries(mputil PUBLIC $<BUILD_INTERFACE:core_interface>)
14+
target_link_libraries(mpgen PUBLIC $<BUILD_INTERFACE:core_interface>)
15+
# Mark capproto options as advanced to hide by default from cmake UI
16+
mark_as_advanced(CapnProto_DIR)
17+
mark_as_advanced(CapnProto_capnpc_IMPORTED_LOCATION)
18+
mark_as_advanced(CapnProto_capnp_IMPORTED_LOCATION)
19+
mark_as_advanced(CapnProto_capnp-json_IMPORTED_LOCATION)
20+
mark_as_advanced(CapnProto_capnp-rpc_IMPORTED_LOCATION)
21+
mark_as_advanced(CapnProto_capnp-websocket_IMPORTED_LOCATION)
22+
mark_as_advanced(CapnProto_kj-async_IMPORTED_LOCATION)
23+
mark_as_advanced(CapnProto_kj-gzip_IMPORTED_LOCATION)
24+
mark_as_advanced(CapnProto_kj-http_IMPORTED_LOCATION)
25+
mark_as_advanced(CapnProto_kj_IMPORTED_LOCATION)
26+
mark_as_advanced(CapnProto_kj-test_IMPORTED_LOCATION)
27+
mark_as_advanced(CapnProto_kj-tls_IMPORTED_LOCATION)
28+
if(BUILD_TESTS)
29+
# Add tests to "all" target so ctest can run them
30+
set_target_properties(mptests PROPERTIES EXCLUDE_FROM_ALL OFF)
31+
endif()
32+
# Exclude examples from compilation database, because the examples are not
33+
# built by default, and they contain generated c++ code. Without this
34+
# exclusion, tools like clang-tidy and IWYU that make use of compilation
35+
# database would complain that the generated c++ source files do not exist. An
36+
# alternate fix could build "mpexamples" by default like "mptests" above.
37+
set_target_properties(mpcalculator mpprinter mpexample PROPERTIES EXPORT_COMPILE_COMMANDS OFF)
38+
endfunction()

depends/funcs.mk

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,33 @@ define fetch_file
3939
$(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5))))
4040
endef
4141

42+
# Shell script to create a source tarball in $(1)_source from local directory
43+
# $(1)_local_dir instead of downloading remote sources. Tarball is recreated if
44+
# any paths in the local directory have a newer mtime, and checksum of the
45+
# tarball is saved to $(1)_fetched and returned as output.
46+
define fetch_local_dir_sha256
47+
if ! [ -f $($(1)_source) ] || [ -n "$$(find $($(1)_local_dir) -newer $($(1)_source) | head -n1)" ]; then \
48+
mkdir -p $(dir $($(1)_source)) && \
49+
$(build_TAR) -c -f $($(1)_source) -C $($(1)_local_dir) . && \
50+
rm -f $($(1)_fetched); \
51+
fi && \
52+
if ! [ -f $($(1)_fetched) ] || [ -n "$$(find $($(1)_source) -newer $($(1)_fetched))" ]; then \
53+
mkdir -p $(dir $($(1)_fetched)) && \
54+
cd $($(1)_source_dir) && \
55+
$(build_SHA256SUM) $($(1)_all_sources) > $($(1)_fetched); \
56+
fi && \
57+
cut -d" " -f1 $($(1)_fetched)
58+
endef
59+
4260
define int_get_build_recipe_hash
4361
$(eval $(1)_patches_path?=$(PATCHES_PATH)/$(1))
4462
$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $($(1)_patches_path)/,$($(1)_patches)) | cut -d" " -f1))
63+
# If $(1)_local_dir is set, create a tarball of the local directory contents to
64+
# use as the source of the package, and include a hash of the tarball in the
65+
# package id, so if directory contents change, the package and packages
66+
# depending on it will be rebuilt.
67+
$(if $($(1)_local_dir),$(eval $(1)_sha256_hash:=$(shell $(call fetch_local_dir_sha256,$(1)))))
68+
$(if $($(1)_local_dir),$(eval $(1)_all_file_checksums+=$($(1)_sha256_hash)))
4569
$(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1))
4670
endef
4771

@@ -54,20 +78,32 @@ $(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SU
5478
final_build_id_long+=$($(package)_build_id_long)
5579

5680
#compute package-specific paths
57-
$(1)_build_subdir?=.
58-
$(1)_download_file?=$($(1)_file_name)
59-
$(1)_source_dir:=$(SOURCES_PATH)
60-
$(1)_source:=$$($(1)_source_dir)/$($(1)_file_name)
6181
$(1)_staging_dir=$(base_staging_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)
6282
$(1)_staging_prefix_dir:=$$($(1)_staging_dir)$($($(1)_type)_prefix)
6383
$(1)_extract_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)
64-
$(1)_download_dir:=$(base_download_dir)/$(1)-$($(1)_version)
6584
$(1)_build_dir:=$$($(1)_extract_dir)/$$($(1)_build_subdir)
6685
$(1)_cached_checksum:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz.hash
6786
$(1)_patch_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)/.patches-$($(1)_build_id)
68-
$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/
6987
$(1)_cached:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz
7088
$(1)_build_log:=$(BASEDIR)/$(1)-$($(1)_version)-$($(1)_build_id).log
89+
endef
90+
91+
# Convert a string to a human-readable filename, replacing dot, slash, and space
92+
# characters that could cause problems with dashes and collapsing them.
93+
define int_friendly_file_name
94+
$(subst $(null) $(null),-,$(strip $(subst ., ,$(subst /, ,$(1)))))
95+
endef
96+
97+
define int_get_build_properties
98+
$(1)_build_subdir?=.
99+
$(1)_download_file?=$($(1)_file_name)
100+
$(1)_source_dir:=$(SOURCES_PATH)
101+
# If $(1)_file_name is empty and $(1)_local_dir is nonempty, set file name to a
102+
# .tar file with a friendly filename named after the directory path.
103+
$(if $($(1)_file_name),,$(if $($(1)_local_dir),$(eval $(1)_file_name:=$(call int_friendly_file_name,$($(1)_local_dir)).tar)))
104+
$(1)_source:=$$($(1)_source_dir)/$($(1)_file_name)
105+
$(1)_download_dir:=$(base_download_dir)/$(1)-$($(1)_version)
106+
$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/
71107
$(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources)
72108

73109
#stamps
@@ -288,6 +324,9 @@ $(foreach package,$(all_packages),$(eval $(call int_vars,$(package))))
288324
$(foreach native_package,$(native_packages),$(eval include packages/$(native_package).mk))
289325
$(foreach package,$(packages),$(eval include packages/$(package).mk))
290326

327+
#set build properties for included package files
328+
$(foreach package,$(all_packages),$(eval $(call int_get_build_properties,$(package))))
329+
291330
#compute a hash of all files that comprise this package's build recipe
292331
$(foreach package,$(all_packages),$(eval $(call int_get_build_recipe_hash,$(package))))
293332

depends/packages.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ General tips:
1111
[below](#secondary-dependencies) for more details.
1212

1313
## Identifiers
14-
Each package is required to define at least these variables:
14+
If package does not define a `$(package)_local_dir` variable, it is required to
15+
define these variables:
1516

1617
$(package)_version:
1718
Version of the upstream library or program. If there is no version, a
@@ -28,6 +29,9 @@ Each package is required to define at least these variables:
2829
$(package)_sha256_hash:
2930
The sha256 hash of the upstream file
3031

32+
If a package does define a `$(package)_local_dir` variable, the above variables
33+
are not required and will be ignored.
34+
3135
These variables are optional:
3236

3337
$(package)_build_subdir:
@@ -48,6 +52,18 @@ These variables are optional:
4852
Any extra files that will be fetched via $(package)_fetch_cmds. These are
4953
specified so that they can be fetched and verified via 'make download'.
5054

55+
## Local packages
56+
57+
If a package defines a `$(package)_local_dir` variable, the specified directory
58+
will be treated as a download source, and a tarball of its contents will be
59+
saved to `sources/`. A hash of the tarball will also become part of the package
60+
build id, so if the directory contents change, the package and everything
61+
depending on it will be rebuilt. For efficiency, the tarball is cached once it
62+
has been created, but if the local directory is touched, it will be rebuilt.
63+
64+
Local packages can be useful for using git submodules or subtrees to manage
65+
package sources, or for testing local changes that are not available to
66+
download from an external source.
5167

5268
## Build Variables:
5369
After defining the main identifiers, build variables may be added or customized

depends/packages/libmultiprocess.mk

Lines changed: 0 additions & 29 deletions
This file was deleted.

depends/packages/native_libmultiprocess.mk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package=native_libmultiprocess
2-
$(package)_version=1954f7f65661d49e700c344eae0fc8092decf975
3-
$(package)_download_path=https://github.com/bitcoin-core/libmultiprocess/archive
4-
$(package)_file_name=$($(package)_version).tar.gz
5-
$(package)_sha256_hash=fc014bd74727c1d5d30b396813685012c965d079244dd07b53bc1c75c610a2cb
2+
$(package)_local_dir=../src/ipc/libmultiprocess
63
$(package)_dependencies=native_capnp
74

85
define $(package)_config_cmds

depends/packages/packages.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sqlite_packages=sqlite
2020

2121
zmq_packages=zeromq
2222

23-
multiprocess_packages = libmultiprocess capnp
23+
multiprocess_packages = capnp
2424
multiprocess_native_packages = native_libmultiprocess native_capnp
2525

2626
usdt_linux_packages=systemtap

depends/toolchain.cmake.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ else()
159159
endif()
160160

161161
if("@multiprocess@" STREQUAL "1")
162-
set(WITH_MULTIPROCESS ON CACHE BOOL "")
163-
set(Libmultiprocess_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "")
164-
set(LibmultiprocessNative_ROOT "${CMAKE_CURRENT_LIST_DIR}/native" CACHE PATH "")
162+
set(ENABLE_IPC ON CACHE BOOL "")
163+
set(MPGEN_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/native/bin/mpgen" CACHE FILEPATH "")
164+
set(CAPNP_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/native/bin/capnp" CACHE FILEPATH "")
165+
set(CAPNPC_CXX_EXECUTABLE "${CMAKE_CURRENT_LIST_DIR}/native/bin/capnpc-c++" CACHE FILEPATH "")
165166
else()
166-
set(WITH_MULTIPROCESS OFF CACHE BOOL "")
167+
set(ENABLE_IPC OFF CACHE BOOL "")
167168
endif()

doc/design/libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| *libbitcoin_crypto* | Hardware-optimized functions for data encryption, hashing, message authentication, and key derivation. |
99
| *libbitcoin_kernel* | Consensus engine and support library used for validation by *libbitcoin_node*. |
1010
| *libbitcoinqt* | GUI functionality used by *bitcoin-qt* and *bitcoin-gui* executables. |
11-
| *libbitcoin_ipc* | IPC functionality used by *bitcoin-node*, *bitcoin-wallet*, *bitcoin-gui* executables to communicate when [`-DWITH_MULTIPROCESS=ON`](multiprocess.md) is used. |
11+
| *libbitcoin_ipc* | IPC functionality used by *bitcoin-node*, *bitcoin-wallet*, *bitcoin-gui* executables to communicate when [`-DENABLE_IPC=ON`](multiprocess.md) is used. |
1212
| *libbitcoin_node* | P2P and RPC server functionality used by *bitcoind* and *bitcoin-qt* executables. |
1313
| *libbitcoin_util* | Home for common functionality shared by different executables and libraries. Similar to *libbitcoin_common*, but lower-level (see [Dependencies](#dependencies)). |
1414
| *libbitcoin_wallet* | Wallet functionality used by *bitcoind* and *bitcoin-wallet* executables. |

0 commit comments

Comments
 (0)