diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-03-08 12:15:43 -0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2018-08-08 11:16:15 -0400 |
commit | bcca786b836a4f2764b16489c41f2d1239faaa01 (patch) | |
tree | 46c68346338b071d5ea2c8ad8bcd3761bb68253c /configure.ac | |
parent | 5e666e3d8846e695650ae757d3626547cfd05cbf (diff) |
enable thread sanitizer if the builder wants it
Enable the gcc/clang thread data corruption sanitizer if the builder
requests it and it's available.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 62581f6b..fe717d09 100644 --- a/configure.ac +++ b/configure.ac @@ -1386,6 +1386,37 @@ if test "$enable_addrsan" = "yes" && test "$have_addrsan" != "yes"; then AC_MSG_ERROR([ADDRSAN not supported by compiler.]) fi dnl +dnl Enable THREADSAN for all packages +dnl +AC_ARG_ENABLE([threadsan], +[ --enable-threadsan enable thread sanitizer],, +enable_threadsan=no) +if test "$enable_threadsan" = "yes" || test "$enable_threadsan" = "probe"; then + AC_MSG_CHECKING([if C compiler supports THREADSAN]) + OLD_CFLAGS="$CFLAGS" + OLD_LDFLAGS="$LDFLAGS" + THREADSAN_FLAGS="-fsanitize=thread" + CFLAGS="$CFLAGS $THREADSAN_FLAGS" + LDFLAGS="$LDFLAGS $THREADSAN_FLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [threadsan_cflags=$THREADSAN_FLAGS] + [threadsan_ldflags=$THREADSAN_FLAGS] + [have_threadsan=yes], + [AC_MSG_RESULT([no])]) + CFLAGS="${OLD_CFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + AC_SUBST(have_threadsan) + AC_SUBST(threadsan_cflags) + AC_SUBST(threadsan_ldflags) +fi +if test "$enable_threadsan" = "yes" && test "$have_threadsan" != "yes"; then + AC_MSG_ERROR([THREADSAN not supported by compiler.]) +fi +if test "$have_threadsan" = "yes" && test "$have_addrsan" = "yes"; then + AC_MSG_WARN([ADDRSAN and THREADSAN are not known to work together.]) +fi +dnl dnl OS-specific uncomment control dnl LINUX_CMT="#" |