[cmake] Address Samsonov's post-commit review of r262723
authorFilipe Cabecinhas <me@filcab.net>
Sat, 5 Mar 2016 10:01:04 +0000 (10:01 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Sat, 5 Mar 2016 10:01:04 +0000 (10:01 +0000)
Reviewers: samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D17896

llvm-svn: 262770

compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/dfsan/CMakeLists.txt
compiler-rt/lib/interception/CMakeLists.txt
compiler-rt/lib/lsan/CMakeLists.txt
compiler-rt/lib/msan/CMakeLists.txt
compiler-rt/lib/sanitizer_common/CMakeLists.txt
compiler-rt/lib/tsan/CMakeLists.txt
compiler-rt/lib/tsan/dd/CMakeLists.txt
compiler-rt/lib/ubsan/CMakeLists.txt

index a8fd89a5505454917c40f701764892aacdb6610e..da5a2a1f4f887c45bf1ea6e53977ace64f694172 100644 (file)
@@ -45,9 +45,14 @@ macro(append_string_if condition value)
   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 eea17c046054ef997ccc493e334a1f51505b4975..0a9e9da7af103299157d7a71226a23f23f738eaf 100644 (file)
@@ -21,6 +21,7 @@ check_cxx_compiler_flag(-funwind-tables      COMPILER_RT_HAS_FUNWIND_TABLES_FLAG
 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 3a29ba830beb2e8c4a5f176495eb40ad211d925b..57ac56f8c8f97ec309e3902a4119f6a597c9942b 100644 (file)
@@ -32,7 +32,7 @@ set(ASAN_PREINIT_SOURCES
 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 19a7909d0429f09a72039ff0b7fa94172d3c1e9f..438dff5003728a2ef00144f08d5fd794e12c174f 100644 (file)
@@ -6,7 +6,7 @@ set(DFSAN_RTL_SOURCES
   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 16b41c976d6bc220ce442552f801e030532f50bd..972b31084a28a8dcb494156dd7e6d4d9a5e03911 100644 (file)
@@ -10,7 +10,7 @@ set(INTERCEPTION_SOURCES
 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 20e40932165c011e26c2499730735f2c53ccac37..ac2fd1ed8be2fa2bad2d3fdb5a1884da05456ceb 100644 (file)
@@ -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 fb75daeb949d9db3dbd90bb6a34c0a1cd7db952d..c10ecbfece382d42dba488b5018cdbc1cf4d90b6 100644 (file)
@@ -17,7 +17,7 @@ set(MSAN_RTL_CXX_SOURCES
 
 
 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 6a20f025507a7ee80ef0c1eea7a74b229762cdfa..5d197a472f6beeacfa293c95efd940a3e6277d2c 100644 (file)
@@ -122,7 +122,7 @@ append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITION
 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 a151c6c6b076218c9ae1257362265e76e2962a3d..4f0e4a1e3e5e984fb8ef05af3cf1965194a7a59f 100644 (file)
@@ -6,7 +6,7 @@ set(TSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 # 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 6330bd9fbe7a5adb5e3f3fecb65de9fd892d9a54..bcff35f20b36cfcf0daf4161f2a66fcfe1ea4805 100644 (file)
@@ -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 de477fd2dc16d8a4998becdc661ac93436e1d970..8176c82ca47b0d4620541ecd039812920002cfe5 100644 (file)
@@ -22,18 +22,16 @@ set(UBSAN_CXX_SOURCES
 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)