From: Vitaly Buka Date: Wed, 8 Dec 2021 01:59:39 +0000 (-0800) Subject: [sanitizer] Restore __thumb__ workaround X-Git-Tag: upstream/15.0.7~23695 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ff52be5d98a621db6de079ad09d0f94854938e8;p=platform%2Fupstream%2Fllvm.git [sanitizer] Restore __thumb__ workaround It was removed in D114934 and failed clang-thumbv7-full-2stage. --- diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp index 2eb3490..f0a008a 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 945cdf3..929dac1 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 bab77b4..a5d9eef 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) {