configure: Add flag for enabling thread_local.

- When aiming for glibc compatibility, don't use thread_local.
- Add a flag --enable-threadlocal, which, when specified, will
  enable/disable thread_local regardless of the value of glibc_compat.
- FreeBSD has a buggy thread_local, don't use it.
This commit is contained in:
Carl Dong 2019-05-20 13:22:29 -04:00
parent 149b3477ec
commit 480e3415d7

View file

@ -194,6 +194,12 @@ AC_ARG_ENABLE([glibc-back-compat],
[use_glibc_compat=$enableval], [use_glibc_compat=$enableval],
[use_glibc_compat=no]) [use_glibc_compat=no])
AC_ARG_ENABLE([threadlocal],
[AS_HELP_STRING([--enable-threadlocal],
[enable features that depend on the c++ thread_local keyword (currently just thread names in debug logs). (default is to enabled if there is platform support and glibc-back-compat is not enabled)])],
[use_thread_local=$enableval],
[use_thread_local=auto])
AC_ARG_ENABLE([asm], AC_ARG_ENABLE([asm],
[AS_HELP_STRING([--disable-asm], [AS_HELP_STRING([--disable-asm],
[disable assembly routines (enabled by default)])], [disable assembly routines (enabled by default)])],
@ -827,6 +833,7 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
] ]
) )
if test "x$use_thread_local" = xyes || { test "x$use_thread_local" = xauto && test "x$use_glibc_compat" = xno; }; then
TEMP_LDFLAGS="$LDFLAGS" TEMP_LDFLAGS="$LDFLAGS"
LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS" LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS"
AC_MSG_CHECKING([for thread_local support]) AC_MSG_CHECKING([for thread_local support])
@ -852,6 +859,11 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
# supported (per https://stackoverflow.com/a/29929949) # supported (per https://stackoverflow.com/a/29929949)
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
;; ;;
*freebsd*)
# FreeBSD's implementation of thread_local is also buggy (per
# https://groups.google.com/d/msg/bsdmailinglist/22ncTZAbDp4/Dii_pII5AwAJ)
AC_MSG_RESULT(no)
;;
*) *)
AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define if thread_local is supported.]) AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define if thread_local is supported.])
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
@ -863,6 +875,7 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
] ]
) )
LDFLAGS="$TEMP_LDFLAGS" LDFLAGS="$TEMP_LDFLAGS"
fi
# Check for different ways of gathering OS randomness # Check for different ways of gathering OS randomness
AC_MSG_CHECKING(for Linux getrandom syscall) AC_MSG_CHECKING(for Linux getrandom syscall)