Skip to content

Commit 3b65982

Browse files
committed
Merge hebasto#242: cmake: Keep RPATH for the bitcoin-chainstate target in the build tree
f39a181 fixup! ci: Test CMake edge cases (Hennadii Stepanov) aadee95 fixup! cmake: Do not add the rpath information to compiled executables (Hennadii Stepanov) Pull request description: This is a follow-up of bitcoin#30312 and hebasto#236. On staging branch @ 8b80c1a: ``` $ cmake -B build -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_SHARED_LIBS=ON $ cmake --build build -t bitcoin-chainstate $ ./build/src/bitcoin-chainstate ./build/src/bitcoin-chainstate: error while loading shared libraries: libbitcoinkernel.so: cannot open shared object file: No such file or directory ``` This PR fixes this issue and adds a new CI job to check it. ACKs for top commit: m3dwards: ACK f39a181 theuni: ACK f39a181 Tree-SHA512: 845b956d3d9791e75baf4d9865501b273aea52210022e0da8efe311d758f5eff901c7bc839d521ec967967d5edd4c5ed3b245294287207b0a65e3fd18c54cc29
2 parents 119b07e + f39a181 commit 3b65982

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

.github/workflows/cmake.yml

+63
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,69 @@ jobs:
262262
./install/bin/bitcoind -version
263263
264264
265+
ubuntu-chainstate:
266+
name: 'Ubuntu, chainstate + ${{ matrix.conf.job_name }} libkernel'
267+
runs-on: ubuntu-latest
268+
269+
strategy:
270+
fail-fast: false
271+
matrix:
272+
conf:
273+
- shared_libs: '-DBUILD_SHARED_LIBS=OFF'
274+
job_name: 'STATIC'
275+
- shared_libs: '-DBUILD_SHARED_LIBS=ON'
276+
job_name: 'SHARED'
277+
278+
steps:
279+
- name: Checkout
280+
uses: actions/checkout@v4
281+
282+
- name: Install packages
283+
run: |
284+
sudo apt-get update
285+
sudo apt-get install --no-install-recommends ccache libboost-dev libevent-dev
286+
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"
287+
288+
- name: CMake version
289+
run: |
290+
cmake --version
291+
ctest --version
292+
293+
- name: Restore Ccache cache
294+
uses: actions/cache/restore@v4
295+
id: ccache-cache
296+
with:
297+
path: ${{ env.CCACHE_DIR }}
298+
key: ${{ github.job }}-ccache-${{ github.run_id }}
299+
restore-keys: ${{ github.job }}-${{ matrix.conf.job_name }}-ccache-
300+
301+
- name: Generate build system
302+
run: |
303+
cmake -B build -DBUILD_UTIL_CHAINSTATE=ON ${{ matrix.conf.shared_libs }}
304+
305+
- name: Build
306+
working-directory: build
307+
run: |
308+
ccache --zero-stats
309+
cmake --build . -j $(nproc) --target bitcoin-chainstate
310+
311+
- name: Ccache stats
312+
run: |
313+
ccache --version | head -n 1
314+
ccache --show-stats
315+
316+
- name: Save Ccache cache
317+
uses: actions/cache/save@v4
318+
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
319+
with:
320+
path: ${{ env.CCACHE_DIR }}
321+
key: ${{ github.job }}-${{ matrix.conf.job_name }}-ccache-${{ github.run_id }}
322+
323+
- name: Run bitcoin-chainstate
324+
run: |
325+
./build/src/bitcoin-chainstate || [[ $? -eq 1 ]]
326+
327+
265328
cross-build:
266329
name: ${{ matrix.host.name }}
267330
runs-on: ubuntu-latest

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,14 @@ if(DEFINED ENV{LDFLAGS})
599599
deduplicate_flags(CMAKE_EXE_LINKER_FLAGS)
600600
endif()
601601

602-
set(CMAKE_SKIP_RPATH TRUE)
602+
# TODO: The `CMAKE_SKIP_BUILD_RPATH` variable setting can be deleted
603+
# in the future after reordering Guix script commands to
604+
# perform binary checks after the installation step.
605+
# Relevant discussions:
606+
# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953
607+
# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833
608+
set(CMAKE_SKIP_BUILD_RPATH TRUE)
609+
set(CMAKE_SKIP_INSTALL_RPATH TRUE)
603610
add_subdirectory(src)
604611
add_subdirectory(test)
605612
add_subdirectory(doc)

src/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,15 @@ if(BUILD_UTIL_CHAINSTATE)
355355
add_executable(bitcoin-chainstate
356356
bitcoin-chainstate.cpp
357357
)
358+
# TODO: The `SKIP_BUILD_RPATH` property setting can be deleted
359+
# in the future after reordering Guix script commands to
360+
# perform binary checks after the installation step.
361+
# Relevant discussions:
362+
# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953
363+
# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833
364+
set_target_properties(bitcoin-chainstate PROPERTIES
365+
SKIP_BUILD_RPATH OFF
366+
)
358367
target_link_libraries(bitcoin-chainstate
359368
PRIVATE
360369
core_interface

0 commit comments

Comments
 (0)