From 21e66f807cc0b502522f67c8cce61b8381241c0a Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Sun, 4 Feb 2024 13:37:53 -0500 Subject: [PATCH] enable -Wthread-safety for clang --- Makefile.am | 4 ++++ configure.ac | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Makefile.am b/Makefile.am index 0cde401..6aec8c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 702174a..58f9de4 100644 --- a/configure.ac +++ b/configure.ac @@ -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)