From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH v2 09/10] misc: enable thread sanitizer if requested
Date: Thu, 26 Oct 2017 15:24:32 -0700 [thread overview]
Message-ID: <20171026222432.GE5483@magnolia> (raw)
In-Reply-To: <150905614967.28563.13207982162984486911.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
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>
---
configure.ac | 17 +++++++++++++++++
debian/rules | 4 ++--
include/builddefs.in | 4 ++--
m4/package_sanitizer.m4 | 20 ++++++++++++++++++++
4 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 764b22b..210e606 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,12 @@ AC_ARG_ENABLE(addrsan,
enable_addrsan=no)
AC_SUBST(enable_addrsan)
+# Enable THREADSAN; set enable_threadsan=probe to enable autoprobe.
+AC_ARG_ENABLE(threadsan,
+[ --enable-threadsan=[yes/no] Enable Thread Sanitizer (THREADSAN) [default=no]],,
+ enable_threadsan=no)
+AC_SUBST(enable_threadsan)
+
#
# If the user specified a libdir ending in lib64 do not append another
# 64 to the library names.
@@ -174,6 +180,17 @@ if test "$enable_addrsan" = "yes" && test "$have_addrsan" != "yes"; then
AC_MSG_ERROR([ADDRSAN not supported by compiler.])
fi
+if test "$enable_threadsan" = "yes" || test "$enable_threadsan" = "probe"; then
+ AC_PACKAGE_CHECK_THREADSAN
+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
+
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([char *])
AC_TYPE_UMODE_T
diff --git a/debian/rules b/debian/rules
index 6b6f45b..f186d79 100755
--- a/debian/rules
+++ b/debian/rules
@@ -20,9 +20,9 @@ stdenv = @GZIP=-q; export GZIP;
options = export DEBUG=-DNDEBUG DISTRIBUTION=debian \
INSTALL_USER=root INSTALL_GROUP=root \
- LOCAL_CONFIGURE_OPTIONS="--enable-readline=yes --enable-blkid=yes --disable-ubsan --disable-addrsan" ;
+ LOCAL_CONFIGURE_OPTIONS="--enable-readline=yes --enable-blkid=yes --disable-ubsan --disable-addrsan --disable-threadsan" ;
diopts = $(options) \
- export OPTIMIZER=-Os LOCAL_CONFIGURE_OPTIONS="--enable-gettext=no --disable-ubsan --disable-addrsan" ;
+ export OPTIMIZER=-Os LOCAL_CONFIGURE_OPTIONS="--enable-gettext=no --disable-ubsan --disable-addrsan --disable-threadsan" ;
checkdir = test -f debian/rules
build: built
diff --git a/include/builddefs.in b/include/builddefs.in
index 7c78d4b..2df12a7 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -155,8 +155,8 @@ ifeq ($(HAVE_GETFSMAP),yes)
PCFLAGS+= -DHAVE_GETFSMAP
endif
-SANITIZER_CFLAGS += @addrsan_cflags@ @ubsan_cflags@
-SANITIZER_LDFLAGS += @addrsan_ldflags@ @ubsan_ldflags@
+SANITIZER_CFLAGS += @addrsan_cflags@ @threadsan_cflags@ @ubsan_cflags@
+SANITIZER_LDFLAGS += @addrsan_ldflags@ @threadsan_ldflags@ @ubsan_ldflags@
GCFLAGS = $(DEBUG) \
-DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
diff --git a/m4/package_sanitizer.m4 b/m4/package_sanitizer.m4
index 06031ad..41b7299 100644
--- a/m4/package_sanitizer.m4
+++ b/m4/package_sanitizer.m4
@@ -37,3 +37,23 @@ AC_DEFUN([AC_PACKAGE_CHECK_ADDRSAN],
AC_SUBST(addrsan_cflags)
AC_SUBST(addrsan_ldflags)
])
+
+AC_DEFUN([AC_PACKAGE_CHECK_THREADSAN],
+ [ AC_MSG_CHECKING([if C compiler supports THREADSAN])
+ OLD_CFLAGS="$CFLAGS"
+ OLD_LDFLAGS="$LDFLAGS"
+ THREADSAN_FLAGS="-fsanitize=thread"
+ CFLAGS="$CFLAGS $THREADSAN_FLAGS"
+ LDFLAGS="$LDFLAGS $ADRSAN_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)
+ ])
next prev parent reply other threads:[~2017-10-26 22:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 22:14 [PATCH 00/10] xfsprogs: 4.14 rollup Darrick J. Wong
2017-10-26 22:14 ` [PATCH 01/10] db: increase metadump's default overly long extent discard threshold Darrick J. Wong
2017-10-27 0:03 ` Eric Sandeen
2017-10-27 0:12 ` Darrick J. Wong
2017-10-26 22:15 ` [PATCH 02/10] xfsprogs: explicitly cast troublesome types to match printf format specifiers Darrick J. Wong
2017-10-27 0:06 ` Eric Sandeen
2017-10-26 22:15 ` [PATCH 03/10] xfs_io: add new error injection knobs to inject command Darrick J. Wong
2017-10-27 0:09 ` Eric Sandeen
2017-10-26 22:15 ` [PATCH 04/10] xfs_repair: fix bag memory overwrite problems Darrick J. Wong
2017-10-27 0:49 ` Eric Sandeen
2017-10-26 22:15 ` [PATCH 05/10] xfs_repair: clear DAX flag from non-file inodes Darrick J. Wong
2017-10-27 2:01 ` Eric Sandeen
2017-10-26 22:15 ` [PATCH 06/10] xfs_repair: fix cowextsize field checking and repairing Darrick J. Wong
2017-10-27 2:06 ` Eric Sandeen
2017-10-27 16:17 ` Darrick J. Wong
2017-10-27 16:27 ` Eric Sandeen
2017-10-26 22:15 ` [PATCH 07/10] misc: enable ubsan if it's available Darrick J. Wong
2017-10-26 22:23 ` [PATCH v2] misc: enable ubsan if the builder wants it Darrick J. Wong
2017-10-26 22:15 ` [PATCH 08/10] misc: enable gcc/clang address sanitizer Darrick J. Wong
2017-10-26 22:24 ` [PATCH v2 " Darrick J. Wong
2017-10-26 22:15 ` [PATCH 09/10] misc: enable thread Darrick J. Wong
2017-10-26 22:24 ` Darrick J. Wong [this message]
2017-10-26 22:15 ` [PATCH 10/10] misc: fix ubsan warnings Darrick J. Wong
2017-10-27 13:48 ` Eric Sandeen
2017-10-27 16:14 ` Darrick J. Wong
2017-10-27 16:24 ` Eric Sandeen
2017-10-27 16:19 ` [PATCH v2 " Darrick J. Wong
2017-10-26 22:32 ` [PATCH 00/10] xfsprogs: 4.14 rollup Goldwyn Rodrigues
2017-10-27 0:01 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171026222432.GE5483@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox