From aae82b3c7c4b5c57dfcf4e9fb68b4eb7d43605d5 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 30 Mar 2024 06:38:57 +0000 Subject: [PATCH 1/3] depends: Bump libmultiprocess source Not using the latest commit 3f8483b61a5eee3e958328d90f25f29a1a61ae7b due to https://github.com/chaincodelabs/libmultiprocess/pull/97#issuecomment-2027937177 --- depends/packages/native_libmultiprocess.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/native_libmultiprocess.mk b/depends/packages/native_libmultiprocess.mk index bcdb1f9e7c42b..5091005617166 100644 --- a/depends/packages/native_libmultiprocess.mk +++ b/depends/packages/native_libmultiprocess.mk @@ -1,8 +1,8 @@ package=native_libmultiprocess -$(package)_version=8da797c5f1644df1bffd84d10c1ae9836dc70d60 +$(package)_version=003eb04d6d0029fd24a330ab63d5a9ba08cf240f $(package)_download_path=https://github.com/chaincodelabs/libmultiprocess/archive $(package)_file_name=$($(package)_version).tar.gz -$(package)_sha256_hash=030f4d393d2ac9deba98d2e1973e22fc439ffc009d5f8ae3225c90639f86beb0 +$(package)_sha256_hash=d23e82f7a0b498a876a4bcdecca3104032a9f9372e1a0cf0049409a2718e5d39 $(package)_dependencies=native_capnp define $(package)_config_cmds From c24647c02353c4709cf7aeb5b9674af1c056021a Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:46:52 +0000 Subject: [PATCH 2/3] cmake: Add `MULTIPROCESS` option --- CMakeLists.txt | 2 ++ cmake/optional.cmake | 12 ++++++++++++ depends/Makefile | 1 + depends/toolchain.cmake.in | 9 +++++++++ src/CMakeLists.txt | 16 ++++++++++++++++ src/ipc/CMakeLists.txt | 18 ++++++++++++++++++ src/qt/CMakeLists.txt | 22 ++++++++++++++++++++-- src/test/CMakeLists.txt | 22 ++++++++++++++++++++++ 8 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/ipc/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index e1706542b8ff3..aa871fa9cfe53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,7 @@ tristate_option(WITH_EXTERNAL_SIGNER AUTO ) tristate_option(WITH_QRENCODE "Enable QR code support." "if libqrencode is found." AUTO) +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) option(BUILD_TESTS "Build test_bitcoin executable." ON) cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_TESTS" OFF) @@ -540,6 +541,7 @@ if(WITH_GUI) message(" QR code (GUI) ....................... ${WITH_QRENCODE}") endif() message(" external signer ..................... ${WITH_EXTERNAL_SIGNER}") +message(" multiprocess ........................ ${MULTIPROCESS}") message(" NAT-PMP ............................. ${WITH_NATPMP}") message(" UPnP ................................ ${WITH_MINIUPNPC}") message(" ZeroMQ .............................. ${WITH_ZMQ}") diff --git a/cmake/optional.cmake b/cmake/optional.cmake index 96db91f736eee..f2a0c24f484bb 100644 --- a/cmake/optional.cmake +++ b/cmake/optional.cmake @@ -207,3 +207,15 @@ if(WITH_GUI AND WITH_QRENCODE) message(FATAL_ERROR "libqrencode requested, but not found.") endif() endif() + +if(MULTIPROCESS) + find_package(Libmultiprocess CONFIG) + find_package(LibmultiprocessGen CONFIG) + if(TARGET Libmultiprocess::multiprocess AND TARGET Libmultiprocess::mpgen) + set(MULTIPROCESS ON) + elseif(MULTIPROCESS STREQUAL "AUTO") + set(MULTIPROCESS OFF) + else() + message(FATAL_ERROR "\"-DMULTIPROCESS=ON\" specified, but libmultiprocess library was not found.") + endif() +endif() diff --git a/depends/Makefile b/depends/Makefile index 6492de79564e5..42c6a8a88e66f 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -295,6 +295,7 @@ $(host_prefix)/share/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_ -e 's|@no_natpmp@|$(NO_NATPMP)|' \ -e 's|@no_usdt@|$(NO_USDT)|' \ -e 's|@no_harden@|$(NO_HARDEN)|' \ + -e 's|@multiprocess@|$(MULTIPROCESS)|' \ $< > $@ touch $@ diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index 4771d80005efa..f5178585c1529 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -153,3 +153,12 @@ endif() if(NOT HARDENING AND "@no_harden@" STREQUAL "1") set(HARDENING OFF CACHE STRING "Attempt to harden the resulting executables.") endif() + +if("@multiprocess@" STREQUAL "1") + if(NOT MULTIPROCESS) + set(MULTIPROCESS ON CACHE STRING "") + endif() + if(NOT LibmultiprocessGen_DIR) + set(LibmultiprocessGen_DIR "${CMAKE_FIND_ROOT_PATH}/native/lib/cmake/LibmultiprocessGen" CACHE PATH "") + endif() +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c315bea099f5..2100664b4c200 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,9 @@ add_dependencies(bitcoin_clientversion generate_build_info) add_subdirectory(crypto) add_subdirectory(univalue) add_subdirectory(util) +if(MULTIPROCESS) + add_subdirectory(ipc) +endif() add_library(bitcoin_consensus_sources INTERFACE) @@ -277,6 +280,19 @@ if(BUILD_DAEMON) ) list(APPEND installable_targets bitcoind) endif() +if(MULTIPROCESS) + add_executable(bitcoin-node + bitcoind.cpp + init/bitcoin-node.cpp + ) + target_link_libraries(bitcoin-node + core_interface + bitcoin_node + bitcoin_ipc + $ + ) + list(APPEND installable_targets bitcoin-node) +endif() add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt new file mode 100644 index 0000000000000..4e4f6314e0ef2 --- /dev/null +++ b/src/ipc/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2023-present The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +add_library(bitcoin_ipc STATIC EXCLUDE_FROM_ALL + capnp/protocol.cpp + interfaces.cpp + process.cpp +) + +target_capnp_sources(bitcoin_ipc ${CMAKE_SOURCE_DIR} + capnp/echo.capnp capnp/init.capnp +) + +target_link_libraries(bitcoin_ipc + PRIVATE + core_interface +) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 45b8b50da2334..b528b4d68acfc 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -202,12 +202,30 @@ target_link_libraries(bitcoin-qt ) import_plugins(bitcoin-qt) - +set(installable_targets bitcoin-qt) if(WIN32) set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) endif() -install(TARGETS bitcoin-qt +if(MULTIPROCESS) + add_executable(bitcoin-gui + main.cpp + ../init/bitcoin-gui.cpp + ) + target_link_libraries(bitcoin-gui + core_interface + bitcoinqt + bitcoin_node + bitcoin_ipc + ) + import_plugins(bitcoin-gui) + list(APPEND installable_targets bitcoin-gui) + if(WIN32) + set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE) + endif() +endif() + +install(TARGETS ${installable_targets} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT GUI ) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 328944feb45c8..bb3e94ab7f883 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -175,6 +175,28 @@ if(ENABLE_WALLET) endif() endif() +if(MULTIPROCESS) + add_library(bitcoin_ipc_test STATIC EXCLUDE_FROM_ALL + ipc_test.cpp + ) + + target_capnp_sources(bitcoin_ipc_test ${CMAKE_SOURCE_DIR} + ipc_test.capnp + ) + + target_link_libraries(bitcoin_ipc_test + PRIVATE + core_interface + univalue + ) + + target_sources(test_bitcoin + PRIVATE + ipc_tests.cpp + ) + target_link_libraries(test_bitcoin bitcoin_ipc_test) +endif() + install(TARGETS test_bitcoin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) From 6c64fc208a950d721b9e5a742cc2da3960733027 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:40:39 +0000 Subject: [PATCH 3/3] fixup! ci: Test CMake edge cases Add "Linux 64-bit, multiprocess" task. --- .github/workflows/cmake.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c8658f887a584..47a0aaf0c6629 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -275,6 +275,10 @@ jobs: # For -Wno-error=unreachable-code, please refer to https://github.com/bitcoin/bitcoin/issues/29334 configure_env: 'env CXXFLAGS="-Wno-error=unreachable-code"' configure_options: '-DWERROR=ON' + - name: 'Linux 64-bit, multiprocess' + triplet: 'x86_64-pc-linux-gnu' + depends_options: 'MULTIPROCESS=1' + configure_options: '-DWERROR=ON' - name: 'MinGW-w64' triplet: 'x86_64-w64-mingw32' packages: 'g++-mingw-w64-x86-64-posix' @@ -386,7 +390,7 @@ jobs: key: ${{ matrix.host.triplet }}${{ matrix.host.cache_suffix }}-ccache-${{ github.run_id }} - name: Test - if: ${{ matrix.host.triplet == 'i686-pc-linux-gnu' }} + if: ${{ matrix.host.triplet == 'i686-pc-linux-gnu' || matrix.host.triplet == 'x86_64-pc-linux-gnu' }} run: | ctest --test-dir build -j $(nproc)