[compiler-rt] fcf6ae2 - tsan: add OpenBSD support for Go

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 07:47:21 PDT 2020


Author: Dmitry Vyukov
Date: 2020-06-08T16:47:13+02:00
New Revision: fcf6ae2f070eba73074b6ec8d8281e54d29dbeeb

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

LOG: tsan: add OpenBSD support for Go

With the race_debug_openbsd_amd64.syso file created via this diff,
Go's race detector is able to detect a race in the example code
from this link: https://golang.org/doc/articles/race_detector.html

Reviewed-in: https://reviews.llvm.org/D80469
Author: qbit (Aaron Bieber)

Added: 
    

Modified: 
    compiler-rt/lib/tsan/go/buildgo.sh
    compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
index 9e21b77d5a09..2238caf53b34 100755
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -108,6 +108,27 @@ elif [ "`uname -a | grep NetBSD`" != "" ]; then
 		../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
 		../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
 	"
+elif [ "`uname -a | grep OpenBSD`" != "" ]; then
+	# The resulting object still depends on libc.
+	# We removed this dependency for Go runtime for other OSes,
+	# and we should remove it for OpenBSD as well, but there is no pressing need.
+	DEPENDS_ON_LIBC=1
+	SUFFIX="openbsd_amd64"
+	OSCFLAGS="-fno-strict-aliasing -fPIC -Werror"
+	ARCHCFLAGS="-m64"
+	OSLDFLAGS="-pthread -fPIC -fpie"
+	SRCS="
+		$SRCS
+		../rtl/tsan_platform_linux.cpp
+		../../sanitizer_common/sanitizer_posix.cpp
+		../../sanitizer_common/sanitizer_posix_libcdep.cpp
+		../../sanitizer_common/sanitizer_procmaps_bsd.cpp
+		../../sanitizer_common/sanitizer_procmaps_common.cpp
+		../../sanitizer_common/sanitizer_linux.cpp
+		../../sanitizer_common/sanitizer_linux_libcdep.cpp
+		../../sanitizer_common/sanitizer_openbsd.cpp
+		../../sanitizer_common/sanitizer_stoptheworld_linux_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"

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
index 33fa586ca1b0..645152a06c39 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -8,25 +8,26 @@
 //
 // This file is a part of ThreadSanitizer (TSan), a race detector.
 //
-// Linux- and FreeBSD-specific code.
+// Linux- and BSD-specific code.
 //===----------------------------------------------------------------------===//
 
-
 #include "sanitizer_common/sanitizer_platform.h"
-#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \
+    SANITIZER_OPENBSD
 
 #include "sanitizer_common/sanitizer_common.h"
 #include "sanitizer_common/sanitizer_libc.h"
 #include "sanitizer_common/sanitizer_linux.h"
 #include "sanitizer_common/sanitizer_platform_limits_netbsd.h"
+#include "sanitizer_common/sanitizer_platform_limits_openbsd.h"
 #include "sanitizer_common/sanitizer_platform_limits_posix.h"
 #include "sanitizer_common/sanitizer_posix.h"
 #include "sanitizer_common/sanitizer_procmaps.h"
-#include "sanitizer_common/sanitizer_stoptheworld.h"
 #include "sanitizer_common/sanitizer_stackdepot.h"
+#include "sanitizer_common/sanitizer_stoptheworld.h"
+#include "tsan_flags.h"
 #include "tsan_platform.h"
 #include "tsan_rtl.h"
-#include "tsan_flags.h"
 
 #include <fcntl.h>
 #include <pthread.h>
@@ -512,4 +513,5 @@ void cur_thread_finalize() {
 
 }  // namespace __tsan
 
-#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD ||
+        // SANITIZER_OPENBSD


        


More information about the llvm-commits mailing list