[sanitizer] Restore __thumb__ workaround
authorVitaly Buka <vitalybuka@google.com>
Wed, 8 Dec 2021 01:59:39 +0000 (17:59 -0800)
committerVitaly Buka <vitalybuka@google.com>
Wed, 8 Dec 2021 02:04:06 +0000 (18:04 -0800)
It was removed in D114934 and failed clang-thumbv7-full-2stage.

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

index 2eb3490..f0a008a 100644 (file)
@@ -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() {
index 945cdf3..929dac1 100644 (file)
@@ -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
index bab77b4..a5d9eef 100644 (file)
@@ -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) {