Skip to content

Commit

Permalink
tsan: add OpenBSD support for Go
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
dvyukov committed Jun 8, 2020
1 parent 9939f23 commit fcf6ae2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
21 changes: 21 additions & 0 deletions compiler-rt/lib/tsan/go/buildgo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 8 additions & 6 deletions compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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

0 comments on commit fcf6ae2

Please sign in to comment.