configure: add support for thread sanitizer (--enable-tsan)
authorMatthias Maennich <maennich@google.com>
Thu, 12 Mar 2020 11:31:57 +0000 (12:31 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 18 Mar 2020 10:10:25 +0000 (11:10 +0100)
Similarly to asan and ubsan, add support for tsan conditionally at
configure time. This allows us to track down race conditions etc.

* configure.ac: Add configure options for -fsanitize=thread

Signed-off-by: Matthias Maennich <maennich@google.com>
configure.ac

index ba800a72ac7a4333473d093e6842da7b767915ab..50a50c6c8932c23c1ac0c477b8a804f2bf509872 100644 (file)
@@ -120,6 +120,12 @@ AC_ARG_ENABLE(asan,
              ENABLE_ASAN=$enableval,
              ENABLE_ASAN=no)
 
+AC_ARG_ENABLE(tsan,
+             AS_HELP_STRING([--enable-tsan=yes|no],
+                            [enable the support of building with -fsanitize=thread)]),
+             ENABLE_TSAN=$enableval,
+             ENABLE_TSAN=no)
+
 AC_ARG_ENABLE(ubsan,
              AS_HELP_STRING([--enable-ubsan=yes|no],
                             [enable the support of building with -fsanitize=undefined)]),
@@ -614,6 +620,11 @@ if test x$ENABLE_ASAN = xyes; then
     CXXFLAGS="$CXXFLAGS -fsanitize=address"
 fi
 
+if test x$ENABLE_TSAN = xyes; then
+    CFLAGS="$CFLAGS -fsanitize=thread"
+    CXXFLAGS="$CXXFLAGS -fsanitize=thread"
+fi
+
 if test x$ENABLE_UBSAN = xyes; then
     CFLAGS="$CFLAGS -fsanitize=undefined"
     CXXFLAGS="$CXXFLAGS -fsanitize=undefined"
@@ -907,6 +918,7 @@ AC_MSG_NOTICE([
     Enable python 3                               : ${ENABLE_PYTHON3}
     Enable running tests under Valgrind            : ${enable_valgrind}
     Enable build with -fsanitize=address          : ${ENABLE_ASAN}
+    Enable build with -fsanitize=thread           : ${ENABLE_TSAN}
     Enable build with -fsanitize=undefined        : ${ENABLE_UBSAN}
     Generate html apidoc                          : ${ENABLE_APIDOC}
     Generate html manual                          : ${ENABLE_MANUAL}