1 include_directories(..) 2 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 ) 12 set(MSAN_RTL_CFLAGS 13 ${SANITIZER_COMMON_CFLAGS} 14 -fno-rtti 15 -fPIE 16 # Prevent clang from generating libc calls. 17 -ffreestanding) 18 19 # Static runtime library. 20 set(MSAN_RUNTIME_LIBRARIES) 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 SYMS msan.syms) 30 list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch}) 31 endif() 32 33 add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt) 34 35 # We should only build MSan unit tests if we can build instrumented libcxx. 36 set(MSAN_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx) 37 if(EXISTS ${MSAN_LIBCXX_PATH}/) 38 set(MSAN_CAN_INSTRUMENT_LIBCXX TRUE) 39 else() 40 set(MSAN_CAN_INSTRUMENT_LIBCXX FALSE) 41 endif() 42 43 if(LLVM_INCLUDE_TESTS) 44 add_subdirectory(tests) 45 endif() 46 47 add_subdirectory(lit_tests) 48