Index: cmake/Modules/CompilerRTUtils.cmake =================================================================== --- cmake/Modules/CompilerRTUtils.cmake +++ cmake/Modules/CompilerRTUtils.cmake @@ -45,9 +45,14 @@ endif() endmacro() -macro(append_no_rtti_flag list) - append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list}) - append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list}) +macro(append_rtti_flag polarity list) + if(polarity) + append_list_if(COMPILER_RT_HAS_FRTTI_FLAG -frtti ${list}) + append_list_if(COMPILER_RT_HAS_GR_FLAG /GR ${list}) + else() + append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list}) + append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list}) + endif() endmacro() macro(append_have_file_definition filename varname list) Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -21,6 +21,7 @@ check_cxx_compiler_flag(-fno-stack-protector COMPILER_RT_HAS_FNO_STACK_PROTECTOR_FLAG) check_cxx_compiler_flag(-fno-sanitize=safe-stack COMPILER_RT_HAS_FNO_SANITIZE_SAFE_STACK_FLAG) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG) +check_cxx_compiler_flag(-frtti COMPILER_RT_HAS_FRTTI_FLAG) check_cxx_compiler_flag(-fno-rtti COMPILER_RT_HAS_FNO_RTTI_FLAG) check_cxx_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG) check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG) Index: lib/asan/CMakeLists.txt =================================================================== --- lib/asan/CMakeLists.txt +++ lib/asan/CMakeLists.txt @@ -32,7 +32,7 @@ include_directories(..) set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(ASAN_CFLAGS) +append_rtti_flag(OFF ASAN_CFLAGS) set(ASAN_COMMON_DEFINITIONS ASAN_HAS_EXCEPTIONS=1) Index: lib/dfsan/CMakeLists.txt =================================================================== --- lib/dfsan/CMakeLists.txt +++ lib/dfsan/CMakeLists.txt @@ -6,7 +6,7 @@ dfsan_custom.cc dfsan_interceptors.cc) set(DFSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(DFSAN_COMMON_CFLAGS) +append_rtti_flag(OFF DFSAN_COMMON_CFLAGS) # Prevent clang from generating libc calls. append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CFLAGS) Index: lib/interception/CMakeLists.txt =================================================================== --- lib/interception/CMakeLists.txt +++ lib/interception/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories(..) set(INTERCEPTION_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(INTERCEPTION_CFLAGS) +append_rtti_flag(OFF INTERCEPTION_CFLAGS) add_compiler_rt_object_libraries(RTInterception OS ${SANITIZER_COMMON_SUPPORTED_OS} Index: lib/lsan/CMakeLists.txt =================================================================== --- lib/lsan/CMakeLists.txt +++ lib/lsan/CMakeLists.txt @@ -1,7 +1,7 @@ include_directories(..) set(LSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(LSAN_CFLAGS) +append_rtti_flag(OFF LSAN_CFLAGS) set(LSAN_COMMON_SOURCES lsan_common.cc Index: lib/msan/CMakeLists.txt =================================================================== --- lib/msan/CMakeLists.txt +++ lib/msan/CMakeLists.txt @@ -17,7 +17,7 @@ set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(MSAN_RTL_CFLAGS) +append_rtti_flag(OFF MSAN_RTL_CFLAGS) append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE MSAN_RTL_CFLAGS) # Prevent clang from generating libc calls. append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS) Index: lib/sanitizer_common/CMakeLists.txt =================================================================== --- lib/sanitizer_common/CMakeLists.txt +++ lib/sanitizer_common/CMakeLists.txt @@ -122,7 +122,7 @@ append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS) set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(SANITIZER_CFLAGS) +append_rtti_flag(OFF SANITIZER_CFLAGS) append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570 SANITIZER_CFLAGS) Index: lib/tsan/CMakeLists.txt =================================================================== --- lib/tsan/CMakeLists.txt +++ lib/tsan/CMakeLists.txt @@ -6,7 +6,7 @@ # SANITIZER_COMMON_CFLAGS contains -fPIC, but it's performance-critical for # TSan runtime to be built with -fPIE to reduce the number of register spills. append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TSAN_CFLAGS) -append_no_rtti_flag(TSAN_CFLAGS) +append_rtti_flag(OFF TSAN_CFLAGS) if(COMPILER_RT_TSAN_DEBUG_OUTPUT) # Add extra debug information to TSan runtime. This configuration is rarely Index: lib/tsan/dd/CMakeLists.txt =================================================================== --- lib/tsan/dd/CMakeLists.txt +++ lib/tsan/dd/CMakeLists.txt @@ -3,7 +3,7 @@ include_directories(../..) set(DD_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(DD_CFLAGS) +append_rtti_flag(OFF DD_CFLAGS) set(DD_SOURCES dd_rtl.cc Index: lib/ubsan/CMakeLists.txt =================================================================== --- lib/ubsan/CMakeLists.txt +++ lib/ubsan/CMakeLists.txt @@ -22,18 +22,16 @@ include_directories(..) set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(UBSAN_CFLAGS) +append_rtti_flag(OFF UBSAN_CFLAGS) append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CFLAGS) set(UBSAN_STANDALONE_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -append_no_rtti_flag(UBSAN_STANDALONE_CFLAGS) +append_rtti_flag(OFF UBSAN_STANDALONE_CFLAGS) append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_STANDALONE_CFLAGS) set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS}) +append_rtti_flag(ON UBSAN_STANDALONE_CXXFLAGS) append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CXXFLAGS) -# Make sure we end with -frtti on type_hash -set_property(SOURCE ubsan_type_hash_itanium.cc APPEND_STRING PROPERTY - COMPILE_FLAGS " -frtti") add_custom_target(ubsan)