Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -327,6 +327,15 @@ endif() endif() +if(APPLE AND SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.9") + # Mac OS X prior to 10.9 had problems with exporting symbols from + # libc++/libc++abi. + set(SANITIZER_CAN_USE_CXXABI FALSE) +else() + set(SANITIZER_CAN_USE_CXXABI TRUE) +endif() +pythonize_bool(SANITIZER_CAN_USE_CXXABI) + add_subdirectory(include) set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx) Index: lib/ubsan/CMakeLists.txt =================================================================== --- lib/ubsan/CMakeLists.txt +++ lib/ubsan/CMakeLists.txt @@ -28,11 +28,16 @@ add_custom_target(ubsan) if(APPLE) + set(UBSAN_COMMON_SOURCES ${UBSAN_SOURCES}) + if(SANITIZER_CAN_USE_CXXABI) + list(APPEND UBSAN_COMMON_SOURCES ${UBSAN_CXX_SOURCES}) + endif() + # Common parts of UBSan runtime. add_compiler_rt_object_libraries(RTUbsan OS ${SANITIZER_COMMON_SUPPORTED_OS} ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH} - SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES} + SOURCES ${UBSAN_COMMON_SOURCES} CFLAGS ${UBSAN_CXXFLAGS}) if(COMPILER_RT_HAS_UBSAN) Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -90,6 +90,10 @@ if not compiler_rt_debug: config.available_features.add('compiler-rt-optimized') +sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True) +if sanitizer_can_use_cxxabi: + config.available_features.add('cxxabi') + lit.util.usePlatformSdkOnDarwin(config, lit_config) def is_darwin_lto_supported(): Index: test/lit.common.configured.in =================================================================== --- test/lit.common.configured.in +++ test/lit.common.configured.in @@ -27,6 +27,7 @@ set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@) set_default("compiler_rt_libdir", "@COMPILER_RT_LIBRARY_OUTPUT_DIR@") set_default("emulator", "@COMPILER_RT_EMULATOR@") +set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@) # LLVM tools dir can be passed in lit parameters, so try to # apply substitution. Index: test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp +++ test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp @@ -1,6 +1,8 @@ // RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t // RUN: not %run %t 2>&1 | FileCheck %s +// REQUIRES: cxxabi + struct S { virtual int f() { return 0; } }; struct T : virtual S {}; Index: test/ubsan/TestCases/TypeCheck/vptr.cpp =================================================================== --- test/ubsan/TestCases/TypeCheck/vptr.cpp +++ test/ubsan/TestCases/TypeCheck/vptr.cpp @@ -24,7 +24,7 @@ // RUN: echo "vptr_check:S" > %t.loc-supp // RUN: UBSAN_OPTIONS="suppressions='%t.loc-supp'" not %run %t x- 2>&1 | FileCheck %s --check-prefix=CHECK-LOC-SUPPRESS -// REQUIRES: stable-runtime +// REQUIRES: stable-runtime, cxxabi #include #include #include