Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -102,6 +102,7 @@ # Sanity check for Go runtime. set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh) +set(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} Index: lib/tsan/go/buildgo.sh =================================================================== --- lib/tsan/go/buildgo.sh +++ lib/tsan/go/buildgo.sh @@ -33,7 +33,7 @@ ../../sanitizer_common/sanitizer_symbolizer.cc " -if [ "`uname -a | grep Linux`" != "" ]; then +if [ "`uname -a | grep x86_64 | 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" @@ -84,6 +84,21 @@ ../rtl/tsan_platform_windows.cc ../../sanitizer_common/sanitizer_win.cc " +elif [ "`uname -a | grep mips64 | grep Linux`" != "" ]; then + SUFFIX="linux_mips64" + OSCFLAGS="-fPIC -Wno-maybe-uninitialized -Wno-unused-const-variable -Werror -Wno-unknown-warning-option -Wno-unused-variable -Wno-unused-function" + OSLDFLAGS="-lpthread -fPIC -fpie" + SRCS=" + $SRCS + ../../sanitizer_common/sanitizer_posix.cc + ../../sanitizer_common/sanitizer_posix_libcdep.cc + ../../sanitizer_common/sanitizer_procmaps_common.cc + ../../sanitizer_common/sanitizer_procmaps_linux.cc + ../../sanitizer_common/sanitizer_linux.cc + ../../sanitizer_common/sanitizer_linux_libcdep.cc + ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc + ../rtl/tsan_platform_linux.cc + " else echo Unknown platform exit 1 @@ -111,8 +126,10 @@ done 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 +if [ "$DEBUG" = "" -a "`uname -a | grep x86_64`" != "" ]; then FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer" +elif [ "$DEBUG" = "" -a "`uname -a | grep mips64`" != "" ]; then + FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer" else FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g" 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) {