[compiler-rt] r201547 - [CMake] Simplify setting compile flag disabling RTTI

Alexey Samsonov samsonov at google.com
Mon Feb 17 23:52:41 PST 2014


Author: samsonov
Date: Tue Feb 18 01:52:40 2014
New Revision: 201547

URL: http://llvm.org/viewvc/llvm-project?rev=201547&view=rev
Log:
[CMake] Simplify setting compile flag disabling RTTI

Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/lib/interception/CMakeLists.txt
    compiler-rt/trunk/lib/lsan/CMakeLists.txt
    compiler-rt/trunk/lib/msan/CMakeLists.txt
    compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
    compiler-rt/trunk/lib/tsan/CMakeLists.txt
    compiler-rt/trunk/test/CMakeLists.txt

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -144,12 +144,6 @@ pythonize_bool(COMPILER_RT_DEBUG)
 #================================
 include(config-ix)
 
-macro(append_if list condition var)
-  if (${condition})
-    list(APPEND ${list} ${var})
-  endif()
-endmacro()
-
 # Provide some common commmandline flags for Sanitizer runtimes.
 append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_FPIC_FLAG -fPIC)
 append_if(SANITIZER_COMMON_CFLAGS COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin)
@@ -229,17 +223,6 @@ filter_available_targets(UBSAN_SUPPORTED
 
 add_subdirectory(include)
 
-# When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
-# and run tests with tools from the host toolchain.
-if (NOT ANDROID)
-  set(SANITIZER_COMMON_LIT_TEST_DEPS
-    clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
-    compiler-rt-headers)
-  if(UNIX)
-    list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
-  endif()
-endif()
-
 set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx)
 if(EXISTS ${COMPILER_RT_LIBCXX_PATH}/)
   set(COMPILER_RT_HAS_LIBCXX_SOURCES TRUE)

Modified: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake Tue Feb 18 01:52:40 2014
@@ -36,3 +36,14 @@ macro(pythonize_bool var)
     set(${var}_PYBOOL False)
   endif()
 endmacro()
+
+macro(append_if list condition var)
+  if (${condition})
+    list(APPEND ${list} ${var})
+  endif()
+endmacro()
+
+macro(append_no_rtti_flag list)
+  append_if(${list} COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti)
+  append_if(${list} COMPILER_RT_HAS_GR_FLAG /GR-)
+endmacro()

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue Feb 18 01:52:40 2014
@@ -8,8 +8,10 @@ check_cxx_compiler_flag(-fomit-frame-poi
 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(-fvisibility=hidden  COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG)
+check_cxx_compiler_flag(-fno-rtti            COMPILER_RT_HAS_FNO_RTTI_FLAG)
 check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG)
 
+check_cxx_compiler_flag(/GR COMPILER_RT_HAS_GR_FLAG)
 check_cxx_compiler_flag(/GS COMPILER_RT_HAS_GS_FLAG)
 check_cxx_compiler_flag(/MT COMPILER_RT_HAS_MT_FLAG)
 check_cxx_compiler_flag(/Oy COMPILER_RT_HAS_Oy_FLAG)

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -28,15 +28,8 @@ if(ANDROID)
   include_directories(${COMPILER_RT_EXTRA_ANDROID_HEADERS})
 endif()
 
-if (NOT MSVC)
-  set(ASAN_CFLAGS
-    ${SANITIZER_COMMON_CFLAGS}
-    -fno-rtti)
-else()
-  set(ASAN_CFLAGS
-    ${SANITIZER_COMMON_CFLAGS}
-    /GR-)
-endif()
+set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+append_no_rtti_flag(ASAN_CFLAGS)
 
 set(ASAN_COMMON_DEFINITIONS
   ASAN_HAS_EXCEPTIONS=1)

Modified: compiler-rt/trunk/lib/interception/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/interception/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -9,15 +9,8 @@ set(INTERCEPTION_SOURCES
 
 include_directories(..)
 
-if (NOT MSVC)
-  set(INTERCEPTION_CFLAGS
-    ${SANITIZER_COMMON_CFLAGS}
-    -fno-rtti)
-else()
-  set(INTERCEPTION_CFLAGS
-    ${SANITIZER_COMMON_CFLAGS}
-    /GR-)
-endif()
+set(INTERCEPTION_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+append_no_rtti_flag(INTERCEPTION_CFLAGS)
 
 if(APPLE)
   # Build universal binary on APPLE.

Modified: compiler-rt/trunk/lib/lsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/lsan/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -1,8 +1,7 @@
 include_directories(..)
 
-set(LSAN_CFLAGS
-  ${SANITIZER_COMMON_CFLAGS}
-  -fno-rtti)
+set(LSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+append_no_rtti_flag(LSAN_CFLAGS)
 
 set(LSAN_COMMON_SOURCES
   lsan_common.cc

Modified: compiler-rt/trunk/lib/msan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -9,12 +9,13 @@ set(MSAN_RTL_SOURCES
   msan_new_delete.cc
   msan_report.cc
   )
+
 set(MSAN_RTL_CFLAGS
   ${SANITIZER_COMMON_CFLAGS}
-  -fno-rtti
   -fPIE
   # Prevent clang from generating libc calls.
   -ffreestanding)
+append_no_rtti_flag(MSAN_RTL_CFLAGS)
 
 # Static runtime library.
 add_custom_target(msan)

Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -88,15 +88,8 @@ else()
     SANITIZER_NEEDS_SEGV=1)
 endif()
 
-if (NOT MSVC)
-  set(SANITIZER_CFLAGS
-    ${SANITIZER_COMMON_CFLAGS}
-    -fno-rtti)
-else()
-  set(SANITIZER_CFLAGS
-    ${SANITIZER_COMMON_CFLAGS}
-    /GR-)
-endif()
+set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+append_no_rtti_flag(SANITIZER_CFLAGS)
 
 append_if(SANITIZER_CFLAGS COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG -Wframe-larger-than=512)
 append_if(SANITIZER_CFLAGS COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors)

Modified: compiler-rt/trunk/lib/tsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -6,8 +6,8 @@ include_directories(..)
 # TSan runtime to be built with -fPIE to reduce the number of register spills.
 set(TSAN_CFLAGS
   ${SANITIZER_COMMON_CFLAGS}
-  -fPIE
-  -fno-rtti)
+  -fPIE)
+append_no_rtti_flag(TSAN_CFLAGS)
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
 append_if(TSAN_RTL_CFLAGS COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG -Wframe-larger-than=512)

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=201547&r1=201546&r2=201547&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Tue Feb 18 01:52:40 2014
@@ -6,6 +6,17 @@ configure_lit_site_cfg(
 # add_subdirectory(BlocksRuntime)
 # add_subdirectory(builtins)
 
+# When ANDROID, we build tests with the host compiler (i.e. CMAKE_C_COMPILER),
+# and run tests with tools from the host toolchain.
+if (NOT ANDROID)
+  set(SANITIZER_COMMON_LIT_TEST_DEPS
+    clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
+    compiler-rt-headers)
+  if(UNIX)
+    list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS SanitizerLintCheck)
+  endif()
+endif()
+
 # Run sanitizer tests only if we're sure that clang would produce
 # working binaries.
 if(COMPILER_RT_CAN_EXECUTE_TESTS)





More information about the llvm-commits mailing list