diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index d5a0b65ab758f..be068b2381d06 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -358,7 +358,7 @@ bool SanitizerArgs::needsFuzzerInterceptors() const { bool SanitizerArgs::needsUbsanRt() const { // All of these include ubsan. if (needsAsanRt() || needsMsanRt() || needsNsanRt() || needsHwasanRt() || - needsTsanRt() || needsDfsanRt() || needsLsanRt() || + needsTsanRt() || needsDfsanRt() || needsLsanRt() || needsTysanRt() || needsCfiCrossDsoDiagRt() || (needsScudoRt() && !requiresMinimalRuntime())) return false; diff --git a/compiler-rt/lib/tysan/CMakeLists.txt b/compiler-rt/lib/tysan/CMakeLists.txt index 7d13ae3963919..e7a6e71b86a0c 100644 --- a/compiler-rt/lib/tysan/CMakeLists.txt +++ b/compiler-rt/lib/tysan/CMakeLists.txt @@ -46,8 +46,10 @@ if(APPLE) OBJECT_LIBS RTTysan_dynamic RTInterception RTSanitizerCommon + RTSanitizerCommonCoverage RTSanitizerCommonLibc RTSanitizerCommonSymbolizer + RTUbsan CFLAGS ${TYSAN_DYNAMIC_CFLAGS} LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} DEFS ${TYSAN_DYNAMIC_DEFINITIONS} @@ -71,8 +73,10 @@ else() SOURCES ${TYSAN_SOURCES} OBJECT_LIBS RTInterception RTSanitizerCommon + RTSanitizerCommonCoverage RTSanitizerCommonLibc RTSanitizerCommonSymbolizer + RTUbsan CFLAGS ${TYSAN_CFLAGS} PARENT_TARGET tysan) endforeach() diff --git a/compiler-rt/test/ubsan/CMakeLists.txt b/compiler-rt/test/ubsan/CMakeLists.txt index 410585e6a07ef..f0b84f431472a 100644 --- a/compiler-rt/test/ubsan/CMakeLists.txt +++ b/compiler-rt/test/ubsan/CMakeLists.txt @@ -62,6 +62,9 @@ foreach(arch ${UBSAN_TEST_ARCH}) if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};" AND NOT ANDROID) add_ubsan_testsuites("ThreadSanitizer" tsan ${arch}) endif() + if(COMPILER_RT_HAS_TYSAN AND ";${TYSAN_SUPPORTED_ARCH};" MATCHES ";${arch};") + add_ubsan_testsuites("TypeSanitizer" tysan ${arch}) + endif() endforeach() macro(add_ubsan_device_testsuite test_mode sanitizer platform arch) @@ -124,6 +127,10 @@ if(APPLE) if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};") add_ubsan_device_testsuite("ThreadSanitizer" tsan ${platform} ${arch}) endif() + + if(COMPILER_RT_HAS_TYSAN AND ";${TYSAN_SUPPORTED_ARCH};" MATCHES ";${arch};") + add_ubsan_device_testsuite("TypeSanitizer" tysan ${platform} ${arch}) + endif() endforeach() endforeach() endif() diff --git a/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp index 0ab65bd30d92c..0b848ec8ac471 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp @@ -7,6 +7,9 @@ // Reason unknown, needs debugging. // UNSUPPORTED: target=aarch64{{.*}} && ubsan-tsan +// TySan doesn't build a shared library +// UNSUPPORTED: ubsan-tysan + #include #include #include diff --git a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp index c6133178262cc..fd019d2242552 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp @@ -19,8 +19,9 @@ // RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=edge,trace-pc-guard %s -o %t // RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir='"%t-dir"' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN -// Coverage is not yet implemented in TSan. +// Coverage is not yet implemented in TSan or TySan. // XFAIL: ubsan-tsan +// XFAIL: ubsan-tysan // UNSUPPORTED: ubsan-standalone-static // No coverage support // UNSUPPORTED: target={{.*openbsd.*}} diff --git a/compiler-rt/test/ubsan/lit.common.cfg.py b/compiler-rt/test/ubsan/lit.common.cfg.py index 25e527903788e..314d207f94ad5 100644 --- a/compiler-rt/test/ubsan/lit.common.cfg.py +++ b/compiler-rt/test/ubsan/lit.common.cfg.py @@ -39,6 +39,9 @@ def get_required_attr(config, attr_name): elif ubsan_lit_test_mode == "ThreadSanitizer": config.available_features.add("ubsan-tsan") clang_ubsan_cflags = ["-fsanitize=thread"] +elif ubsan_lit_test_mode == "TypeSanitizer": + config.available_features.add("ubsan-tysan") + clang_ubsan_cflags = ["-fsanitize=type"] else: lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode) diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md index 6203c01453d55..c6c527d1ae964 100644 --- a/llvm/docs/ReleaseNotes.md +++ b/llvm/docs/ReleaseNotes.md @@ -222,6 +222,7 @@ Changes to BOLT Changes to Sanitizers --------------------- +* Support running TypeSanitizer with UndefinedBehaviourSanitizer. * TypeSanitizer no longer inlines all instrumentation by default. Added the `-f[no-]sanitize-type-outline-instrumentation` flags to give users control over this behaviour.