[UBsan] Enable ubsan minimal unit tests on OpenBSD

OpenBSD needs lld linker for sanitisers.
Disabling lint checking as some symbols cannot be defined and block the proper unit tests launch.

Reviewers: lebedev.ri, vitalybuka

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D48528

llvm-svn: 335524
This commit is contained in:
David Carlier 2018-06-25 21:10:25 +00:00
parent 487bef376b
commit 7a0bf90dcf
2 changed files with 11 additions and 2 deletions

View File

@ -81,7 +81,7 @@ macro(add_sanitizer_rt_version_list name)
endmacro()
# Add target to check code style for sanitizer runtimes.
if(CMAKE_HOST_UNIX)
if(CMAKE_HOST_UNIX AND NOT OS_NAME MATCHES "OpenBSD")
add_custom_target(SanitizerLintCheck
COMMAND env LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR=
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
@ -90,5 +90,8 @@ if(CMAKE_HOST_UNIX)
DEPENDS ${SANITIZER_LINT_SCRIPT}
COMMENT "Running lint check for sanitizer sources..."
VERBATIM)
else()
add_custom_target(SanitizerLintCheck
COMMAND echo "No lint check")
endif()

View File

@ -22,6 +22,12 @@ target_cflags = [get_required_attr(config, "target_cflags")]
clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags
clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags
# OpenBSD needs lld linker to function
# TODO update the frontend driver
if config.host_os == 'OpenBSD':
clang_ubsan_cflags.append("-fuse-ld=lld")
clang_ubsan_cxxflags.append("-fuse-ld=lld")
# Define %clang and %clangxx substitutions to use in test RUN lines.
config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
@ -30,7 +36,7 @@ config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags
config.suffixes = ['.c', '.cc', '.cpp']
# Check that the host supports UndefinedBehaviorSanitizerMinimal tests
if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin']: # TODO: Windows
if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD']: # TODO: Windows
config.unsupported = True
# Don't target x86_64h if the test machine can't execute x86_64h binaries.