[compiler-rt] 00da38c - tsan: add Go race detector support for macOS/ARM64

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 30 11:43:28 PDT 2020


Author: Dmitry Vyukov
Date: 2020-10-30T19:42:48+01:00
New Revision: 00da38ce2d36c07f12c287dc515d37bb7bc410e9

URL: https://github.com/llvm/llvm-project/commit/00da38ce2d36c07f12c287dc515d37bb7bc410e9
DIFF: https://github.com/llvm/llvm-project/commit/00da38ce2d36c07f12c287dc515d37bb7bc410e9.diff

LOG: tsan: add Go race detector support for macOS/ARM64

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
index 42ab73f8d4d0..2e19c52052e0 100755
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -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"

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 31e394397369..16169cab666a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -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

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
index eea52a34e97f..ec2c5fb1621d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -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",


        


More information about the llvm-commits mailing list