Skip to content

Commit c1e1967

Browse files
committed
Merge #118: cmake: Add MULTIPROCESS option
6c64fc2 fixup! ci: Test CMake edge cases (Hennadii Stepanov) c24647c cmake: Add `MULTIPROCESS` option (Hennadii Stepanov) aae82b3 depends: Bump libmultiprocess source (Hennadii Stepanov) Pull request description: Also a new "Linux 64-bit, multiprocess" CI task has been added. Also see: bitcoin#29665. Top commit has no ACKs. Tree-SHA512: c03255070fb843ff37e8997cf2813f10380925fb2a5b7178e5f0516cc4d829700ff334e18066265b246d87f7ba1a20472bb0638608983d11a74b6d68dd9c4306
2 parents 8bcdf2a + 6c64fc2 commit c1e1967

10 files changed

+107
-5
lines changed

.github/workflows/cmake.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ jobs:
275275
# For -Wno-error=unreachable-code, please refer to https://github.com/bitcoin/bitcoin/issues/29334
276276
configure_env: 'env CXXFLAGS="-Wno-error=unreachable-code"'
277277
configure_options: '-DWERROR=ON'
278+
- name: 'Linux 64-bit, multiprocess'
279+
triplet: 'x86_64-pc-linux-gnu'
280+
depends_options: 'MULTIPROCESS=1'
281+
configure_options: '-DWERROR=ON'
278282
- name: 'MinGW-w64'
279283
triplet: 'x86_64-w64-mingw32'
280284
packages: 'g++-mingw-w64-x86-64-posix'
@@ -386,7 +390,7 @@ jobs:
386390
key: ${{ matrix.host.triplet }}${{ matrix.host.cache_suffix }}-ccache-${{ github.run_id }}
387391

388392
- name: Test
389-
if: ${{ matrix.host.triplet == 'i686-pc-linux-gnu' }}
393+
if: ${{ matrix.host.triplet == 'i686-pc-linux-gnu' || matrix.host.triplet == 'x86_64-pc-linux-gnu' }}
390394
run: |
391395
ctest --test-dir build -j $(nproc)
392396

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ tristate_option(WITH_EXTERNAL_SIGNER
8686
AUTO
8787
)
8888
tristate_option(WITH_QRENCODE "Enable QR code support." "if libqrencode is found." AUTO)
89+
tristate_option(MULTIPROCESS "Build multiprocess bitcoin-node, bitcoin-wallet, and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." "if libmultiprocess is found." OFF)
8990

9091
option(BUILD_TESTS "Build test_bitcoin executable." ON)
9192
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_TESTS" OFF)
@@ -540,6 +541,7 @@ if(WITH_GUI)
540541
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
541542
endif()
542543
message(" external signer ..................... ${WITH_EXTERNAL_SIGNER}")
544+
message(" multiprocess ........................ ${MULTIPROCESS}")
543545
message(" NAT-PMP ............................. ${WITH_NATPMP}")
544546
message(" UPnP ................................ ${WITH_MINIUPNPC}")
545547
message(" ZeroMQ .............................. ${WITH_ZMQ}")

cmake/optional.cmake

+12
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,15 @@ if(WITH_GUI AND WITH_QRENCODE)
207207
message(FATAL_ERROR "libqrencode requested, but not found.")
208208
endif()
209209
endif()
210+
211+
if(MULTIPROCESS)
212+
find_package(Libmultiprocess CONFIG)
213+
find_package(LibmultiprocessGen CONFIG)
214+
if(TARGET Libmultiprocess::multiprocess AND TARGET Libmultiprocess::mpgen)
215+
set(MULTIPROCESS ON)
216+
elseif(MULTIPROCESS STREQUAL "AUTO")
217+
set(MULTIPROCESS OFF)
218+
else()
219+
message(FATAL_ERROR "\"-DMULTIPROCESS=ON\" specified, but libmultiprocess library was not found.")
220+
endif()
221+
endif()

depends/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ $(host_prefix)/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_$(fina
295295
-e 's|@no_natpmp@|$(NO_NATPMP)|' \
296296
-e 's|@no_usdt@|$(NO_USDT)|' \
297297
-e 's|@no_harden@|$(NO_HARDEN)|' \
298+
-e 's|@multiprocess@|$(MULTIPROCESS)|' \
298299
$< > $@
299300
touch $@
300301

depends/packages/native_libmultiprocess.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package=native_libmultiprocess
2-
$(package)_version=8da797c5f1644df1bffd84d10c1ae9836dc70d60
2+
$(package)_version=003eb04d6d0029fd24a330ab63d5a9ba08cf240f
33
$(package)_download_path=https://github.com/chaincodelabs/libmultiprocess/archive
44
$(package)_file_name=$($(package)_version).tar.gz
5-
$(package)_sha256_hash=030f4d393d2ac9deba98d2e1973e22fc439ffc009d5f8ae3225c90639f86beb0
5+
$(package)_sha256_hash=d23e82f7a0b498a876a4bcdecca3104032a9f9372e1a0cf0049409a2718e5d39
66
$(package)_dependencies=native_capnp
77

88
define $(package)_config_cmds

depends/toolchain.cmake.in

+9
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,12 @@ endif()
153153
if(NOT HARDENING AND "@no_harden@" STREQUAL "1")
154154
set(HARDENING OFF CACHE STRING "Attempt to harden the resulting executables.")
155155
endif()
156+
157+
if("@multiprocess@" STREQUAL "1")
158+
if(NOT MULTIPROCESS)
159+
set(MULTIPROCESS ON CACHE STRING "")
160+
endif()
161+
if(NOT LibmultiprocessGen_DIR)
162+
set(LibmultiprocessGen_DIR "${CMAKE_FIND_ROOT_PATH}/native/lib/cmake/LibmultiprocessGen" CACHE PATH "")
163+
endif()
164+
endif()

src/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ add_dependencies(bitcoin_clientversion generate_build_info)
3535
add_subdirectory(crypto)
3636
add_subdirectory(univalue)
3737
add_subdirectory(util)
38+
if(MULTIPROCESS)
39+
add_subdirectory(ipc)
40+
endif()
3841

3942

4043
add_library(bitcoin_consensus_sources INTERFACE)
@@ -277,6 +280,19 @@ if(BUILD_DAEMON)
277280
)
278281
list(APPEND installable_targets bitcoind)
279282
endif()
283+
if(MULTIPROCESS)
284+
add_executable(bitcoin-node
285+
bitcoind.cpp
286+
init/bitcoin-node.cpp
287+
)
288+
target_link_libraries(bitcoin-node
289+
core_interface
290+
bitcoin_node
291+
bitcoin_ipc
292+
$<TARGET_NAME_IF_EXISTS:bitcoin_wallet>
293+
)
294+
list(APPEND installable_targets bitcoin-node)
295+
endif()
280296

281297

282298
add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL

src/ipc/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2023-present 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+
add_library(bitcoin_ipc STATIC EXCLUDE_FROM_ALL
6+
capnp/protocol.cpp
7+
interfaces.cpp
8+
process.cpp
9+
)
10+
11+
target_capnp_sources(bitcoin_ipc ${CMAKE_SOURCE_DIR}
12+
capnp/echo.capnp capnp/init.capnp
13+
)
14+
15+
target_link_libraries(bitcoin_ipc
16+
PRIVATE
17+
core_interface
18+
)

src/qt/CMakeLists.txt

+20-2
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,30 @@ target_link_libraries(bitcoin-qt
202202
)
203203

204204
import_plugins(bitcoin-qt)
205-
205+
set(installable_targets bitcoin-qt)
206206
if(WIN32)
207207
set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE)
208208
endif()
209209

210-
install(TARGETS bitcoin-qt
210+
if(MULTIPROCESS)
211+
add_executable(bitcoin-gui
212+
main.cpp
213+
../init/bitcoin-gui.cpp
214+
)
215+
target_link_libraries(bitcoin-gui
216+
core_interface
217+
bitcoinqt
218+
bitcoin_node
219+
bitcoin_ipc
220+
)
221+
import_plugins(bitcoin-gui)
222+
list(APPEND installable_targets bitcoin-gui)
223+
if(WIN32)
224+
set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE)
225+
endif()
226+
endif()
227+
228+
install(TARGETS ${installable_targets}
211229
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
212230
COMPONENT GUI
213231
)

src/test/CMakeLists.txt

+22
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,28 @@ if(ENABLE_WALLET)
175175
endif()
176176
endif()
177177

178+
if(MULTIPROCESS)
179+
add_library(bitcoin_ipc_test STATIC EXCLUDE_FROM_ALL
180+
ipc_test.cpp
181+
)
182+
183+
target_capnp_sources(bitcoin_ipc_test ${CMAKE_SOURCE_DIR}
184+
ipc_test.capnp
185+
)
186+
187+
target_link_libraries(bitcoin_ipc_test
188+
PRIVATE
189+
core_interface
190+
univalue
191+
)
192+
193+
target_sources(test_bitcoin
194+
PRIVATE
195+
ipc_tests.cpp
196+
)
197+
target_link_libraries(test_bitcoin bitcoin_ipc_test)
198+
endif()
199+
178200
install(TARGETS test_bitcoin
179201
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
180202
)

0 commit comments

Comments
 (0)