1 # Build for the undefined behavior sanitizer runtime support library. 2 3 set(UBSAN_SOURCES 4 ubsan_diag.cc 5 ubsan_handlers.cc 6 ubsan_handlers_cxx.cc 7 ubsan_type_hash.cc 8 ubsan_value.cc 9 ) 10 11 include_directories(..) 12 13 set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) 14 15 filter_available_targets(UBSAN_SUPPORTED_ARCH 16 x86_64 i386) 17 18 set(UBSAN_RUNTIME_LIBRARIES) 19 20 if(APPLE) 21 # Build universal binary on APPLE. 22 add_compiler_rt_osx_static_runtime(clang_rt.ubsan_osx 23 ARCH ${UBSAN_SUPPORTED_ARCH} 24 SOURCES ${UBSAN_SOURCES} 25 $<TARGET_OBJECTS:RTSanitizerCommon.osx> 26 CFLAGS ${UBSAN_CFLAGS}) 27 list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx) 28 else() 29 # Build separate libraries for each target. 30 foreach(arch ${UBSAN_SUPPORTED_ARCH}) 31 add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch} 32 SOURCES ${UBSAN_SOURCES} 33 $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> 34 CFLAGS ${UBSAN_CFLAGS}) 35 list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-${arch}) 36 endforeach() 37 endif() 38 39 add_subdirectory(lit_tests) 40