pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-netbsd: Upgrade to SVN r. 317430
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Mon Nov 6 05:06:54 2017 +0100
Changeset: 43e086801a546e74e985cda3339f74590d4502c1
Modified Files:
compiler-rt-netbsd/Makefile
compiler-rt-netbsd/distinfo
compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
Log Message:
compiler-rt-netbsd: Upgrade to SVN r. 317430
This revision incorporates NetBSD enhances in compiler-rt.
Two major patches incorporated:
- Improve detection of thread termination on NetBSD.
- Stop tracking Linux specific on_exit().
Revamp patch for tracking __cxa_atexit() and atexit(3) and make it
compatible with NetBSD.
Sponsored by <The NetBSD Foundation>
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=43e086801a546e74e985cda3339f74590d4502c1
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 | 2 +-
.../patch-lib_tsan_rtl_tsan__interceptors.cc | 115 ++++++++++-----------
3 files changed, 56 insertions(+), 63 deletions(-)
diffs:
diff --git a/compiler-rt-netbsd/Makefile b/compiler-rt-netbsd/Makefile
index b1acca4db2..9f4e6c1547 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= 316598
+SVN_REVISION.compiler-rt= 317430
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 d5f67bd127..cc46cf3ef8 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -3,6 +3,6 @@ $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
SHA1 (patch-cmake_config-ix.cmake) = a1814db3e044ce3954655fea1e157a96bfa8df2f
SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 38ca750154dfc9843a56748078235824b772a147
SHA1 (patch-lib_msan_msan.h) = ce3f544490aebc1db73be9e3388f0a9d31d5b369
-SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 1247b3395ff2d5e9158895d141289cc315587797
+SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 9ad8e5545c28ac0a284e557934712a8a7c949539
SHA1 (patch-lib_tsan_rtl_tsan__rtl.cc) = bc3d6aa81515ac4a4fc5b504e93b3ac8de355371
SHA1 (patch-lib_tsan_rtl_tsan__rtl__amd64.S) = 6df0f2af44ebfec76d3b237c984eff63ee93b30f
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
index fea3c2b207..c33864f482 100644
--- a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
@@ -1,67 +1,60 @@
$NetBSD$
---- lib/tsan/rtl/tsan_interceptors.cc.orig 2017-10-25 19:03:27.000000000 +0000
+--- lib/tsan/rtl/tsan_interceptors.cc.orig 2017-11-06 03:58:05.389006908 +0000
+++ lib/tsan/rtl/tsan_interceptors.cc
-@@ -265,7 +265,7 @@ static ThreadSignalContext *SigCtx(Threa
- return ctx;
- }
-
--#if !SANITIZER_MAC
-+#if !SANITIZER_MAC && !SANITIZER_NETBSD
- static unsigned g_thread_finalize_key;
- #endif
-
-@@ -866,7 +866,7 @@ void DestroyThreadState() {
- }
- } // namespace __tsan
+@@ -391,7 +391,28 @@ struct AtExitCtx {
+ void *arg;
+ };
--#if !SANITIZER_MAC
-+#if !SANITIZER_MAC && !SANITIZER_NETBSD
- static void thread_finalize(void *v) {
- uptr iter = (uptr)v;
- if (iter > 1) {
-@@ -896,7 +896,7 @@ extern "C" void *__tsan_thread_start_fun
- ThreadState *thr = cur_thread();
- // Thread-local state is not initialized yet.
- ScopedIgnoreInterceptors ignore;
--#if !SANITIZER_MAC
-+#if !SANITIZER_MAC && !SANITIZER_NETBSD
- ThreadIgnoreBegin(thr, 0);
- if (pthread_setspecific(g_thread_finalize_key,
- (void *)GetPthreadDestructorIterations())) {
-@@ -2445,6 +2445,17 @@ TSAN_INTERCEPTOR(void *, __tls_get_addr,
- }
- #endif
-
-+#if SANITIZER_NETBSD
-+TSAN_INTERCEPTOR(void, _lwp_exit) {
-+ SCOPED_TSAN_INTERCEPTOR(_lwp_exit);
-+ DestroyThreadState();
-+ REAL(_lwp_exit)();
-+}
-+#define TSAN_MAYBE_INTERCEPT__LWP_EXIT TSAN_INTERCEPT(_lwp_exit)
-+#else
-+#define TSAN_MAYBE_INTERCEPT__LWP_EXIT
-+#endif
+-static void at_exit_wrapper(void *arg) {
++static struct AtExitCtx **AtExitStack;
++static int AtExitStackSize;
+
- namespace __tsan {
-
- static void finalize(void *arg) {
-@@ -2613,6 +2624,8 @@ void InitializeInterceptors() {
- TSAN_INTERCEPT(__tls_get_addr);
- #endif
-
-+ TSAN_MAYBE_INTERCEPT__LWP_EXIT;
++static void at_exit_wrapper() {
++ ThreadState *thr = cur_thread();
++ uptr pc = 0;
+
- #if !SANITIZER_MAC && !SANITIZER_ANDROID
- // Need to setup it, because interceptors check that the function is resolved.
- // But atexit is emitted directly into the module, so can't be resolved.
-@@ -2624,7 +2637,7 @@ void InitializeInterceptors() {
- Die();
- }
-
--#if !SANITIZER_MAC
-+#if !SANITIZER_MAC && !SANITIZER_NETBSD
- if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
- Printf("ThreadSanitizer: failed to create thread key\n");
- Die();
++ // Pop AtExitCtx from the top of the stack of callback functions
++ AtExitCtx *ctx = AtExitStack[AtExitStackSize - 1];
++ --AtExitStackSize;
++ if (InternalReallocArr(&AtExitStack, AtExitStackSize,
++ sizeof(struct AtExitCtx *))) {
++ Printf("InternalReallocArr error");
++ Die();
++ }
++
++ Acquire(thr, pc, (uptr)ctx);
++ ((void(*)())ctx->f)();
++ InternalFree(ctx);
++}
++
++static void cxa_at_exit_wrapper(void *arg) {
+ ThreadState *thr = cur_thread();
+ uptr pc = 0;
+ Acquire(thr, pc, (uptr)arg);
+@@ -430,7 +451,24 @@ static int setup_at_exit_wrapper(ThreadS
+ // Memory allocation in __cxa_atexit will race with free during exit,
+ // because we do not see synchronization around atexit callback list.
+ ThreadIgnoreBegin(thr, pc);
+- int res = REAL(__cxa_atexit)(at_exit_wrapper, ctx, dso);
++ int res;
++ if (dso == 0) {
++ // NetBSD does not preserve the 2nd argument if dso is equal to 0
++ // Store ctx in a local stack-like structure
++ res = REAL(__cxa_atexit)((void (*)(void *a))at_exit_wrapper, 0, 0);
++ // Push AtExitCtx on the top of the stack of callback functions
++ if (res == 0) {
++ ++AtExitStackSize;
++ if (InternalReallocArr(&AtExitStack, AtExitStackSize,
++ sizeof(struct AtExitCtx *))) {
++ Printf("InternalReallocArr error");
++ Die();
++ }
++ AtExitStack[AtExitStackSize - 1] = ctx;
++ }
++ } else {
++ res = REAL(__cxa_atexit)(cxa_at_exit_wrapper, ctx, dso);
++ }
+ ThreadIgnoreEnd(thr, pc);
+ return res;
+ }
Home |
Main Index |
Thread Index |
Old Index