CMakeLists.txt revision 3e587a4f631c1b7338d4f2a29df74b704b8bb1ca
1# Build for the undefined behavior sanitizer runtime support library. 2 3set(UBSAN_SOURCES 4 ubsan_diag.cc 5 ubsan_handlers.cc 6 ubsan_value.cc 7 ) 8 9set(UBSAN_CXX_SOURCES 10 ubsan_handlers_cxx.cc 11 ubsan_type_hash.cc 12 ) 13 14include_directories(..) 15 16set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) 17 18filter_available_targets(UBSAN_SUPPORTED_ARCH 19 x86_64 i386) 20 21set(UBSAN_RUNTIME_LIBRARIES) 22 23if(APPLE) 24 # Build universal binary on APPLE. 25 add_compiler_rt_osx_static_runtime(clang_rt.ubsan_osx 26 ARCH ${UBSAN_SUPPORTED_ARCH} 27 SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES} 28 $<TARGET_OBJECTS:RTSanitizerCommon.osx> 29 CFLAGS ${UBSAN_CFLAGS}) 30 list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx) 31else() 32 # Build separate libraries for each target. 33 foreach(arch ${UBSAN_SUPPORTED_ARCH}) 34 # Main UBSan runtime. 35 add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch} 36 SOURCES ${UBSAN_SOURCES} 37 CFLAGS ${UBSAN_CFLAGS}) 38 # C++-specific parts of UBSan runtime. Requires a C++ ABI library. 39 add_compiler_rt_static_runtime(clang_rt.ubsan_cxx-${arch} ${arch} 40 SOURCES ${UBSAN_CXX_SOURCES} 41 CFLAGS ${UBSAN_CFLAGS}) 42 list(APPEND UBSAN_RUNTIME_LIBRARIES 43 clang_rt.san-${arch} 44 clang_rt.ubsan-${arch} 45 clang_rt.ubsan_cxx-${arch}) 46 endforeach() 47endif() 48 49add_subdirectory(lit_tests) 50