pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-netbsd: Sync local patches with pkgsrc-wip
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Thu Oct 19 15:17:19 2017 +0200
Changeset: aef4cbdcd5ea0392905247369b315d974b28885a
Modified Files:
compiler-rt-netbsd/distinfo
compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
Added Files:
compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
compiler-rt-netbsd/patches/patch-test_tsan_map32bit.cc
Log Message:
compiler-rt-netbsd: Sync local patches with pkgsrc-wip
Part of the code contains new or revamped kludges, but it's a step
forwards.
check-tsan:
Expected Passes : 248
Expected Failures : 1
Unsupported Tests : 83
Unexpected Failures: 44
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=aef4cbdcd5ea0392905247369b315d974b28885a
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
compiler-rt-netbsd/distinfo | 5 +-
...zer__common_sanitizer__common__interceptors.inc | 66 +++++++++
...r__common_sanitizer__platform__limits__netbsd.h | 13 ++
.../patch-lib_tsan_rtl_tsan__interceptors.cc | 162 ++++++++++++---------
.../patches/patch-test_tsan_map32bit.cc | 20 +++
5 files changed, 200 insertions(+), 66 deletions(-)
diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index d0f4b3aa38..ff339f0ea8 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -2,17 +2,20 @@ $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
SHA1 (patch-cmake_config-ix.cmake) = 5b1842f08cc8c2b96e0529b552b09c7adf2065dc
SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = eaffd9f8f2621ad465b5c734a764bdff0243af3d
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = 297a3c995a3df644e515dda2856f0784e6e96a62
SHA1 (patch-lib_sanitizer__common_sanitizer__internal__defs.h) = f5825b7081758e07e36dbd47a887f31a20912a83
SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = 25cba9ff9d61910bb74d500e515da083af4e6cb7
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = ce1a3cbb60b81ae67a3242eb96f8d277a1fad059
SHA1 (patch-lib_sanitizer__common_sanitizer__thread__registry.cc) = ab0bccc862443c04ec0e7287bbf8e2632546bb90
SHA1 (patch-lib_tsan_go_buildgo.sh) = fe64b3389bbf6ae2ddf187df3e0600b2f817f51d
-SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 1d849dba05d9c8f70e3636fb65758e0971e8a2e3
+SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 3bea97313e5ddf4942f0a63fabeaf61789328698
SHA1 (patch-lib_tsan_rtl_tsan__platform__linux.cc) = 23744bd656f0dcee425821491bcaa723f26130a3
SHA1 (patch-lib_tsan_rtl_tsan__platform__posix.cc) = ddf48d91100e681f09b7303a37936ac8cd7f775a
SHA1 (patch-lib_tsan_rtl_tsan__rtl.cc) = 8d5938bb27f9d238ceeb09ac1e6e8090b196fdcc
SHA1 (patch-lib_tsan_rtl_tsan__rtl__amd64.S) = 95591667c23372ceb72334b2ceae800d32574ac6
SHA1 (patch-lib_tsan_tests_rtl_tsan__test__util__posix.cc) = 302c72dab4fe5a0c94d7de0d728033e616811e5e
SHA1 (patch-test_tsan_lit.cfg) = 001a4025f0542998da209df933359cf929d7631e
+SHA1 (patch-test_tsan_map32bit.cc) = 08886c59b31fb1bc3574ce8c12d2a8194c0b64a1
SHA1 (patch-test_tsan_strerror__r.cc) = 6f157012b8a3ca80f11380b76c433bddea16c86b
SHA1 (patch-test_tsan_tls__race.cc) = 7447ee161c27deb7196151f56ea739904bec8c1c
SHA1 (patch-test_tsan_tls__race2.cc) = da9b3298b8e882db111b01ac10a5ae6dbeaa88dc
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
new file mode 100644
index 0000000000..06962803da
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
@@ -0,0 +1,66 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_common_interceptors.inc.orig 2017-10-19 13:16:09.802766688 +0000
++++ lib/sanitizer_common/sanitizer_common_interceptors.inc
+@@ -3795,7 +3795,7 @@ INTERCEPTOR(void, _exit, int status) {
+ #define INIT__EXIT
+ #endif
+
+-#if SANITIZER_INTERCEPT_PHTREAD_MUTEX
++#if SANITIZER_INTERCEPT_PHTREAD_MUTEX && !SANITIZER_NETBSD
+ INTERCEPTOR(int, pthread_mutex_lock, void *m) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, pthread_mutex_lock, m);
+@@ -3828,6 +3828,13 @@ INTERCEPTOR(int, pthread_mutex_unlock, v
+ #define INIT_PTHREAD_MUTEX_UNLOCK
+ #endif
+
++__attribute__((constructor))
++static void
++yikes(void) {
++// INIT_PTHREAD_MUTEX_LOCK;
++// INIT_PTHREAD_MUTEX_UNLOCK;
++}
++
+ #if SANITIZER_INTERCEPT_GETMNTENT || SANITIZER_INTERCEPT_GETMNTENT_R
+ static void write_mntent(void *ctx, __sanitizer_mntent *mnt) {
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, mnt, sizeof(*mnt));
+@@ -4405,7 +4412,7 @@ INTERCEPTOR(char *, tempnam, char *dir,
+ #define INIT_TEMPNAM
+ #endif
+
+-#if SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP
++#if SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP && !SANITIZER_NETBSD
+ INTERCEPTOR(int, pthread_setname_np, uptr thread, const char *name) {
+ void *ctx;
+ COMMON_INTERCEPTOR_ENTER(ctx, pthread_setname_np, thread, name);
+@@ -4414,6 +4421,18 @@ INTERCEPTOR(int, pthread_setname_np, upt
+ return REAL(pthread_setname_np)(thread, name);
+ }
+ #define INIT_PTHREAD_SETNAME_NP COMMON_INTERCEPT_FUNCTION(pthread_setname_np);
++#elif SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP && SANITIZER_NETBSD
++INTERCEPTOR(int, pthread_setname_np, uptr thread, const char *name, void *arg) {
++ void *ctx;
++ char newname[32]; // PTHREAD_MAX_NAMELEN_NP=32
++ int namelen;
++ COMMON_INTERCEPTOR_ENTER(ctx, pthread_setname_np, thread, name, arg);
++ namelen = internal_snprintf(newname, sizeof(newname), name, arg);
++ COMMON_INTERCEPTOR_READ_STRING(ctx, newname, namelen);
++ COMMON_INTERCEPTOR_SET_PTHREAD_NAME(ctx, thread, newname);
++ return REAL(pthread_setname_np)(thread, name, arg);
++}
++#define INIT_PTHREAD_SETNAME_NP COMMON_INTERCEPT_FUNCTION(pthread_setname_np);
+ #else
+ #define INIT_PTHREAD_SETNAME_NP
+ #endif
+@@ -6373,8 +6392,10 @@ static void InitializeCommonInterceptors
+ INIT_SIGPROCMASK;
+ INIT_BACKTRACE;
+ INIT__EXIT;
++#if !SANITIZER_NETBSD
+ INIT_PTHREAD_MUTEX_LOCK;
+ INIT_PTHREAD_MUTEX_UNLOCK;
++#endif
+ INIT_GETMNTENT;
+ INIT_GETMNTENT_R;
+ INIT_STATFS;
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
new file mode 100644
index 0000000000..e9c8fd582c
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_platform_limits_netbsd.h.orig 2017-10-17 18:35:46.000000000 +0000
++++ lib/sanitizer_common/sanitizer_platform_limits_netbsd.h
+@@ -313,7 +313,7 @@ struct __sanitizer_wordexp_t {
+ uptr we_nbytes;
+ };
+
+-typedef void __sanitizer_FILE;
++typedef char __sanitizer_FILE;
+ #define SANITIZER_HAS_STRUCT_FILE 0
+
+ extern int shmctl_ipc_stat;
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 451f6b7ba2..21aebb1a2f 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
@@ -2,95 +2,127 @@ $NetBSD$
--- lib/tsan/rtl/tsan_interceptors.cc.orig 2017-10-17 18:35:44.000000000 +0000
+++ lib/tsan/rtl/tsan_interceptors.cc
-@@ -257,7 +257,7 @@ static ThreadSignalContext *SigCtx(Threa
- return ctx;
- }
-
--#if !SANITIZER_MAC
-+#if !SANITIZER_MAC && !SANITIZER_NETBSD
- static unsigned g_thread_finalize_key;
+@@ -43,8 +43,16 @@ using namespace __tsan; // NOLINT
+ #if SANITIZER_NETBSD
+ #define dirfd(dirp) (*(int *)(dirp))
+ #define fileno_unlocked fileno
+-#define stdout __sF[1]
+-#define stderr __sF[2]
++
++#if _LP64
++#define __sF_size 152
++#else
++#define __sF_size 88
++#endif
++
++#define stdout ((char*)&__sF + (__sF_size * 1))
++#define stderr ((char*)&__sF + (__sF_size * 2))
++
#endif
-@@ -387,9 +387,9 @@ static void at_exit_wrapper(void *arg) {
- ThreadState *thr = cur_thread();
+ #if SANITIZER_ANDROID
+@@ -99,7 +107,7 @@ extern "C" int dirfd(void *dirp);
+ extern "C" int mallopt(int param, int value);
+ #endif
+ #if SANITIZER_NETBSD
+-extern __sanitizer_FILE **__sF;
++extern __sanitizer_FILE __sF[];
+ #else
+ extern __sanitizer_FILE *stdout, *stderr;
+ #endif
+@@ -388,8 +396,8 @@ static void at_exit_wrapper(void *arg) {
uptr pc = 0;
Acquire(thr, pc, (uptr)arg);
-- AtExitCtx *ctx = (AtExitCtx*)arg;
+ AtExitCtx *ctx = (AtExitCtx*)arg;
- ((void(*)(void *arg))ctx->f)(ctx->arg);
- InternalFree(ctx);
-+// AtExitCtx *ctx = (AtExitCtx*)arg;
+// ((void(*)(void *arg))ctx->f)(ctx->arg);
+// InternalFree(ctx);
}
static int setup_at_exit_wrapper(ThreadState *thr, uptr pc, void(*f)(),
-@@ -858,7 +858,7 @@ void DestroyThreadState() {
+@@ -912,6 +920,38 @@ extern "C" void *__tsan_thread_start_fun
+ return res;
}
- } // namespace __tsan
--#if !SANITIZER_MAC
-+#if !SANITIZER_MAC && !SANITIZER_NETBSD
- static void thread_finalize(void *v) {
- uptr iter = (uptr)v;
- if (iter > 1) {
-@@ -888,7 +888,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())) {
-@@ -1670,8 +1670,8 @@ TSAN_INTERCEPTOR(void*, tmpfile64, int f
- static void FlushStreams() {
- // Flushing all the streams here may freeze the process if a child thread is
- // performing file stream operations at the same time.
++static void FlushStreams() {
++ // Flushing all the streams here may freeze the process if a child thread is
++ // performing file stream operations at the same time.
++
++ REAL(fflush)(stdout);
++ REAL(fflush)(stderr);
++}
++
++static void finalize(void *arg) {
++ using namespace __tsan;
++ ThreadState *thr = cur_thread();
++ int status = Finalize(thr);
++ // Make sure the output is not lost.
++ FlushStreams();
++ if (status)
++ Die();
++}
++
++__attribute__((constructor))
++static void
++yikes1(void) {
++ if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
++ Printf("ThreadSanitizer: failed to setup atexit callback\n");
++ Die();
++ }
++
++ if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
++ Printf("ThreadSanitizer: failed to create thread key\n");
++ Die();
++ }
++}
++
+ TSAN_INTERCEPTOR(int, pthread_create,
+ void *th, void *attr, void *(*callback)(void*), void * param) {
+ SCOPED_INTERCEPTOR_RAW(pthread_create, th, attr, callback, param);
+@@ -1667,13 +1707,6 @@ TSAN_INTERCEPTOR(void*, tmpfile64, int f
+ #define TSAN_MAYBE_INTERCEPT_TMPFILE64
+ #endif
+
+-static void FlushStreams() {
+- // Flushing all the streams here may freeze the process if a child thread is
+- // performing file stream operations at the same time.
- REAL(fflush)(stdout);
- REAL(fflush)(stderr);
-+// REAL(fflush)(stdout);
-+// REAL(fflush)(stderr);
- }
-
+-}
+-
TSAN_INTERCEPTOR(void, abort, int fake) {
-@@ -2439,6 +2439,7 @@ TSAN_INTERCEPTOR(void *, __tls_get_addr,
+ SCOPED_TSAN_INTERCEPTOR(abort, fake);
+ FlushStreams();
+@@ -2439,15 +2472,6 @@ TSAN_INTERCEPTOR(void *, __tls_get_addr,
namespace __tsan {
-+#if 0
- static void finalize(void *arg) {
- ThreadState *thr = cur_thread();
- int status = Finalize(thr);
-@@ -2447,6 +2448,7 @@ static void finalize(void *arg) {
- if (status)
- Die();
- }
-+#endif
-
+-static void finalize(void *arg) {
+- ThreadState *thr = cur_thread();
+- int status = Finalize(thr);
+- // Make sure the output is not lost.
+- FlushStreams();
+- if (status)
+- Die();
+-}
+-
#if !SANITIZER_MAC && !SANITIZER_ANDROID
static void unreachable() {
-@@ -2611,16 +2613,16 @@ void InitializeInterceptors() {
+ Report("FATAL: ThreadSanitizer: unreachable called\n");
+@@ -2611,6 +2635,7 @@ void InitializeInterceptors() {
REAL(atexit) = (int(*)(void(*)()))unreachable;
#endif
-- if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
-- Printf("ThreadSanitizer: failed to setup atexit callback\n");
-- Die();
-- }
-+// if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
-+// Printf("ThreadSanitizer: failed to setup atexit callback\n");
-+// Die();
-+// }
-
- #if !SANITIZER_MAC
-- if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
-- Printf("ThreadSanitizer: failed to create thread key\n");
-- Die();
-- }
-+// if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
-+// Printf("ThreadSanitizer: failed to create thread key\n");
-+// Die();
-+// }
++#if 0
+ if (REAL(__cxa_atexit)(&finalize, 0, 0)) {
+ Printf("ThreadSanitizer: failed to setup atexit callback\n");
+ Die();
+@@ -2622,6 +2647,7 @@ void InitializeInterceptors() {
+ Die();
+ }
#endif
++#endif
FdInit();
+ }
diff --git a/compiler-rt-netbsd/patches/patch-test_tsan_map32bit.cc b/compiler-rt-netbsd/patches/patch-test_tsan_map32bit.cc
new file mode 100644
index 0000000000..5b974e8900
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-test_tsan_map32bit.cc
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- test/tsan/map32bit.cc.orig 2017-10-17 18:35:29.000000000 +0000
++++ test/tsan/map32bit.cc
+@@ -12,8 +12,8 @@
+ // XFAIL: aarch64
+ // XFAIL: powerpc64
+
+-// MAP_32BIT doesn't exist on OS X.
+-// UNSUPPORTED: darwin
++// MAP_32BIT doesn't exist on OS X and NetBSD.
++// UNSUPPORTED: darwin,netbsd
+
+ void *Thread(void *ptr) {
+ *(int*)ptr = 42;
+@@ -45,4 +45,3 @@ int main() {
+
+ // CHECK: WARNING: ThreadSanitizer: data race
+ // CHECK: DONE
+-
Home |
Main Index |
Thread Index |
Old Index