https://github.com/gbMattN updated 
https://github.com/llvm/llvm-project/pull/169036

>From fe16327341c4e0b7e8e4cc5f1e9227e2d811bb33 Mon Sep 17 00:00:00 2001
From: gbMattN <[email protected]>
Date: Fri, 21 Nov 2025 13:28:03 +0000
Subject: [PATCH 1/2] [TySan] Make TySan compatible with UBSan

---
 clang/lib/Driver/SanitizerArgs.cpp                        | 2 +-
 compiler-rt/lib/tysan/CMakeLists.txt                      | 2 ++
 compiler-rt/test/ubsan/CMakeLists.txt                     | 7 +++++++
 compiler-rt/test/ubsan/TestCases/Misc/Posix/sigaction.cpp | 3 +++
 compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp | 3 ++-
 compiler-rt/test/ubsan/lit.common.cfg.py                  | 3 +++
 6 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 420c4cddbc8dd..dfcc516f358b5 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..bf0909455d0d8 100644
--- a/compiler-rt/lib/tysan/CMakeLists.txt
+++ b/compiler-rt/lib/tysan/CMakeLists.txt
@@ -72,7 +72,9 @@ else()
       OBJECT_LIBS RTInterception
                   RTSanitizerCommon
                   RTSanitizerCommonLibc
+                  RTSanitizerCommonCoverage
                   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 <assert.h>
 #include <signal.h>
 #include <stdio.h>
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)
 

>From a9531164fec602317d04acc070a82c19199d9995 Mon Sep 17 00:00:00 2001
From: gbMattN <[email protected]>
Date: Fri, 21 Nov 2025 13:40:27 +0000
Subject: [PATCH 2/2] Update docs and add apple support

---
 compiler-rt/lib/tysan/CMakeLists.txt | 4 +++-
 llvm/docs/ReleaseNotes.md            | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/tysan/CMakeLists.txt 
b/compiler-rt/lib/tysan/CMakeLists.txt
index bf0909455d0d8..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,8 @@ else()
       SOURCES ${TYSAN_SOURCES}
       OBJECT_LIBS RTInterception
                   RTSanitizerCommon
-                  RTSanitizerCommonLibc
                   RTSanitizerCommonCoverage
+                  RTSanitizerCommonLibc
                   RTSanitizerCommonSymbolizer
                   RTUbsan
       CFLAGS ${TYSAN_CFLAGS}
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 6f386b81476ac..310e08b98a6ac 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -217,6 +217,8 @@ Changes to BOLT
 Changes to Sanitizers
 ---------------------
 
+* Support running TypeSanitizer with UndefinedBehaviourSanitizer
+
 Other Changes
 -------------
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to