tsan: fix build bugs
authorDmitry Vyukov <dvyukov@google.com>
Sat, 28 Mar 2020 08:07:15 +0000 (09:07 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Sat, 28 Mar 2020 08:09:39 +0000 (09:09 +0100)
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
compiler-rt/lib/tsan/rtl/tsan_clock.cpp

index 5156bd6..bd7e067 100755 (executable)
@@ -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
index 7989a90..96bbfa1 100644 (file)
@@ -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_,