diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -247,7 +247,7 @@ set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64}) endif() -set(ALL_GWP_ASAN_SUPPORTED_ARCH ${X86} ${X86_64}) +set(ALL_GWP_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${ARM32}) if(APPLE) set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64}) else() @@ -691,7 +691,7 @@ # TODO(hctim): Enable this on Android again. Looks like it's causing a SIGSEGV # for Scudo and GWP-ASan, further testing needed. if (COMPILER_RT_HAS_SANITIZER_COMMON AND GWP_ASAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Linux") + OS_NAME MATCHES "Android|Linux") set(COMPILER_RT_HAS_GWP_ASAN TRUE) else() set(COMPILER_RT_HAS_GWP_ASAN FALSE) diff --git a/compiler-rt/lib/gwp_asan/CMakeLists.txt b/compiler-rt/lib/gwp_asan/CMakeLists.txt --- a/compiler-rt/lib/gwp_asan/CMakeLists.txt +++ b/compiler-rt/lib/gwp_asan/CMakeLists.txt @@ -21,7 +21,8 @@ # Ensure that GWP-ASan meets the delegated requirements of some supporting # allocators. Some supporting allocators (e.g. scudo standalone) cannot use any # parts of the C++ standard library. -set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions -nostdinc++ -pthread) +set(GWP_ASAN_CFLAGS -fno-rtti -fno-exceptions -nostdinc++ -pthread + -fno-emulated-tls) append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC GWP_ASAN_CFLAGS) append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fno-omit-frame-pointer GWP_ASAN_CFLAGS) diff --git a/compiler-rt/lib/scudo/CMakeLists.txt b/compiler-rt/lib/scudo/CMakeLists.txt --- a/compiler-rt/lib/scudo/CMakeLists.txt +++ b/compiler-rt/lib/scudo/CMakeLists.txt @@ -41,9 +41,20 @@ # Currently, Scudo uses the GwpAsan flag parser. This backs onto the flag # parsing mechanism of sanitizer_common. Once Scudo has its own flag parsing, # and parses GwpAsan options, you can remove this dependency. - list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser - RTGwpAsanBacktraceLibc) - list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS) + list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsan RTGwpAsanOptionsParser) + + # Install GWP-ASan stubs. Also, ensure that TLS is not emulated on this + # platform (Android still compiles with emulated TLS by default). + list(APPEND SCUDO_CFLAGS -DGWP_ASAN_HOOKS -fno-emulated-tls) + + # Android does not have the libc backtrace() support (from execinfo.h). In + # this case, we use the sanitizer common variant. + if (ANDROID) + list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsanBacktraceSanitizerCommon + RTSanitizerCommonSymbolizer) + else() + list(APPEND SCUDO_MINIMAL_OBJECT_LIBS RTGwpAsanBacktraceLibc) + endif() endif() set(SCUDO_OBJECT_LIBS ${SCUDO_MINIMAL_OBJECT_LIBS})