Skip to content

Commit

Permalink
Merge #235: [FIXUP] cmake: Link Threads::Threads to `core_base_inte…
Browse files Browse the repository at this point in the history
…rface`

0772957 [FIXUP] cmake: Link `Threads::Threads` to `core_base_interface` (Hennadii Stepanov)

Pull request description:

  This PR fixes compiling using `-pthread` flag on UNIX systems with a non-POSIX default thread model.

  Details:

  1. During tests on SunOS / illumos (OpenIndiana Hipster 2024.04 distribution), wallet-specific unit tests and benchmarks exhibited deadlock-like behavior. It [seems](https://gitlab.kitware.com/cmake/cmake/-/issues/26063) that POSIX threads were expected but not properly utilized.

  2. Despite applying a patch to CMake, the staging branch continued to fail due to a bug that is resolved with this PR.

  ---

  UPD. Currently, a workaround can be applied: `-DAPPEND_CPPFLAGS="-pthread"`.

ACKs for top commit:
  fanquake:
    ACK 0772957

Tree-SHA512: c2e219792bb79b355d34335f19efb9a1adc81e7eeb9bc2b7aaa1b35967bffdbced5d887a00892b5d43b035998ee689d9c9263298f789b04826da6537b37b002b
  • Loading branch information
hebasto committed Jun 24, 2024
2 parents cea0fa2 + 0772957 commit 8b80c1a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()
endif()

include(AddThreadsIfNeeded)
add_threads_if_needed()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(core_base_interface INTERFACE
Threads::Threads
)

if(SANITIZERS)
# First check if the compiler accepts flags. If an incompatible pair like
Expand Down
21 changes: 0 additions & 21 deletions cmake/module/AddThreadsIfNeeded.cmake

This file was deleted.

1 change: 0 additions & 1 deletion src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ target_link_libraries(bitcoin_util
core_interface
bitcoin_clientversion
bitcoin_crypto
Threads::Threads
$<$<PLATFORM_ID:Windows>:ws2_32>
)

0 comments on commit 8b80c1a

Please sign in to comment.