[TSan] Fix Go build.
authorAlexey Samsonov <vonosmas@gmail.com>
Fri, 30 Jan 2015 23:04:57 +0000 (23:04 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Fri, 30 Jan 2015 23:04:57 +0000 (23:04 +0000)
llvm-svn: 227634

compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/lib/tsan/go/buildgo.sh

index 9df2e47..26138ba 100644 (file)
@@ -449,17 +449,6 @@ void ReExec() {
   Die();
 }
 
-// Stub implementation of GetThreadStackAndTls for Go.
-#if SANITIZER_GO
-void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
-                          uptr *tls_addr, uptr *tls_size) {
-  *stk_addr = 0;
-  *stk_size = 0;
-  *tls_addr = 0;
-  *tls_size = 0;
-}
-#endif  // SANITIZER_GO
-
 enum MutexState {
   MtxUnlocked = 0,
   MtxLocked = 1,
index a5a8d0a..9ca46a7 100644 (file)
@@ -58,8 +58,10 @@ real_pthread_attr_getstack(void *attr, void **addr, size_t *size);
 }  // extern "C"
 
 static int my_pthread_attr_getstack(void *attr, void **addr, size_t *size) {
+#if !SANITIZER_GO
   if (real_pthread_attr_getstack)
     return real_pthread_attr_getstack((pthread_attr_t *)attr, addr, size);
+#endif
   return pthread_attr_getstack((pthread_attr_t *)attr, addr, size);
 }
 
@@ -67,8 +69,10 @@ SANITIZER_WEAK_ATTRIBUTE int
 real_sigaction(int signum, const void *act, void *oldact);
 
 int internal_sigaction(int signum, const void *act, void *oldact) {
+#if !SANITIZER_GO
   if (real_sigaction)
     return real_sigaction(signum, act, oldact);
+#endif
   return sigaction(signum, (const struct sigaction *)act,
                    (struct sigaction *)oldact);
 }
@@ -152,7 +156,7 @@ static uptr g_tls_size;
 #endif
 
 void InitTlsSize() {
-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID
+#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
   typedef void (*get_tls_func)(size_t*, size_t*) DL_INTERNAL_FUNCTION;
   get_tls_func get_tls;
   void *get_tls_static_info_ptr = dlsym(RTLD_NEXT, "_dl_get_tls_static_info");
@@ -250,6 +254,7 @@ uptr ThreadSelf() {
 }
 #endif  // SANITIZER_FREEBSD
 
+#if !SANITIZER_GO
 static void GetTls(uptr *addr, uptr *size) {
 #if SANITIZER_LINUX
 # if defined(__x86_64__) || defined(__i386__)
@@ -278,6 +283,7 @@ static void GetTls(uptr *addr, uptr *size) {
 # error "Unknown OS"
 #endif
 }
+#endif
 
 uptr GetTlsSize() {
 #if SANITIZER_FREEBSD
@@ -291,6 +297,10 @@ uptr GetTlsSize() {
 
 void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
                           uptr *tls_addr, uptr *tls_size) {
+#if SANITIZER_GO
+  // Stub implementation for Go.
+  *stk_addr = *stk_size = *tls_addr = *tls_size = 0;
+#else
   GetTls(tls_addr, tls_size);
 
   uptr stack_top, stack_bottom;
@@ -307,6 +317,7 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
       *tls_addr = *stk_addr + *stk_size;
     }
   }
+#endif
 }
 
 void AdjustStackSize(void *attr_) {
index 52310aa..a7c717d 100755 (executable)
@@ -19,6 +19,7 @@ SRCS="
        ../../sanitizer_common/sanitizer_allocator.cc
        ../../sanitizer_common/sanitizer_common.cc
        ../../sanitizer_common/sanitizer_deadlock_detector2.cc
+       ../../sanitizer_common/sanitizer_flag_parser.cc
        ../../sanitizer_common/sanitizer_flags.cc
        ../../sanitizer_common/sanitizer_libc.cc
        ../../sanitizer_common/sanitizer_persistent_allocator.cc
@@ -41,6 +42,7 @@ if [ "`uname -a | grep Linux`" != "" ]; then
                ../../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
        "
 elif [ "`uname -a | grep FreeBSD`" != "" ]; then
@@ -54,6 +56,7 @@ elif [ "`uname -a | grep FreeBSD`" != "" ]; then
                 ../../sanitizer_common/sanitizer_procmaps_common.cc
                 ../../sanitizer_common/sanitizer_procmaps_freebsd.cc
                 ../../sanitizer_common/sanitizer_linux.cc
+                ../../sanitizer_common/sanitizer_linux_libcdep.cc
                 ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
         "
 elif [ "`uname -a | grep Darwin`" != "" ]; then