diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index c59b4456cd4549..45c52f804f4854 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -114,6 +114,7 @@ construct_compiler_rt_default_triple() if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$") if (${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "^arm") set(COMPILER_RT_DEFAULT_TARGET_ARCH "armhf") + CHECK_SYMBOL_EXISTS (__thumb__ "" COMPILER_RT_ARM_THUMB) endif() endif() if ("${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" MATCHES ".*android.*") diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc index b83ac03408d88b..5964c7020d3145 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc @@ -40,7 +40,12 @@ COMMON_FLAG(bool, fast_unwind_on_check, false, COMMON_FLAG(bool, fast_unwind_on_fatal, false, "If available, use the fast frame-pointer-based unwinder on fatal " "errors.") -COMMON_FLAG(bool, fast_unwind_on_malloc, true, +// ARM thumb/thumb2 frame pointer is inconsistent on GCC and Clang [1] +// and fast-unwider is also unreliable with mixing arm and thumb code [2]. +// [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92172 +// [2] https://bugs.llvm.org/show_bug.cgi?id=44158 +COMMON_FLAG(bool, fast_unwind_on_malloc, + !(SANITIZER_LINUX && !SANITIZER_ANDROID && SANITIZER_ARM), "If available, use the fast frame-pointer-based unwinder on " "malloc/free.") COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.") diff --git a/compiler-rt/test/asan/TestCases/Linux/clang_gcc_abi.cpp b/compiler-rt/test/asan/TestCases/Linux/clang_gcc_abi.cpp index 0c3fa0aed7d046..314e7d35b460b2 100644 --- a/compiler-rt/test/asan/TestCases/Linux/clang_gcc_abi.cpp +++ b/compiler-rt/test/asan/TestCases/Linux/clang_gcc_abi.cpp @@ -1,7 +1,7 @@ -// RUN: %clangxx_asan -O0 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -O1 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -O2 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -O3 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O0 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O1 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O2 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O3 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s // REQUIRES: (arm-target-arch || armhf-target-arch), fast-unwinder-works diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py index f9c491846a4299..4cfd0b68b7619d 100644 --- a/compiler-rt/test/asan/lit.cfg.py +++ b/compiler-rt/test/asan/lit.cfg.py @@ -205,7 +205,7 @@ def build_invocation(compile_flags): config.available_features.add("asan-" + config.bits + "-bits") # Fast unwinder doesn't work with Thumb -if re.search('mthumb', config.target_cflags) is None: +if not config.arm_thumb: config.available_features.add('fast-unwinder-works') # Turn on leak detection on 64-bit Linux. diff --git a/compiler-rt/test/asan/lit.site.cfg.py.in b/compiler-rt/test/asan/lit.site.cfg.py.in index 81cebde2029ed7..afecfafeb99f94 100644 --- a/compiler-rt/test/asan/lit.site.cfg.py.in +++ b/compiler-rt/test/asan/lit.site.cfg.py.in @@ -5,6 +5,7 @@ config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@" config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@" config.clang = "@ASAN_TEST_TARGET_CC@" config.bits = "@ASAN_TEST_BITS@" +config.arm_thumb = "@COMPILER_RT_ARM_THUMB@" config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@" config.apple_platform_min_deployment_target_flag = "@ASAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG@" config.asan_dynamic = @ASAN_TEST_DYNAMIC@