From aadee9564fce485a5ff9faa355e45eac6968ca64 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:10:33 +0100 Subject: [PATCH 1/2] fixup! cmake: Do not add the rpath information to compiled executables 1. Keep RPATH for the `bitcoin-chainstate` target in the build tree, which is useful for the shared `libbitcoinkernel`. 2. Document future improvements. --- CMakeLists.txt | 9 ++++++++- src/CMakeLists.txt | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47f8ebdca8581..c62be499e4952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -597,7 +597,14 @@ if(DEFINED ENV{LDFLAGS}) deduplicate_flags(CMAKE_EXE_LINKER_FLAGS) endif() -set(CMAKE_SKIP_RPATH TRUE) +# TODO: The `CMAKE_SKIP_BUILD_RPATH` variable setting can be deleted +# in the future after reordering Guix script commands to +# perform binary checks after the installation step. +# Relevant discussions: +# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953 +# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833 +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(CMAKE_SKIP_INSTALL_RPATH TRUE) add_subdirectory(src) add_subdirectory(test) add_subdirectory(doc) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb466e6868cca..6116b817bc403 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -355,6 +355,15 @@ if(BUILD_UTIL_CHAINSTATE) add_executable(bitcoin-chainstate bitcoin-chainstate.cpp ) + # TODO: The `SKIP_BUILD_RPATH` property setting can be deleted + # in the future after reordering Guix script commands to + # perform binary checks after the installation step. + # Relevant discussions: + # - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953 + # - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833 + set_target_properties(bitcoin-chainstate PROPERTIES + SKIP_BUILD_RPATH OFF + ) target_link_libraries(bitcoin-chainstate PRIVATE core_interface From f39a1811487dd9c12b81e1ab8078ce9a462eb387 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:46:29 +0100 Subject: [PATCH 2/2] fixup! ci: Test CMake edge cases Add a new "ubuntu-chainstate" job, which builds and runs the `bitcoin-chainstate` binary with static and shared `libbitcoinkernel`. --- .github/workflows/cmake.yml | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 33508551063b1..12a53eacf3ae0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -262,6 +262,69 @@ jobs: ./install/bin/bitcoind -version + ubuntu-chainstate: + name: 'Ubuntu, chainstate + ${{ matrix.conf.job_name }} libkernel' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + conf: + - shared_libs: '-DBUILD_SHARED_LIBS=OFF' + job_name: 'STATIC' + - shared_libs: '-DBUILD_SHARED_LIBS=ON' + job_name: 'SHARED' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends ccache libboost-dev libevent-dev + echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV" + + - name: CMake version + run: | + cmake --version + ctest --version + + - name: Restore Ccache cache + uses: actions/cache/restore@v4 + id: ccache-cache + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ github.job }}-ccache-${{ github.run_id }} + restore-keys: ${{ github.job }}-${{ matrix.conf.job_name }}-ccache- + + - name: Generate build system + run: | + cmake -B build -DBUILD_UTIL_CHAINSTATE=ON ${{ matrix.conf.shared_libs }} + + - name: Build + working-directory: build + run: | + ccache --zero-stats + cmake --build . -j $(nproc) --target bitcoin-chainstate + + - name: Ccache stats + run: | + ccache --version | head -n 1 + ccache --show-stats + + - name: Save Ccache cache + uses: actions/cache/save@v4 + if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ github.job }}-${{ matrix.conf.job_name }}-ccache-${{ github.run_id }} + + - name: Run bitcoin-chainstate + run: | + ./build/src/bitcoin-chainstate || [[ $? -eq 1 ]] + + cross-build: name: ${{ matrix.host.name }} runs-on: ubuntu-latest