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
|
|
|
|
)
|
|
|
|
|
2015-04-02 06:42:36 +08:00
|
|
|
set(UBSAN_STANDALONE_SOURCES
|
|
|
|
ubsan_init_standalone.cc
|
|
|
|
)
|
|
|
|
|
2013-03-21 07:49:17 +08:00
|
|
|
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)
|
2015-04-02 06:42:36 +08:00
|
|
|
set(UBSAN_STANDALONE_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
|
|
|
append_no_rtti_flag(UBSAN_STANDALONE_CFLAGS)
|
2014-07-30 05:52:25 +08:00
|
|
|
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)
|
2015-06-11 07:55:07 +08:00
|
|
|
# Common parts of UBSan runtime.
|
|
|
|
add_compiler_rt_object_libraries(RTUbsan
|
|
|
|
OS ${SANITIZER_COMMON_SUPPORTED_OS}
|
2015-06-19 11:39:24 +08:00
|
|
|
ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
|
2015-06-11 07:55:07 +08:00
|
|
|
SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES}
|
|
|
|
CFLAGS ${UBSAN_CXXFLAGS})
|
2015-04-02 06:42:36 +08:00
|
|
|
|
2015-06-11 07:55:07 +08:00
|
|
|
if(COMPILER_RT_HAS_UBSAN)
|
|
|
|
# Initializer of standalone UBSan runtime.
|
|
|
|
add_compiler_rt_object_libraries(RTUbsan_standalone
|
|
|
|
OS ${SANITIZER_COMMON_SUPPORTED_OS}
|
2015-06-19 11:39:24 +08:00
|
|
|
ARCHS ${UBSAN_SUPPORTED_ARCH}
|
2015-06-11 07:55:07 +08:00
|
|
|
SOURCES ${UBSAN_STANDALONE_SOURCES}
|
|
|
|
CFLAGS ${UBSAN_STANDALONE_CFLAGS})
|
|
|
|
foreach(os ${SANITIZER_COMMON_SUPPORTED_OS})
|
2015-04-02 06:42:36 +08:00
|
|
|
add_compiler_rt_darwin_dynamic_runtime(clang_rt.ubsan_${os}_dynamic ${os}
|
2015-06-19 11:39:24 +08:00
|
|
|
ARCHS ${UBSAN_SUPPORTED_ARCH}
|
2015-04-02 06:42:36 +08:00
|
|
|
SOURCES $<TARGET_OBJECTS:RTUbsan.${os}>
|
|
|
|
$<TARGET_OBJECTS:RTUbsan_standalone.${os}>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommon.${os}>)
|
2015-03-25 05:57:07 +08:00
|
|
|
|
2015-04-02 06:42:36 +08:00
|
|
|
add_dependencies(ubsan clang_rt.ubsan_${os}_dynamic)
|
2015-06-11 07:55:07 +08:00
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2012-11-16 20:57:07 +08:00
|
|
|
else()
|
2015-04-02 06:42:36 +08:00
|
|
|
# Common parts of UBSan runtime.
|
2015-06-11 07:55:07 +08:00
|
|
|
add_compiler_rt_object_libraries(RTUbsan
|
2015-06-19 11:39:24 +08:00
|
|
|
ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
|
2015-06-11 07:55:07 +08:00
|
|
|
SOURCES ${UBSAN_SOURCES} CFLAGS ${UBSAN_CFLAGS})
|
|
|
|
# C++-specific parts of UBSan runtime. Requires a C++ ABI library.
|
|
|
|
add_compiler_rt_object_libraries(RTUbsan_cxx
|
2015-06-19 11:39:24 +08:00
|
|
|
ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH}
|
2015-06-11 07:55:07 +08:00
|
|
|
SOURCES ${UBSAN_CXX_SOURCES} CFLAGS ${UBSAN_CXXFLAGS})
|
2015-04-02 06:42:36 +08:00
|
|
|
|
2015-04-02 07:00:02 +08:00
|
|
|
if(COMPILER_RT_HAS_UBSAN)
|
2015-06-11 07:55:07 +08:00
|
|
|
# Initializer of standalone UBSan runtime.
|
|
|
|
add_compiler_rt_object_libraries(RTUbsan_standalone
|
2015-06-19 11:39:24 +08:00
|
|
|
ARCHS ${UBSAN_SUPPORTED_ARCH}
|
2015-06-11 07:55:07 +08:00
|
|
|
SOURCES ${UBSAN_STANDALONE_SOURCES} CFLAGS ${UBSAN_STANDALONE_CFLAGS})
|
|
|
|
|
2015-04-02 07:00:02 +08:00
|
|
|
foreach(arch ${UBSAN_SUPPORTED_ARCH})
|
|
|
|
# Standalone UBSan runtimes.
|
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan_standalone-${arch} ${arch} STATIC
|
|
|
|
SOURCES $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
|
|
|
|
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
|
|
|
|
$<TARGET_OBJECTS:RTUbsan.${arch}>
|
|
|
|
$<TARGET_OBJECTS:RTUbsan_standalone.${arch}>
|
|
|
|
CFLAGS ${UBSAN_CFLAGS})
|
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan_standalone_cxx-${arch} ${arch} STATIC
|
|
|
|
SOURCES $<TARGET_OBJECTS:RTUbsan_cxx.${arch}>
|
|
|
|
CFLAGS ${UBSAN_CXXFLAGS})
|
2015-03-24 04:05:53 +08:00
|
|
|
|
2014-02-14 19:42:22 +08:00
|
|
|
add_dependencies(ubsan
|
2015-04-02 07:00:02 +08:00
|
|
|
clang_rt.ubsan_standalone-${arch}
|
|
|
|
clang_rt.ubsan_standalone_cxx-${arch})
|
|
|
|
if (UNIX AND NOT ${arch} MATCHES "i386|i686")
|
|
|
|
add_sanitizer_rt_symbols(clang_rt.ubsan_standalone-${arch} ubsan.syms.extra)
|
|
|
|
add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx-${arch} ubsan.syms.extra)
|
|
|
|
add_dependencies(ubsan
|
|
|
|
clang_rt.ubsan_standalone-${arch}-symbols
|
|
|
|
clang_rt.ubsan_standalone_cxx-${arch}-symbols)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2012-10-10 03:34:32 +08:00
|
|
|
endif()
|
2014-02-18 17:33:45 +08:00
|
|
|
|
|
|
|
add_dependencies(compiler-rt ubsan)
|