From 9cfd91a4738b36037968d9a9da65ed449a128346 Mon Sep 17 00:00:00 2001 From: Petr Menšík Date: Dec 04 2019 16:57:12 +0000 Subject: Add ThreadSanitizer support Has to be enabled in build by --with TSAN. Would make build fail unit tests and print many warnings about possible race conditions. Not useful for production build, but useful for debugging thread related problems in system tests. --- diff --git a/bind.spec b/bind.spec index 79e961e..e0522c6 100644 --- a/bind.spec +++ b/bind.spec @@ -31,6 +31,7 @@ %else %bcond_with UNITTEST %endif +%bcond_with TSAN %{?!bind_uid: %global bind_uid 25} %{?!bind_gid: %global bind_gid 25} @@ -244,6 +245,9 @@ BuildRequires: fstrm-devel protobuf-c-devel %endif # Needed to regenerate dig.1 manpage BuildRequires: docbook-style-xsl, libxslt +%if %{with TSAN} +BuildRequires: libtsan +%endif %description BIND (Berkeley Internet Name Domain) is an implementation of the DNS @@ -643,10 +647,15 @@ done cp -Tuav bin/tests "%{1}/bin/tests/" \ cp -uv version "%{1}" \ -export CFLAGS="$CFLAGS $RPM_OPT_FLAGS" +CFLAGS="$CFLAGS $RPM_OPT_FLAGS" +%if %{with TSAN} + CFLAGS+=" -O1 -fsanitize=thread -fPIE -pie" +%endif +export CFLAGS export CPPFLAGS="$CPPFLAGS -DDIG_SIGCHASE" export STD_CDEFINES="$CPPFLAGS" + sed -i -e \ 's/RELEASEVER=\(.*\)/RELEASEVER=\1-RedHat-%{version}-%{release}/' \ version @@ -850,6 +859,10 @@ sed -e "/^\s*include(/ d" -e 's/^-- use //' \ eval "$(bash %{SOURCE48} -A "`pwd`/softhsm-tokens")" %endif +%if %{with TSAN} +export TSAN_OPTIONS="log_exe_name=true log_path=ThreadSanitizer exitcode=0" +%endif + %if %{with UNITTEST} pushd build make unit