forked from OSchip/llvm-project
parent
05938a23f5
commit
ba869e79a0
|
@ -231,6 +231,8 @@ endif()
|
|||
# support only subset of these (e.g. TSan works on x86_64 only).
|
||||
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
|
||||
x86_64 i386 powerpc64 arm)
|
||||
filter_available_targets(UBSAN_SUPPORTED_ARCH
|
||||
x86_64 i386)
|
||||
|
||||
add_subdirectory(include)
|
||||
|
||||
|
|
|
@ -15,10 +15,7 @@ include_directories(..)
|
|||
|
||||
set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
||||
|
||||
filter_available_targets(UBSAN_SUPPORTED_ARCH
|
||||
x86_64 i386)
|
||||
|
||||
set(UBSAN_RUNTIME_LIBRARIES)
|
||||
add_custom_target(ubsan)
|
||||
|
||||
if(APPLE)
|
||||
# Build universal binary on APPLE.
|
||||
|
@ -27,7 +24,7 @@ if(APPLE)
|
|||
SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES}
|
||||
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
|
||||
CFLAGS ${UBSAN_CFLAGS})
|
||||
list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx)
|
||||
add_dependencies(ubsan clang_rt.ubsan_osx)
|
||||
else()
|
||||
# Build separate libraries for each target.
|
||||
foreach(arch ${UBSAN_SUPPORTED_ARCH})
|
||||
|
@ -39,20 +36,16 @@ else()
|
|||
add_compiler_rt_static_runtime(clang_rt.ubsan_cxx-${arch} ${arch}
|
||||
SOURCES ${UBSAN_CXX_SOURCES}
|
||||
CFLAGS ${UBSAN_CFLAGS})
|
||||
list(APPEND UBSAN_RUNTIME_LIBRARIES
|
||||
add_dependencies(ubsan
|
||||
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)
|
||||
list(APPEND UBSAN_RUNTIME_LIBRARIES
|
||||
add_dependencies(ubsan
|
||||
clang_rt.ubsan-${arch}-symbols
|
||||
clang_rt.ubsan_cxx-${arch}-symbols)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(UBSAN_SUPPORTED_ARCH)
|
||||
add_subdirectory(lit_tests)
|
||||
endif()
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UbsanConfig/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig/lit.site.cfg)
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg)
|
||||
|
||||
if(COMPILER_RT_CAN_EXECUTE_TESTS)
|
||||
# Run UBSan output tests only if we're sure that clang would produce
|
||||
# working binaries.
|
||||
set(UBSAN_TEST_DEPS
|
||||
${SANITIZER_COMMON_LIT_TEST_DEPS}
|
||||
${UBSAN_RUNTIME_LIBRARIES}
|
||||
asan_runtime_libraries)
|
||||
add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig
|
||||
${CMAKE_CURRENT_BINARY_DIR}/AsanConfig
|
||||
DEPENDS ${UBSAN_TEST_DEPS})
|
||||
set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan unittests")
|
||||
endif()
|
|
@ -5,3 +5,11 @@ configure_lit_site_cfg(
|
|||
# BlocksRuntime and builtins testsuites are not yet ported to lit.
|
||||
# add_subdirectory(BlocksRuntime)
|
||||
# add_subdirectory(builtins)
|
||||
|
||||
# Run sanitizer tests only if we're sure that clang would produce
|
||||
# working binaries.
|
||||
if(COMPILER_RT_CAN_EXECUTE_TESTS)
|
||||
if(UBSAN_SUPPORTED_ARCH)
|
||||
add_subdirectory(ubsan)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UbsanConfig/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig/lit.site.cfg)
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg)
|
||||
|
||||
set(UBSAN_TEST_DEPS
|
||||
${SANITIZER_COMMON_LIT_TEST_DEPS}
|
||||
ubsan
|
||||
asan_runtime_libraries)
|
||||
add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig
|
||||
${CMAKE_CURRENT_BINARY_DIR}/AsanConfig
|
||||
DEPENDS ${UBSAN_TEST_DEPS})
|
||||
set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan unittests")
|
Loading…
Reference in New Issue