diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -29,6 +29,8 @@ append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SCUDO_LINK_FLAGS) if(ANDROID) + list(APPEND SCUDO_CFLAGS -fno-emulated-tls) + # Put the shared library in the global group. For more details, see # android-changes-for-ndk-developers.md#changes-to-library-search-order append_list_if(COMPILER_RT_HAS_Z_GLOBAL -Wl,-z,global SCUDO_LINK_FLAGS) diff --git a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt --- a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt @@ -16,6 +16,10 @@ # TODO(kostyak): find a way to make -fsized-deallocation work -Wno-mismatched-new-delete) +if(ANDROID) + list(APPEND SCUDO_UNITTEST_CFLAGS -fno-emulated-tls) +endif() + set(SCUDO_TEST_ARCH ${SCUDO_STANDALONE_SUPPORTED_ARCH}) # gtests requires c++ diff --git a/compiler-rt/lib/scudo/standalone/tsd_shared.h b/compiler-rt/lib/scudo/standalone/tsd_shared.h --- a/compiler-rt/lib/scudo/standalone/tsd_shared.h +++ b/compiler-rt/lib/scudo/standalone/tsd_shared.h @@ -72,7 +72,7 @@ private: ALWAYS_INLINE void setCurrentTSD(TSD *CurrentTSD) { -#if SCUDO_ANDROID +#if _BIONIC *getAndroidTlsPtr() = reinterpret_cast(CurrentTSD); #elif SCUDO_LINUX ThreadTSD = CurrentTSD; @@ -84,7 +84,7 @@ } ALWAYS_INLINE TSD *getCurrentTSD() { -#if SCUDO_ANDROID +#if _BIONIC return reinterpret_cast *>(*getAndroidTlsPtr()); #elif SCUDO_LINUX return ThreadTSD; @@ -152,12 +152,12 @@ u32 CoPrimes[MaxTSDCount]; bool Initialized; HybridMutex Mutex; -#if SCUDO_LINUX && !SCUDO_ANDROID +#if SCUDO_LINUX && !_BIONIC static THREADLOCAL TSD *ThreadTSD; #endif }; -#if SCUDO_LINUX && !SCUDO_ANDROID +#if SCUDO_LINUX && !_BIONIC template THREADLOCAL TSD *TSDRegistrySharedT::ThreadTSD;