pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

compiler-rt-netbsd: Update to SVN r. 349257



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Dec 15 09:49:26 2018 +0100
Changeset:	17dfd7b0cbd2dba7c8bf295321713f34da45a365

Modified Files:
	compiler-rt-netbsd/Makefile
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc
	compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
	compiler-rt-netbsd/patches/patch-test_msan_pthread__getname__np.cc
Removed Files:
	compiler-rt-netbsd/patches/patch-lib_xray_tests_CMakeLists.txt

Log Message:
compiler-rt-netbsd: Update to SVN r. 349257

Merged upstream:
[compiler-rt] r349257 - Fix internal_sleep() for NetBSD
[compiler-rt] r349159 - Mark interception_failure_test.cc as passing for NetBSD and asan-dynamic-runtime
[compiler-rt] r349156 - Set shared_libasan_path in lit tests for NetBSD

Reworked TSD patches for ASan and MSan.

Add a local patch for pthread_getname_np().

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=17dfd7b0cbd2dba7c8bf295321713f34da45a365

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 compiler-rt-netbsd/Makefile                        |   2 +-
 compiler-rt-netbsd/distinfo                        |   7 +-
 .../patches/patch-lib_asan_asan__posix.cc          |  98 +++++++++++-------
 .../patches/patch-lib_msan_msan__linux.cc          | 109 +++++++++++++--------
 ...zer__common_sanitizer__platform__interceptors.h |  13 +++
 .../patches/patch-lib_xray_tests_CMakeLists.txt    |  12 ---
 .../patch-test_msan_pthread__getname__np.cc        |  13 +++
 7 files changed, 161 insertions(+), 93 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/Makefile b/compiler-rt-netbsd/Makefile
index 4d2498ed97..bd8386daca 100644
--- a/compiler-rt-netbsd/Makefile
+++ b/compiler-rt-netbsd/Makefile
@@ -5,7 +5,7 @@ CATEGORIES=	lang devel
 
 SVN_REPOSITORIES=		compiler-rt
 SVN_REPO.compiler-rt=		http://llvm.org/svn/llvm-project/compiler-rt/trunk
-SVN_REVISION.compiler-rt=	349021
+SVN_REVISION.compiler-rt=	349257
 
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
 HOMEPAGE=	http://compiler-rt.llvm.org/
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 50799f0e91..ca0be82dfa 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -1,6 +1,7 @@
 $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
 
-SHA1 (patch-lib_asan_asan__posix.cc) = be7e47c252e30184639f7ed1c98c75a8667fd261
+SHA1 (patch-lib_asan_asan__posix.cc) = 76056a2dca1eee0d16a79b9da39d8ddb53108de4
 SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 7210cbe6a3a65846a4229349b9a610a83ff3632f
-SHA1 (patch-lib_msan_msan__linux.cc) = b5df0f4f5930d7c1681b1ad867c893d01d6e5cf7
-SHA1 (patch-lib_xray_tests_CMakeLists.txt) = a5bee64ac6e4c0ff43aad200072d15c128ca03ad
+SHA1 (patch-lib_msan_msan__linux.cc) = e0a8034e63a0e9a571acdaca956e5002cf14dfe0
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = a444a0c9bef59dcde9a46191a0579bc39855f5ea
+SHA1 (patch-test_msan_pthread__getname__np.cc) = 54247b192a2f6a6fd078bee6b9188739f6edeae8
diff --git a/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc b/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc
index aea86c1ee4..d39ff665dc 100644
--- a/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_asan_asan__posix.cc
@@ -2,49 +2,75 @@ $NetBSD$
 
 --- lib/asan/asan_posix.cc.orig	2018-08-21 21:25:41.000000000 +0000
 +++ lib/asan/asan_posix.cc
-@@ -40,31 +40,35 @@ void AsanOnDeadlySignal(int signo, void 
+@@ -30,6 +30,11 @@
+ #include <sys/resource.h>
+ #include <unistd.h>
+ 
++#if SANITIZER_NETBSD
++extern "C" int __cxa_thread_atexit(void (*)(void *), void *,
++                                   void *) SANITIZER_WEAK_ATTRIBUTE;
++#endif
++
+ namespace __asan {
+ 
+ void AsanOnDeadlySignal(int signo, void *siginfo, void *context) {
+@@ -40,6 +45,51 @@ void AsanOnDeadlySignal(int signo, void 
  
  // ---------------------- TSD ---------------- {{{1
  
--static pthread_key_t tsd_key;
-+struct TsdKey {
-+  void *data;
-+  void (*dst)(void *value);
-+  TsdKey() : data(nullptr), dst(nullptr) {}
-+  ~TsdKey() {
-+    if (dst)
-+      dst(data);
++#if SANITIZER_NETBSD
++// Thread Static Data cannot be used in early init on NetBSD
++// Reuse the Asan TSD API for compatibility with existing code
++// with an alternative implementation.
++
++static bool tsd_key_inited = false;
++static void (*tsd_destructor)(void *tsd) = nullptr;
++static THREADLOCAL void *tsd_key = nullptr;
++
++void tsd_at_exit(void *tsd) {
++  CHECK_EQ(tsd, tsd_key);
++  CHECK(tsd_key);
++  (*tsd_destructor)(tsd_key);
++}
++
++void AsanTSDInit(void (*destructor)(void *tsd)) {
++  CHECK(!tsd_key_inited);
++  tsd_key_inited = true;
++  tsd_destructor = destructor;
++}
++
++void *AsanTSDGet() {
++  CHECK(tsd_key_inited);
++  return tsd_key;
++}
++
++void AsanTSDSet(void *tsd) {
++  CHECK(tsd_key_inited);
++  CHECK(tsd);
++  CHECK(!tsd_key);
++  tsd_key = tsd;
++  if (::__cxa_thread_atexit(tsd_at_exit, tsd, nullptr)) {
++    Printf("AddressSanitizer: failed to setup thread atexit callback");
++    Die();
 +  }
-+};
++}
 +
-+static thread_local TsdKey Tk;
++void PlatformTSDDtor(void *tsd) {
++  CHECK(tsd_key_inited);
++  tsd_key = nullptr;
++  // Make sure that signal handler can not see a stale current thread pointer.
++  atomic_signal_fence(memory_order_seq_cst);
++  AsanThread::TSDDtor(tsd);
++}
++#else
+ static pthread_key_t tsd_key;
  static bool tsd_key_inited = false;
  void AsanTSDInit(void (*destructor)(void *tsd)) {
-   CHECK(!tsd_key_inited);
-   tsd_key_inited = true;
--  CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
-+  Tk.dst = destructor;
- }
- 
- void *AsanTSDGet() {
-   CHECK(tsd_key_inited);
--  return pthread_getspecific(tsd_key);
-+  return Tk.data;
- }
- 
- void AsanTSDSet(void *tsd) {
-   CHECK(tsd_key_inited);
--  pthread_setspecific(tsd_key, tsd);
-+  Tk.data = tsd;
- }
- 
- void PlatformTSDDtor(void *tsd) {
--  AsanThreadContext *context = (AsanThreadContext*)tsd;
--  if (context->destructor_iterations > 1) {
--    context->destructor_iterations--;
--    CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
--    return;
--  }
+@@ -67,6 +117,7 @@ void PlatformTSDDtor(void *tsd) {
+   }
    AsanThread::TSDDtor(tsd);
  }
++#endif
  }  // namespace __asan
+ 
+ #endif  // SANITIZER_POSIX
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
index 8c7e059cf7..c71fa87ec3 100644
--- a/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
@@ -2,61 +2,88 @@ $NetBSD$
 
 --- lib/msan/msan_linux.cc.orig	2018-08-21 21:25:44.000000000 +0000
 +++ lib/msan/msan_linux.cc
-@@ -31,6 +31,7 @@
- #include <sys/time.h>
- #include <sys/resource.h>
- 
-+#include "interception/interception.h"
+@@ -34,6 +34,11 @@
  #include "sanitizer_common/sanitizer_common.h"
  #include "sanitizer_common/sanitizer_procmaps.h"
  
-@@ -175,13 +176,28 @@ void InstallAtExitHandler() {
++#if SANITIZER_NETBSD
++extern "C" int __cxa_thread_atexit(void (*)(void *), void *,
++                                   void *) SANITIZER_WEAK_ATTRIBUTE;
++#endif
++
+ namespace __msan {
+ 
+ void ReportMapRange(const char *descr, uptr beg, uptr size) {
+@@ -175,19 +180,59 @@ void InstallAtExitHandler() {
  
  // ---------------------- TSD ---------------- {{{1
  
-+#if !SANITIZER_NETBSD
- static pthread_key_t tsd_key;
-+#endif
+-static pthread_key_t tsd_key;
++static THREADLOCAL MsanThread *msan_current_thread;
++
++MsanThread *GetCurrentThread() { return msan_current_thread; }
 +
- static bool tsd_key_inited = false;
- 
 +#if SANITIZER_NETBSD
-+INTERCEPTOR(void, _lwp_exit) {
-+  CHECK(tsd_key_inited);
-+  MsanTSDDtor(GetCurrentThread());
-+  REAL(_lwp_exit)();
-+}
-+#endif
++// Thread Static Data cannot be used in early init on NetBSD
++// Reuse the Asan TSD API for compatibility with existing code
++// with an alternative implementation.
++
+ static bool tsd_key_inited = false;
++static void (*tsd_destructor)(void *tsd) = nullptr;
 +
++void tsd_at_exit(void *tsd) {
++  CHECK_EQ(tsd, (void *)msan_current_thread);
++  CHECK(tsd);
++  (*tsd_destructor)(tsd);
++}
+ 
  void MsanTSDInit(void (*destructor)(void *tsd)) {
    CHECK(!tsd_key_inited);
    tsd_key_inited = true;
-+#if SANITIZER_NETBSD
-+  INTERCEPT_FUNCTION(_lwp_exit);
-+#else
-   CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
-+#endif
+-  CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
++  tsd_destructor = destructor;
  }
  
- static THREADLOCAL MsanThread* msan_current_thread;
-@@ -196,16 +212,20 @@ void SetCurrentThread(MsanThread *t) {
-   msan_current_thread = t;
-   // Make sure that MsanTSDDtor gets called at the end.
-   CHECK(tsd_key_inited);
-+#if !SANITIZER_NETBSD
-   pthread_setspecific(tsd_key, (void *)t);
-+#endif
+-static THREADLOCAL MsanThread* msan_current_thread;
++void SetCurrentThread(MsanThread *t) {
++  CHECK(tsd_key_inited);
++  // Make sure we do not reset the current MsanThread.
++  CHECK_EQ(0, msan_current_thread);
++  msan_current_thread = t;
++  // Make sure that MsanTSDDtor gets called at the end.
++  CHECK(tsd_key_inited);
++  if (::__cxa_thread_atexit(tsd_at_exit, t, nullptr)) {
++    Printf("MemorySanitizer: failed to setup thread atexit callback");
++    Die();
++  }
++}
+ 
+-MsanThread *GetCurrentThread() {
+-  return msan_current_thread;
++void MsanTSDDtor(void *tsd) {
++  CHECK(tsd_key_inited);
++  CHECK_EQ(tsd, (void *)msan_current_thread);
++  msan_current_thread = nullptr;
++  // Make sure that signal handler can not see a stale current thread pointer.
++  atomic_signal_fence(memory_order_seq_cst);
++  MsanThread::TSDDtor(tsd);
++}
++#else
++static pthread_key_t tsd_key;
++static bool tsd_key_inited = false;
++
++void MsanTSDInit(void (*destructor)(void *tsd)) {
++  CHECK(!tsd_key_inited);
++  tsd_key_inited = true;
++  CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
  }
  
- void MsanTSDDtor(void *tsd) {
-+#if !SANITIZER_NETBSD
-   MsanThread *t = (MsanThread*)tsd;
-   if (t->destructor_iterations_ > 1) {
-     t->destructor_iterations_--;
-     CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
-     return;
-   }
-+#endif
-   msan_current_thread = nullptr;
-   // Make sure that signal handler can not see a stale current thread pointer.
+ void SetCurrentThread(MsanThread *t) {
+@@ -211,6 +256,7 @@ void MsanTSDDtor(void *tsd) {
    atomic_signal_fence(memory_order_seq_cst);
+   MsanThread::TSDDtor(tsd);
+ }
++#endif
+ 
+ } // namespace __msan
+ 
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
new file mode 100644
index 0000000000..2f6664c6c5
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_platform_interceptors.h.orig	2018-12-15 08:48:07.348952343 +0000
++++ lib/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -387,7 +387,7 @@
+ #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \
+   (SI_FREEBSD || SI_NETBSD || SI_OPENBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
+ #define SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP \
+-  (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
++  (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
+ 
+ #define SANITIZER_INTERCEPT_TLS_GET_ADDR \
+   (SI_FREEBSD || SI_NETBSD || SI_OPENBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
diff --git a/compiler-rt-netbsd/patches/patch-lib_xray_tests_CMakeLists.txt b/compiler-rt-netbsd/patches/patch-lib_xray_tests_CMakeLists.txt
deleted file mode 100644
index 68bbbd58f1..0000000000
--- a/compiler-rt-netbsd/patches/patch-lib_xray_tests_CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-$NetBSD$
-
---- lib/xray/tests/CMakeLists.txt.orig	2018-11-02 21:28:34.000000000 +0000
-+++ lib/xray/tests/CMakeLists.txt
-@@ -70,6 +70,7 @@ if (NOT APPLE)
-     list(APPEND XRAY_UNITTEST_LINK_FLAGS -lLLVMXRay -lLLVMSupport -lLLVMTestingSupport)
-   endif()
- 
-+  list(APPEND XRAY_UNITTEST_LINK_FLAGS -lexecinfo -lLLVMDemangle)
-   append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_UNITTEST_LINK_FLAGS)
-   append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_UNITTEST_LINK_FLAGS)
-   append_list_if(COMPILER_RT_HAS_LIBDL -ldl XRAY_UNITTEST_LINK_FLAGS)
diff --git a/compiler-rt-netbsd/patches/patch-test_msan_pthread__getname__np.cc b/compiler-rt-netbsd/patches/patch-test_msan_pthread__getname__np.cc
new file mode 100644
index 0000000000..872150529a
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-test_msan_pthread__getname__np.cc
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- test/msan/pthread_getname_np.cc.orig	2018-08-21 21:25:23.000000000 +0000
++++ test/msan/pthread_getname_np.cc
+@@ -1,7 +1,7 @@
+ // RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %run %t
+ // The main goal is getting the pthread name back and
+ // FreeBSD based do not support this feature
+-// UNSUPPORTED: android, netbsd, freebsd
++// UNSUPPORTED: android, freebsd
+ 
+ // Regression test for a deadlock in pthread_getattr_np
+ 


Home | Main Index | Thread Index | Old Index