From 65b4695375c6518c0b51a2a4c8392ab9d461e317 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 28 Mar 2020 09:07:15 +0100 Subject: [PATCH] tsan: fix build bugs 1. Fix expression inside of DCHECK_LE. 2. Add a debug build test to buildgo.sh. 3. Fix race binary path in buildgo.sh. --- compiler-rt/lib/tsan/go/buildgo.sh | 20 ++++++++++++-------- compiler-rt/lib/tsan/rtl/tsan_clock.cpp | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh index 5156bd6f..bd7e067 100755 --- a/compiler-rt/lib/tsan/go/buildgo.sh +++ b/compiler-rt/lib/tsan/go/buildgo.sh @@ -150,15 +150,19 @@ for F in $SRCS; do done FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO=1 -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS $ARCHCFLAGS" +DEBUG_FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g" +FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer" +if [ "$SUFFIX" = "linux_ppc64le" ]; then + FLAGS="$FLAGS -mcpu=power8 -fno-function-sections" +elif [ "$SUFFIX" = "linux_amd64" ]; then + FLAGS="$FLAGS -msse3" +fi + if [ "$DEBUG" = "" ]; then - FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer" - if [ "$SUFFIX" = "linux_ppc64le" ]; then - FLAGS="$FLAGS -mcpu=power8 -fno-function-sections" - elif [ "$SUFFIX" = "linux_amd64" ]; then - FLAGS="$FLAGS -msse3" - fi + # Do a build test with debug flags. + $CC $DIR/gotsan.cpp -c -o $DIR/race_debug_$SUFFIX.syso $DEBUG_FLAGS $CFLAGS else - FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g" + FLAGS="$DEBUG_FLAGS" fi if [ "$SILENT" != "1" ]; then @@ -169,7 +173,7 @@ $CC $DIR/gotsan.cpp -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS $CC $OSCFLAGS $ARCHCFLAGS test.c $DIR/race_$SUFFIX.syso -g -o $DIR/test $OSLDFLAGS $LDFLAGS # Verify that no glibc specific code is present -if nm race_$SUFFIX.syso | grep -q __libc_; then +if nm $DIR/race_$SUFFIX.syso | grep -q __libc_; then printf -- '%s seems to link to libc\n' "race_$SUFFIX.syso" exit 1 fi diff --git a/compiler-rt/lib/tsan/rtl/tsan_clock.cpp b/compiler-rt/lib/tsan/rtl/tsan_clock.cpp index 7989a90..96bbfa1 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_clock.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_clock.cpp @@ -187,7 +187,7 @@ void ThreadClock::acquire(ClockCache *c, SyncClock *src) { void ThreadClock::releaseStoreAcquire(ClockCache *c, SyncClock *sc) { DCHECK_LE(nclk_, kMaxTid); - DCHECK_LE(dst->size_, kMaxTid); + DCHECK_LE(sc->size_, kMaxTid); if (sc->size_ == 0) { // ReleaseStore will correctly set release_store_tid_, -- 2.7.4