2012-10-10 03:34:32 +08:00
|
|
|
# Build for the undefined behavior sanitizer runtime support library.
|
|
|
|
|
|
|
|
set(UBSAN_SOURCES
|
|
|
|
ubsan_diag.cc
|
|
|
|
ubsan_handlers.cc
|
2013-03-21 07:49:17 +08:00
|
|
|
ubsan_value.cc
|
|
|
|
)
|
|
|
|
|
|
|
|
set(UBSAN_CXX_SOURCES
|
2012-10-25 10:07:02 +08:00
|
|
|
ubsan_handlers_cxx.cc
|
|
|
|
ubsan_type_hash.cc
|
2012-10-10 03:34:32 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
include_directories(..)
|
|
|
|
|
|
|
|
set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
|
|
|
|
2013-01-19 00:51:07 +08:00
|
|
|
filter_available_targets(UBSAN_SUPPORTED_ARCH
|
|
|
|
x86_64 i386)
|
|
|
|
|
2012-10-10 03:34:32 +08:00
|
|
|
set(UBSAN_RUNTIME_LIBRARIES)
|
|
|
|
|
2012-11-16 20:57:07 +08:00
|
|
|
if(APPLE)
|
|
|
|
# Build universal binary on APPLE.
|
2013-01-21 16:12:20 +08:00
|
|
|
add_compiler_rt_osx_static_runtime(clang_rt.ubsan_osx
|
|
|
|
ARCH ${UBSAN_SUPPORTED_ARCH}
|
2013-03-21 07:49:17 +08:00
|
|
|
SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES}
|
2013-01-21 16:12:20 +08:00
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
|
|
|
|
CFLAGS ${UBSAN_CFLAGS})
|
2012-11-16 20:57:07 +08:00
|
|
|
list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx)
|
|
|
|
else()
|
|
|
|
# Build separate libraries for each target.
|
2013-01-19 00:51:07 +08:00
|
|
|
foreach(arch ${UBSAN_SUPPORTED_ARCH})
|
2013-03-21 07:49:17 +08:00
|
|
|
# Main UBSan runtime.
|
2013-01-21 16:12:20 +08:00
|
|
|
add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch}
|
|
|
|
SOURCES ${UBSAN_SOURCES}
|
2013-03-23 08:31:07 +08:00
|
|
|
CFLAGS ${UBSAN_CFLAGS}
|
|
|
|
SYMS ubsan.syms)
|
2013-03-21 07:49:17 +08:00
|
|
|
# C++-specific parts of UBSan runtime. Requires a C++ ABI library.
|
|
|
|
add_compiler_rt_static_runtime(clang_rt.ubsan_cxx-${arch} ${arch}
|
|
|
|
SOURCES ${UBSAN_CXX_SOURCES}
|
2013-03-23 08:31:07 +08:00
|
|
|
CFLAGS ${UBSAN_CFLAGS}
|
|
|
|
SYMS ubsan.syms)
|
2013-03-21 07:49:17 +08:00
|
|
|
list(APPEND UBSAN_RUNTIME_LIBRARIES
|
|
|
|
clang_rt.san-${arch}
|
|
|
|
clang_rt.ubsan-${arch}
|
|
|
|
clang_rt.ubsan_cxx-${arch})
|
2013-01-19 00:51:07 +08:00
|
|
|
endforeach()
|
2012-10-10 03:34:32 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_subdirectory(lit_tests)
|