2012-10-10 03:34:32 +08:00
|
|
|
# Build for the undefined behavior sanitizer runtime support library.
|
|
|
|
|
|
|
|
set(UBSAN_SOURCES
|
|
|
|
ubsan_diag.cc
|
2014-07-26 06:24:34 +08:00
|
|
|
ubsan_init.cc
|
2014-07-24 02:44:54 +08:00
|
|
|
ubsan_flags.cc
|
2012-10-10 03:34:32 +08:00
|
|
|
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})
|
2014-07-30 05:52:25 +08:00
|
|
|
append_no_rtti_flag(UBSAN_CFLAGS)
|
|
|
|
set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS})
|
2012-10-10 03:34:32 +08:00
|
|
|
|
2014-02-14 19:42:22 +08:00
|
|
|
add_custom_target(ubsan)
|
2012-10-10 03:34:32 +08:00
|
|
|
|
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>
|
2014-07-30 05:52:25 +08:00
|
|
|
CFLAGS ${UBSAN_CXXFLAGS})
|
2014-02-14 19:42:22 +08:00
|
|
|
add_dependencies(ubsan clang_rt.ubsan_osx)
|
2012-11-16 20:57:07 +08:00
|
|
|
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.
|
2014-03-31 21:45:36 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan-${arch} ${arch} STATIC
|
2013-01-21 16:12:20 +08:00
|
|
|
SOURCES ${UBSAN_SOURCES}
|
2013-08-27 23:08:02 +08:00
|
|
|
CFLAGS ${UBSAN_CFLAGS})
|
2013-03-21 07:49:17 +08:00
|
|
|
# C++-specific parts of UBSan runtime. Requires a C++ ABI library.
|
2014-03-31 21:45:36 +08:00
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan_cxx-${arch} ${arch} STATIC
|
2013-03-21 07:49:17 +08:00
|
|
|
SOURCES ${UBSAN_CXX_SOURCES}
|
2014-07-30 05:52:25 +08:00
|
|
|
CFLAGS ${UBSAN_CXXFLAGS})
|
2014-02-14 19:42:22 +08:00
|
|
|
add_dependencies(ubsan
|
2013-08-28 16:07:04 +08:00
|
|
|
clang_rt.san-${arch}
|
|
|
|
clang_rt.ubsan-${arch}
|
|
|
|
clang_rt.ubsan_cxx-${arch})
|
|
|
|
if (UNIX AND NOT ${arch} STREQUAL "i386")
|
|
|
|
add_sanitizer_rt_symbols(clang_rt.ubsan-${arch} ubsan.syms.extra)
|
|
|
|
add_sanitizer_rt_symbols(clang_rt.ubsan_cxx-${arch} ubsan.syms.extra)
|
2014-02-14 19:42:22 +08:00
|
|
|
add_dependencies(ubsan
|
2013-08-28 16:07:04 +08:00
|
|
|
clang_rt.ubsan-${arch}-symbols
|
|
|
|
clang_rt.ubsan_cxx-${arch}-symbols)
|
|
|
|
endif()
|
2013-01-19 00:51:07 +08:00
|
|
|
endforeach()
|
2012-10-10 03:34:32 +08:00
|
|
|
endif()
|
2014-02-18 17:33:45 +08:00
|
|
|
|
|
|
|
add_dependencies(compiler-rt ubsan)
|