tsan: add Go race detector support for macOS/ARM64
authorDmitry Vyukov <dvyukov@google.com>
Fri, 30 Oct 2020 18:42:48 +0000 (19:42 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Fri, 30 Oct 2020 18:42:48 +0000 (19:42 +0100)
Add Go race detector support for macOS/ARM64. The Go counterpart is https://golang.org/cl/266373 .

Author: cherry (Cherry Zhang)
Reviewed-in: https://reviews.llvm.org/D90435

compiler-rt/lib/tsan/go/buildgo.sh
compiler-rt/lib/tsan/rtl/tsan_platform.h
compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp

index 42ab73f..2e19c52 100755 (executable)
@@ -117,9 +117,7 @@ elif [ "`uname -a | grep NetBSD`" != "" ]; then
                ../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
        "
 elif [ "`uname -a | grep Darwin`" != "" ]; then
-       SUFFIX="darwin_amd64"
        OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
-       ARCHCFLAGS="-m64"
        OSLDFLAGS="-lpthread -fPIC -fpie -mmacosx-version-min=10.7"
        SRCS="
                $SRCS
@@ -130,6 +128,13 @@ elif [ "`uname -a | grep Darwin`" != "" ]; then
                ../../sanitizer_common/sanitizer_posix_libcdep.cpp
                ../../sanitizer_common/sanitizer_procmaps_mac.cpp
        "
+       if [ "`uname -a | grep x86_64`" != "" ]; then
+               SUFFIX="darwin_amd64"
+               ARCHCFLAGS="-m64"
+       elif [ "`uname -a | grep arm64`" != "" ]; then
+               SUFFIX="darwin_arm64"
+               ARCHCFLAGS=""
+       fi
 elif [ "`uname -a | grep MINGW`" != "" ]; then
        SUFFIX="windows_amd64"
        OSCFLAGS="-Wno-error=attributes -Wno-attributes -Wno-unused-const-variable -Wno-unknown-warning-option"
index 31e3943..16169ca 100644 (file)
@@ -461,7 +461,7 @@ struct Mapping47 {
 
 #elif SANITIZER_GO && defined(__aarch64__)
 
-/* Go on linux/aarch64 (48-bit VMA)
+/* Go on linux/aarch64 (48-bit VMA) and darwin/aarch64 (47-bit VMA)
 0000 0000 1000 - 0000 1000 0000: executable
 0000 1000 0000 - 00c0 0000 0000: -
 00c0 0000 0000 - 00e0 0000 0000: heap
index eea52a3..ec2c5fb 100644 (file)
@@ -234,7 +234,7 @@ static void my_pthread_introspection_hook(unsigned int event, pthread_t thread,
 #endif
 
 void InitializePlatformEarly() {
-#if defined(__aarch64__)
+#if !SANITIZER_GO && defined(__aarch64__)
   uptr max_vm = GetMaxUserVirtualAddress() + 1;
   if (max_vm != Mapping::kHiAppMemEnd) {
     Printf("ThreadSanitizer: unsupported vm address limit %p, expected %p.\n",