enable -Wthread-safety for clang

This commit is contained in:
Aliaksey Kandratsenka 2024-02-04 13:37:53 -05:00
parent 2d35232cfa
commit 21e66f807c
2 changed files with 17 additions and 0 deletions

View File

@ -28,6 +28,10 @@ if HAVE_SIZED_DEALLOCATION
AM_CXXFLAGS += -fsized-deallocation
endif HAVE_SIZED_DEALLOCATION
if ENABLE_W_THREAD_SAFETY
AM_CXXFLAGS += -Wthread-safety
endif ENABLE_W_THREAD_SAFETY
# The -no-undefined flag allows libtool to generate shared libraries for
# Cygwin and MinGW.
AM_LDFLAGS = -no-undefined

View File

@ -234,6 +234,19 @@ AC_CACHE_CHECK(
CXXFLAGS="$OLD_CXXFLAGS"])
AM_CONDITIONAL(ENABLE_FP_FLAGS, [test "x$ac_cv_frame_pointer_cflags" = "xyes"])
# Clang-only (so far?) -Wthread-safety is a useful thing. We want.
AC_CACHE_CHECK(
[compiler and target supports -Wthread-safety],
[ac_cv_w_thread_safety],
[OLD_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wthread-safety"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [])],
[ac_cv_w_thread_safety=yes],
[ac_cv_w_thread_safety=no])
CXXFLAGS="$OLD_CXXFLAGS"])
AM_CONDITIONAL(ENABLE_W_THREAD_SAFETY, [test "x$ac_cv_w_thread_safety" = "xyes"])
AX_C___ATTRIBUTE__
AC_MSG_CHECKING(for __attribute__((aligned(N))) on functions)