Skip to content

[build] Add HAVE_THREAD_LOCAL check

This adds thread local check to cmake.

It is an alternative implementation of f7f7e2cd3 by Cory Fields from Bitcoin Core, where this patch is implemented for autoconf.

This is a prerequisite for !834 (merged). This will also allow us to remove boost use in sync.cpp, as done in bba9bd0.

Test plan:

Step 1: See that it is defined

On a system that supports thread_local, run cmake -GNinja ... Observe that HAVE_THREAD_LOCAL is defined in build/src/config/bitcoin-config.h.

Step 2: See that it's undefined

On same system, change this patch so that -pthread is removed from set(CMAKE_REQUIRED_LINK_OPTIONS "-pthread;${CMAKE_REQUIRED_LINK_OPTIONS}").

Clear build directory, run cmake -GNinja ... Observe that HAVE_THREAD_LOCAL is undefined in build/src/config/bitcoin-config.h.

Observe that HAVE_THREAD_LOCAL is undefined in build/src/config/bitcoin-config.h

Edited by Dagur Valberg Johannsson

Merge request reports