Skip to content

Commit

Permalink
Merge #100: [BUGFIX] cmake: Fix HAVE_THREAD_LOCAL macro visibility
Browse files Browse the repository at this point in the history
cbd43cc fixup! cmake: Build `bitcoind` executable (Hennadii Stepanov)
6be6d78 fixup! cmake: Build `bitcoin_util` static library (Hennadii Stepanov)

Pull request description:

  The `HAVE_THREAD_LOCAL` is not visible in `src/test/util_threadnames_tests.cpp`. It is easy to verify with the diff as follows:
  ```diff
  --- a/src/test/util_threadnames_tests.cpp
  +++ b/src/test/util_threadnames_tests.cpp
  @@ -55,6 +55,7 @@ std::set<std::string> RenameEnMasse(int num_threads)
   BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded)
   {
   #if !defined(HAVE_THREAD_LOCAL)
  +#error
       // This test doesn't apply to platforms where we don't have thread_local.
       return;
   #endif
  ```

  This PR fixes this issue by moving the macro definition to the `core_interface` library.

  Split from #84.

ACKs for top commit:
  vasild:
    ACK cbd43cc

Tree-SHA512: bd558ae35251d0e9bbdf494690a06ed57f6a36bdbf94840f1b134779bef5aa1de94ee53c962948a5a4b9cc11927777b5a919a7506779149e5fe0c6355c416419
  • Loading branch information
hebasto committed Feb 15, 2024
2 parents 2082e3d + cbd43cc commit 68246bc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cmake/module/AddThreadsIfNeeded.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function(add_threads_if_needed)
find_package(Threads REQUIRED)
set_target_properties(Threads::Threads PROPERTIES IMPORTED_GLOBAL TRUE)

set(thread_local)
if(MINGW)
#[=[
mingw32's implementation of thread_local has been shown to behave
Expand All @@ -36,7 +35,8 @@ function(add_threads_if_needed)
- https://groups.google.com/d/msg/bsdmailinglist/22ncTZAbDp4/Dii_pII5AwAJ
]=]
elseif(THREADLOCAL)
set(thread_local "$<$<COMPILE_FEATURES:cxx_thread_local>:HAVE_THREAD_LOCAL>")
target_compile_definitions(core_interface INTERFACE
"$<$<COMPILE_FEATURES:cxx_thread_local>:HAVE_THREAD_LOCAL>"
)
endif()
set(THREAD_LOCAL_IF_AVAILABLE "${thread_local}" PARENT_SCOPE)
endfunction()
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ add_library(bitcoin_common STATIC EXCLUDE_FROM_ALL
script/solver.cpp
warnings.cpp
)
target_compile_definitions(bitcoin_common
PRIVATE
${THREAD_LOCAL_IF_AVAILABLE}
)
target_link_libraries(bitcoin_common
PRIVATE
core_interface
Expand Down
1 change: 0 additions & 1 deletion src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ add_library(bitcoin_util STATIC EXCLUDE_FROM_ALL

target_compile_definitions(bitcoin_util
PRIVATE
${THREAD_LOCAL_IF_AVAILABLE}
$<$<CXX_COMPILER_ID:MSVC>:_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING>
)

Expand Down

0 comments on commit 68246bc

Please sign in to comment.