Skip to content

Commit b7febbe

Browse files
committed
merge bitcoin#30137: Remove --enable-threadlocal
1 parent dcf67c7 commit b7febbe

File tree

5 files changed

+2
-69
lines changed

5 files changed

+2
-69
lines changed

configure.ac

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,6 @@ AC_ARG_ENABLE([lcov-branch-coverage],
237237
[use_lcov_branch=yes],
238238
[use_lcov_branch=no])
239239

240-
AC_ARG_ENABLE([threadlocal],
241-
[AS_HELP_STRING([--enable-threadlocal],
242-
[enable features that depend on the c++ thread_local keyword (currently just thread names in debug logs). (default is to enable if there is platform support)])],
243-
[use_thread_local=$enableval],
244-
[use_thread_local=auto])
245-
246240
AC_ARG_ENABLE([zmq],
247241
[AS_HELP_STRING([--disable-zmq],
248242
[disable ZMQ notifications])],
@@ -1192,40 +1186,6 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
11921186
[AC_MSG_RESULT([no])]
11931187
)
11941188

1195-
if test "$use_thread_local" = "yes" || test "$use_thread_local" = "auto"; then
1196-
TEMP_LDFLAGS="$LDFLAGS"
1197-
LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS"
1198-
AC_MSG_CHECKING([for thread_local support])
1199-
AC_LINK_IFELSE([AC_LANG_SOURCE([
1200-
#include <thread>
1201-
static thread_local int foo = 0;
1202-
static void run_thread() { foo++;}
1203-
int main(){
1204-
for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();}
1205-
return foo;
1206-
}
1207-
])],
1208-
[
1209-
case $host in
1210-
*mingw*)
1211-
dnl mingw32's implementation of thread_local has also been shown to behave
1212-
dnl erroneously under concurrent usage; see:
1213-
dnl https://gist.github.com/jamesob/fe9a872051a88b2025b1aa37bfa98605
1214-
AC_MSG_RESULT([no])
1215-
;;
1216-
*)
1217-
AC_DEFINE([HAVE_THREAD_LOCAL], [1], [Define if thread_local is supported.])
1218-
AC_MSG_RESULT([yes])
1219-
;;
1220-
esac
1221-
],
1222-
[
1223-
AC_MSG_RESULT([no])
1224-
]
1225-
)
1226-
LDFLAGS="$TEMP_LDFLAGS"
1227-
fi
1228-
12291189
BACKTRACE_FLAGS=
12301190
BACKTRACE_LDFLAGS=
12311191
BACKTRACE_LIBS=

src/init/common.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ void AddLoggingArgs(ArgsManager& argsman)
6767
argsman.AddArg("-logips", strprintf("Include IP addresses in debug output (default: %u)", DEFAULT_LOGIPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
6868
argsman.AddArg("-loglevel=<level>|<category>:<level>", strprintf("Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC: %s (default=%s); warning and error levels are always logged. If <category>:<level> is supplied, the setting will override the global one and may be specified multiple times to set multiple category-specific levels. <category> can be: %s.", LogInstance().LogLevelsString(), LogInstance().LogLevelToStr(BCLog::DEFAULT_LOG_LEVEL), LogInstance().LogCategoriesString()), ArgsManager::DISALLOW_NEGATION | ArgsManager::DISALLOW_ELISION | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
6969
argsman.AddArg("-logtimestamps", strprintf("Prepend debug output with timestamp (default: %u)", DEFAULT_LOGTIMESTAMPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
70-
#ifdef HAVE_THREAD_LOCAL
7170
argsman.AddArg("-logthreadnames", strprintf("Prepend debug output with name of the originating thread (only available on platforms supporting thread_local) (default: %u)", DEFAULT_LOGTHREADNAMES), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
72-
#else
73-
argsman.AddHiddenArgs({"-logthreadnames"});
74-
#endif
7571
argsman.AddArg("-logsourcelocations", strprintf("Prepend debug output with name of the originating source location (source file, line number and function name) (default: %u)", DEFAULT_LOGSOURCELOCATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
7672
argsman.AddArg("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
7773
argsman.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -daemon. To disable logging to file, set -nodebuglogfile)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
@@ -85,9 +81,7 @@ void SetLoggingOptions(const ArgsManager& args)
8581
LogInstance().m_print_to_console = args.GetBoolArg("-printtoconsole", !args.GetBoolArg("-daemon", false));
8682
LogInstance().m_log_timestamps = args.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
8783
LogInstance().m_log_time_micros = args.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
88-
#ifdef HAVE_THREAD_LOCAL
8984
LogInstance().m_log_threadnames = args.GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES);
90-
#endif
9185
LogInstance().m_log_sourcelocations = args.GetBoolArg("-logsourcelocations", DEFAULT_LOGSOURCELOCATIONS);
9286

9387
fLogIPs = args.GetBoolArg("-logips", DEFAULT_LOGIPS);

src/test/util/setup_common.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::os
4848
/**
4949
* This global and the helpers that use it are not thread-safe.
5050
*
51-
* If thread-safety is needed, the global could be made thread_local (given
52-
* that thread_local is supported on all architectures we support) or a
53-
* per-thread instance could be used in the multi-threaded test.
51+
* If thread-safety is needed, a per-thread instance could be
52+
* used in the multi-threaded test.
5453
*/
5554
extern FastRandomContext g_insecure_rand_ctx;
5655

src/test/util_threadnames_tests.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#include <thread>
1212
#include <vector>
1313

14-
#if defined(HAVE_CONFIG_H)
15-
#include <config/bitcoin-config.h>
16-
#endif
17-
1814
#include <boost/test/unit_test.hpp>
1915

2016
BOOST_AUTO_TEST_SUITE(util_threadnames_tests)
@@ -53,11 +49,6 @@ std::set<std::string> RenameEnMasse(int num_threads)
5349
*/
5450
BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded)
5551
{
56-
#if !defined(HAVE_THREAD_LOCAL)
57-
// This test doesn't apply to platforms where we don't have thread_local.
58-
return;
59-
#endif
60-
6152
std::set<std::string> names = RenameEnMasse(100);
6253

6354
BOOST_CHECK_EQUAL(names.size(), 100U);

src/util/threadnames.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ static void SetThreadName(const char* name)
3939
#endif
4040
}
4141

42-
// If we have thread_local, just keep thread ID and name in a thread_local
43-
// global.
44-
#if defined(HAVE_THREAD_LOCAL)
45-
4642
/**
4743
* The name of the thread. We use char array instead of std::string to avoid
4844
* complications with running a destructor when the thread exits. Avoid adding
@@ -60,13 +56,6 @@ static void SetInternalName(const std::string& name)
6056
g_thread_name[copy_bytes] = '\0';
6157
}
6258

63-
// Without thread_local available, don't handle internal name at all.
64-
#else
65-
66-
std::string util::ThreadGetInternalName() { return ""; }
67-
static void SetInternalName(const std::string& name) { }
68-
#endif
69-
7059
void util::ThreadRename(const std::string& name)
7160
{
7261
SetThreadName(("d-" + name).c_str());

0 commit comments

Comments
 (0)