[compiler-rt] 5ff52be - [sanitizer] Restore __thumb__ workaround
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 7 18:04:14 PST 2021
Author: Vitaly Buka
Date: 2021-12-07T18:04:06-08:00
New Revision: 5ff52be5d98a621db6de079ad09d0f94854938e8
URL: https://github.com/llvm/llvm-project/commit/5ff52be5d98a621db6de079ad09d0f94854938e8
DIFF: https://github.com/llvm/llvm-project/commit/5ff52be5d98a621db6de079ad09d0f94854938e8.diff
LOG: [sanitizer] Restore __thumb__ workaround
It was removed in D114934 and failed clang-thumbv7-full-2stage.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
index 2eb34905785f2..f0a008a11eb0b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp
@@ -188,6 +188,9 @@ bool AllocatorMayReturnNull() {
void SetAllocatorMayReturnNull(bool may_return_null) {
atomic_store(&allocator_may_return_null, may_return_null,
memory_order_relaxed);
+#ifdef START_BACKGROUND_THREAD_EARLY
+ MaybeStartBackgroudThread();
+#endif
}
void PrintHintAllocatorCannotReturnNull() {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 945cdf3c868dd..929dac1abd1e0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -932,6 +932,13 @@ inline uptr GetPthreadDestructorIterations() {
void *internal_start_thread(void *(*func)(void*), void *arg);
void internal_join_thread(void *th);
+void MaybeStartBackgroudThread();
+
+#if defined(__thumb__) && defined(__linux__)
+// Workaround for
+// https://lab.llvm.org/buildbot/#/builders/clang-thumbv7-full-2stage
+# define START_BACKGROUND_THREAD_EARLY
+#endif
// Make the compiler think that something is going on there.
// Use this inside a loop that looks like memset/memcpy/etc to prevent the
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index bab77b4deff8c..a5d9eef2c7e9c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -78,7 +78,7 @@ void *BackgroundThread(void *arg) {
}
}
-static void MaybeStartBackgroudThread() {
+void MaybeStartBackgroudThread() {
// Need to implement/test on other platforms.
// Start the background thread if one of the rss limits is given.
if (!common_flags()->hard_rss_limit_mb &&
@@ -96,15 +96,17 @@ static void MaybeStartBackgroudThread() {
}
}
-# pragma clang diagnostic push
+# ifndef START_BACKGROUND_THREAD_EARLY
+# pragma clang diagnostic push
// We avoid global-constructors to be sure that globals are ready when
// sanitizers need them. This can happend before global constructors executed.
// Here we don't mind if thread is started on later stages.
-# pragma clang diagnostic ignored "-Wglobal-constructors"
+# pragma clang diagnostic ignored "-Wglobal-constructors"
static struct BackgroudThreadStarted {
BackgroudThreadStarted() { MaybeStartBackgroudThread(); }
} background_thread_strarter UNUSED;
-# pragma clang diagnostic pop
+# pragma clang diagnostic pop
+# endif
#endif
void WriteToSyslog(const char *msg) {
More information about the llvm-commits
mailing list