Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -102,12 +102,14 @@ # Sanity check for Go runtime. set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh) -add_custom_target(GotsanRuntimeCheck - COMMAND CC=${CMAKE_C_COMPILER} IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT} - DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go - COMMENT "Checking TSan Go runtime..." - VERBATIM) +foreach(arch ${TSAN_SUPPORTED_ARCH}) + add_custom_target(GotsanRuntimeCheck + COMMAND CC=${CMAKE_C_COMPILER} IN_TMPDIR=1 SILENT=1 ${BUILDGO_SCRIPT} + DEPENDS clang_rt.tsan-${arch} ${BUILDGO_SCRIPT} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/go + COMMENT "Checking TSan Go runtime..." + VERBATIM) +endforeach() # Build libcxx instrumented with TSan. if(TSAN_SUPPORTED_ARCH AND Index: lib/tsan/go/buildgo.sh =================================================================== --- lib/tsan/go/buildgo.sh +++ lib/tsan/go/buildgo.sh @@ -34,12 +34,16 @@ " if [ "`uname -a | grep Linux`" != "" ]; then - SUFFIX="linux_amd64" OSCFLAGS="-fPIC -ffreestanding -Wno-maybe-uninitialized -Wno-unused-const-variable -Werror -Wno-unknown-warning-option" OSLDFLAGS="-lpthread -fPIC -fpie" + if [ "`uname -a | grep x86_64`" != "" ]; then + SUFFIX="linux_amd64" + elif [ "`uname -a | grep mips64`" != "" ]; then + SUFFIX="linux_mips64" + OSCFLAGS="$OSCFLAGS -Wno-unused-function" + fi SRCS=" $SRCS - ../rtl/tsan_platform_linux.cc ../../sanitizer_common/sanitizer_posix.cc ../../sanitizer_common/sanitizer_posix_libcdep.cc ../../sanitizer_common/sanitizer_procmaps_common.cc @@ -47,6 +51,7 @@ ../../sanitizer_common/sanitizer_linux.cc ../../sanitizer_common/sanitizer_linux_libcdep.cc ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc + ../rtl/tsan_platform_linux.cc " elif [ "`uname -a | grep FreeBSD`" != "" ]; then SUFFIX="freebsd_amd64" @@ -112,11 +117,15 @@ FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS" if [ "$DEBUG" = "" ]; then - FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer" + FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer" else FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g" fi +if [ "`uname -a | grep x86_64`" != "" ]; then + FLAGS="$FLAGS -msse3" +fi + if [ "$SILENT" != "1" ]; then echo $CC gotsan.cc -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS fi Index: lib/tsan/rtl/tsan_platform.h =================================================================== --- lib/tsan/rtl/tsan_platform.h +++ lib/tsan/rtl/tsan_platform.h @@ -104,7 +104,8 @@ #elif defined(SANITIZER_GO) && !SANITIZER_WINDOWS -/* Go on linux, darwin and freebsd +#if defined(__x86_64__) +/* Go on linux/x86_64, darwin/x86_64 and freebsd/x86_64 0000 0000 1000 - 0000 1000 0000: executable 0000 1000 0000 - 00c0 0000 0000: - 00c0 0000 0000 - 00e0 0000 0000: heap @@ -125,6 +126,27 @@ const uptr kShadowEnd = 0x238000000000ull; const uptr kAppMemBeg = 0x000000001000ull; const uptr kAppMemEnd = 0x00e000000000ull; +#elif defined(__mips64) +/* Go on linux/mips64 +0100 0000 00 - 0140 0000 00: executable and heap +0140 0000 00 - 2200 0000 00: - +2200 0000 00 - 2700 0000 00: shadow +2700 0000 00 - 3000 0000 00: - +3000 0000 00 - 4000 0000 00: metainfo (memory blocks and sync objects) +4000 0000 00 - 6000 0000 00: - +6000 0000 00 - 6200 0000 00: traces +6200 0000 00 - ffff ffff ff: - +*/ + +const uptr kMetaShadowBeg = 0x3000000000ull; +const uptr kMetaShadowEnd = 0x4000000000ull; +const uptr kTraceMemBeg = 0x6000000000ull; +const uptr kTraceMemEnd = 0x6200000000ull; +const uptr kShadowBeg = 0x2200000000ull; +const uptr kShadowEnd = 0x2700000000ull; +const uptr kAppMemBeg = 0x0100000000ull; +const uptr kAppMemEnd = 0x0140000000ull; +#endif ALWAYS_INLINE bool IsAppMem(uptr mem) {