[compiler-rt] ac191bc - [compiler-rt][test] Add REQUIRES for checking static libc++abi

Leonard Chan via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 22 15:26:42 PDT 2021


Author: Leonard Chan
Date: 2021-09-22T15:25:05-07:00
New Revision: ac191bcc99e2fc4ab7993138f5e82a0b75b7e9db

URL: https://github.com/llvm/llvm-project/commit/ac191bcc99e2fc4ab7993138f5e82a0b75b7e9db
DIFF: https://github.com/llvm/llvm-project/commit/ac191bcc99e2fc4ab7993138f5e82a0b75b7e9db.diff

LOG: [compiler-rt][test] Add REQUIRES for checking static libc++abi

intercept-rethrow-exception.cc fails when running runtimes tests if linking in
a hermetic libc++abi. This is because if libc++abi is used, then asan expects
to intercept __cxa_rethrow_primary_exception on linux, which should unpoison the
stack. If we statically link in libc++abi though, it will contain a strong
definition for __cxa_rethrow_primary_exception which wins over the weakly
defined interceptor provided by asan, causing the test to fail by not unpoisoning
the stack on the exception being thrown.

It's likely no one has encountered this before and possible that upstream tests
opt for dynamically linking where the interceptor can work properly. An ideal
long term solution would be to update the interceptor and libc++[abi] APIs to
work for this case, but that will likely take a long time to work out. In the
meantime, since the test isn't necessarily broken, we can just add another
REQUIRES check to make sure that it's only run if we aren't statically linking
in libc++abi.

Differential Revision: https://reviews.llvm.org/D109938

Added: 
    

Modified: 
    compiler-rt/CMakeLists.txt
    compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
    compiler-rt/test/lit.common.cfg.py
    compiler-rt/test/lit.common.configured.in

Removed: 
    


################################################################################
diff  --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index fc8a0cf6d46c5..4bbcf9aca4e8f 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -241,6 +241,7 @@ endif()
 
 option(SANITIZER_USE_STATIC_CXX_ABI
   "Use static libc++abi." ${DEFAULT_SANITIZER_USE_STATIC_CXX_ABI})
+pythonize_bool(SANITIZER_USE_STATIC_CXX_ABI)
 
 set(DEFAULT_COMPILER_RT_USE_BUILTINS_LIBRARY OFF)
 if (FUCHSIA)

diff  --git a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
index c3944d6d5605e..4c549b6ad5c7e 100644
--- a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
+++ b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
@@ -1,6 +1,8 @@
 // Regression test for
 // https://bugs.llvm.org/show_bug.cgi?id=32434
 
+// REQUIRES: shared_cxxabi
+
 // RUN: %clangxx_asan -fexceptions -O0 %s -o %t
 // RUN: %run %t
 

diff  --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index 0515475c3b3f1..ca9047b319fa8 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -363,6 +363,9 @@ def get_ios_commands_dir():
 if sanitizer_can_use_cxxabi:
   config.available_features.add('cxxabi')
 
+if not getattr(config, 'sanitizer_uses_static_cxxabi', False):
+  config.available_features.add('shared_cxxabi')
+
 if config.has_lld:
   config.available_features.add('lld-available')
 

diff  --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index 71c2c72bc873c..be4501be87e64 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -33,6 +33,7 @@ set_default("memprof_shadow_scale", "@COMPILER_RT_MEMPROF_SHADOW_SCALE@")
 set_default("apple_platform", "osx")
 set_default("apple_platform_min_deployment_target_flag", "-mmacosx-version-min")
 set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@)
+set_default("sanitizer_uses_static_cxxabi", @SANITIZER_USE_STATIC_CXX_ABI_PYBOOL@)
 set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@)
 set_default("can_symbolize", @CAN_SYMBOLIZE@)
 set_default("use_lld", @COMPILER_RT_TEST_USE_LLD_PYBOOL@)


        


More information about the llvm-commits mailing list