From 7a0bf90dcf0b1df5af201a280680b240131f6955 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 25 Jun 2018 21:10:25 +0000 Subject: [PATCH] [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 --- compiler-rt/cmake/Modules/SanitizerUtils.cmake | 5 ++++- compiler-rt/test/ubsan_minimal/lit.common.cfg | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler-rt/cmake/Modules/SanitizerUtils.cmake b/compiler-rt/cmake/Modules/SanitizerUtils.cmake index c80fc3b1eefc..9d029337b306 100644 --- a/compiler-rt/cmake/Modules/SanitizerUtils.cmake +++ b/compiler-rt/cmake/Modules/SanitizerUtils.cmake @@ -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() diff --git a/compiler-rt/test/ubsan_minimal/lit.common.cfg b/compiler-rt/test/ubsan_minimal/lit.common.cfg index e8b42bb823c8..7630b617f347 100644 --- a/compiler-rt/test/ubsan_minimal/lit.common.cfg +++ b/compiler-rt/test/ubsan_minimal/lit.common.cfg @@ -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.