forked from OSchip/llvm-project
				
			[CMake] Simplify setting compile flag disabling RTTI
llvm-svn: 201547
This commit is contained in:
		
							parent
							
								
									16a03613fa
								
							
						
					
					
						commit
						b73db72a17
					
				| 
						 | 
				
			
			@ -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_ARCH x86_64 i386)
 | 
			
		|||
 | 
			
		||||
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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,8 +8,10 @@ check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER
 | 
			
		|||
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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue