build: add option to compile with ThreadSanitizer
ThreadSanitizer is a debugging tool that can detect threads that race for data modifications. These races can result in data corruption and are difficult to track and fix. Change-Id: Ibbdaf17c811e30e79cd5bdcf9cd9ff2d0cdb2abb URL: https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual Reported-by: Yaniv Kaul <ykaul@redhat.com> Fixes: #543 Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
fc9889d037
commit
b2a5098982
14
configure.ac
14
configure.ac
@ -299,6 +299,19 @@ else
|
||||
BUILD_ASAN=no
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([atan],
|
||||
AC_HELP_STRING([--enable-tsan],
|
||||
[Enable ThreadSanitizer support]))
|
||||
if test "x$enable_tsan" = "xyes"; then
|
||||
BUILD_TSAN=yes
|
||||
AC_CHECK_LIB([tsan], [__tsan_init], ,
|
||||
[AC_MSG_ERROR([libtsan.so not found, this is required for --enable-tsan])])
|
||||
GF_CFLAGS="${GF_CFLAGS} -O2 -g -fsanitize=thread"
|
||||
GF_LDFLAGS="${GF_LDFLAGS} -ltsan"
|
||||
else
|
||||
BUILD_TSAN=no
|
||||
fi
|
||||
|
||||
|
||||
dnl When possible, prefer libtirpc over glibc rpc.
|
||||
dnl
|
||||
@ -1597,6 +1610,7 @@ echo "georeplication : $BUILD_SYNCDAEMON"
|
||||
echo "Linux-AIO : $BUILD_LIBAIO"
|
||||
echo "Enable Debug : $BUILD_DEBUG"
|
||||
echo "Enable ASAN : $BUILD_ASAN"
|
||||
echo "Enable TSAN : $BUILD_TSAN"
|
||||
echo "Use syslog : $USE_SYSLOG"
|
||||
echo "XML output : $BUILD_XML_OUTPUT"
|
||||
echo "Encryption xlator : $BUILD_CRYPT_XLATOR"
|
||||
|
@ -112,6 +112,15 @@
|
||||
%global _without_syslog --disable-syslog
|
||||
%endif
|
||||
|
||||
# tsan
|
||||
# if you wish to compile an rpm with thread sanitizer...
|
||||
# rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --with tsan
|
||||
%{?_with_tsan:%global _with_tsan --enable-tsan}
|
||||
|
||||
%if ( 0%{?rhel} && 0%{?rhel} < 7 )
|
||||
%global _with_tsan %{nil}
|
||||
%endif
|
||||
|
||||
# valgrind
|
||||
# if you wish to compile an rpm to run all processes under valgrind...
|
||||
# rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --with valgrind
|
||||
@ -247,6 +256,9 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
||||
%if 0%{?_with_asan:1} && !( 0%{?rhel} && 0%{?rhel} < 7 )
|
||||
BuildRequires: libasan
|
||||
%endif
|
||||
%if 0%{?_with_tsan:1} && !( 0%{?rhel} && 0%{?rhel} < 7 )
|
||||
BuildRequires: libtsan
|
||||
%endif
|
||||
BuildRequires: bison flex
|
||||
BuildRequires: gcc make libtool
|
||||
BuildRequires: ncurses-devel readline-devel
|
||||
@ -684,6 +696,7 @@ done
|
||||
%{?_with_firewalld} \
|
||||
%{?_with_gnfs} \
|
||||
%{?_with_tmpfilesdir} \
|
||||
%{?_with_tsan} \
|
||||
%{?_with_valgrind} \
|
||||
%{?_without_epoll} \
|
||||
%{?_without_events} \
|
||||
@ -1373,6 +1386,9 @@ exit 0
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Nov 13 2018 Niels de Vos <ndevos@redhat.com>
|
||||
- Add an option to build with ThreadSanitizer (TSAN)
|
||||
|
||||
* Fri Sep 7 2018 Niels de Vos <ndevos@redhat.com>
|
||||
- Add an option to build with address sanitizer (ASAN)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user