[CMake] Check for -fPIE and -ffreestanding flags for consistency
[blocksruntime.git] / lib / msan / CMakeLists.txt
blob2578b689c3efaa4eef5786c3f162c65dd06819ff
1 include_directories(..)
3 # Runtime library sources and build flags.
4 set(MSAN_RTL_SOURCES
5   msan.cc
6   msan_allocator.cc
7   msan_interceptors.cc
8   msan_linux.cc
9   msan_new_delete.cc
10   msan_report.cc
11   )
13 set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
14 append_no_rtti_flag(MSAN_RTL_CFLAGS)
15 append_if(MSAN_RTL_CFLAGS COMPILER_RT_HAS_FPIE_FLAG -fPIE)
16 # Prevent clang from generating libc calls.
17 append_if(MSAN_RTL_CFLAGS COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding)
19 # Static runtime library.
20 add_custom_target(msan)
21 set(arch "x86_64")
22 if(CAN_TARGET_${arch})
23   add_compiler_rt_static_runtime(clang_rt.msan-${arch} ${arch}
24     SOURCES ${MSAN_RTL_SOURCES}
25             $<TARGET_OBJECTS:RTInterception.${arch}>
26             $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
27             $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
28     CFLAGS ${MSAN_RTL_CFLAGS})
29   add_dependencies(msan clang_rt.msan-${arch})
30   if(UNIX)
31     add_sanitizer_rt_symbols(clang_rt.msan-${arch} msan.syms.extra)
32     add_dependencies(msan clang_rt.msan-${arch}-symbols)
33   endif()
34 endif()
36 add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt)
37 add_dependencies(msan msan_blacklist)
39 if(LLVM_INCLUDE_TESTS)
40   add_subdirectory(tests)
41 endif()