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
|
2015-07-09 06:10:34 +08:00
|
|
|
ubsan_type_hash_itanium.cc
|
|
|
|
ubsan_type_hash_win.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)
|
2016-01-28 05:15:10 +08:00
|
|
|
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CFLAGS)
|
|
|
|
|
2015-04-02 06:42:36 +08:00
|
|
|
set(UBSAN_STANDALONE_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
|
|
|
append_no_rtti_flag(UBSAN_STANDALONE_CFLAGS)
|
2016-01-28 05:15:10 +08:00
|
|
|
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_STANDALONE_CFLAGS)
|
|
|
|
|
2014-07-30 05:52:25 +08:00
|
|
|
set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS})
|
2016-01-28 05:15:10 +08:00
|
|
|
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CXXFLAGS)
|
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-25 08:57:42 +08:00
|
|
|
set(UBSAN_COMMON_SOURCES ${UBSAN_SOURCES})
|
|
|
|
if(SANITIZER_CAN_USE_CXXABI)
|
|
|
|
list(APPEND UBSAN_COMMON_SOURCES ${UBSAN_CXX_SOURCES})
|
|
|
|
endif()
|
|
|
|
|
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-25 08:57:42 +08:00
|
|
|
SOURCES ${UBSAN_COMMON_SOURCES}
|
2015-06-11 07:55:07 +08:00
|
|
|
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})
|
2015-08-27 06:36:31 +08:00
|
|
|
|
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan
|
|
|
|
SHARED
|
|
|
|
OS ${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${UBSAN_SUPPORTED_ARCH}
|
|
|
|
OBJECT_LIBS RTUbsan
|
|
|
|
RTUbsan_standalone
|
|
|
|
RTSanitizerCommon
|
2015-08-28 06:23:27 +08:00
|
|
|
RTSanitizerCommonLibc
|
2015-08-27 06:36:31 +08:00
|
|
|
PARENT_TARGET ubsan)
|
2015-06-11 07:55:07 +08:00
|
|
|
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-08-27 06:36:31 +08:00
|
|
|
# Standalone UBSan runtimes.
|
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan_standalone
|
|
|
|
STATIC
|
|
|
|
ARCHS ${UBSAN_SUPPORTED_ARCH}
|
|
|
|
OBJECT_LIBS RTSanitizerCommon
|
|
|
|
RTSanitizerCommonLibc
|
|
|
|
RTUbsan
|
|
|
|
RTUbsan_standalone
|
|
|
|
CFLAGS ${UBSAN_CFLAGS}
|
|
|
|
PARENT_TARGET ubsan)
|
|
|
|
|
|
|
|
add_compiler_rt_runtime(clang_rt.ubsan_standalone_cxx
|
|
|
|
STATIC
|
|
|
|
ARCHS ${UBSAN_SUPPORTED_ARCH}
|
|
|
|
OBJECT_LIBS RTUbsan_cxx
|
|
|
|
CFLAGS ${UBSAN_CXXFLAGS}
|
|
|
|
PARENT_TARGET ubsan)
|
2015-03-24 04:05:53 +08:00
|
|
|
|
2015-08-28 04:07:54 +08:00
|
|
|
if (UNIX)
|
|
|
|
set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH})
|
|
|
|
list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686)
|
|
|
|
add_sanitizer_rt_symbols(clang_rt.ubsan_standalone
|
|
|
|
ARCHS ${ARCHS_FOR_SYMBOLS}
|
|
|
|
PARENT_TARGET ubsan
|
|
|
|
EXTRA ubsan.syms.extra)
|
|
|
|
add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx
|
|
|
|
ARCHS ${ARCHS_FOR_SYMBOLS}
|
|
|
|
PARENT_TARGET ubsan
|
|
|
|
EXTRA ubsan.syms.extra)
|
|
|
|
endif()
|
2015-04-02 07:00:02 +08:00
|
|
|
endif()
|
2012-10-10 03:34:32 +08:00
|
|
|
endif()
|
2014-02-18 17:33:45 +08:00
|
|
|
|
|
|
|
add_dependencies(compiler-rt ubsan)
|