summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-07-02 10:51:22 -0400
committerTavian Barnes <tavianator@tavianator.com>2025-07-04 08:22:18 -0400
commit19b4d6bb428a94359f0aca524867a8066afe8b5c (patch)
tree7103399545f281eec646bff379cfab786a499211
parent458c99ba19ccafb637f25bfb7f5a1de2dd84c6dc (diff)
downloadbfs-19b4d6bb428a94359f0aca524867a8066afe8b5c.tar.xz
build: Add support for TySan
There are some false positives, so it's not added to distcheck yet.
-rw-r--r--build/flags.mk9
-rwxr-xr-xconfigure6
-rw-r--r--src/bfs.h5
-rw-r--r--src/prelude.h3
4 files changed, 16 insertions, 7 deletions
diff --git a/build/flags.mk b/build/flags.mk
index 3748a8a..d6f9499 100644
--- a/build/flags.mk
+++ b/build/flags.mk
@@ -26,6 +26,7 @@ _ASAN := ${TRUTHY,${ASAN}}
_LSAN := ${TRUTHY,${LSAN}}
_MSAN := ${TRUTHY,${MSAN}}
_TSAN := ${TRUTHY,${TSAN}}
+_TYSAN := ${TRUTHY,${TYSAN}}
_UBSAN := ${TRUTHY,${UBSAN}}
_GCOV := ${TRUTHY,${GCOV}}
_LINT := ${TRUTHY,${LINT}}
@@ -38,21 +39,23 @@ ASAN_CFLAGS,y := -fsanitize=address
LSAN_CFLAGS,y := -fsanitize=leak
MSAN_CFLAGS,y := -fsanitize=memory -fsanitize-memory-track-origins
TSAN_CFLAGS,y := -fsanitize=thread
+TYSAN_CFLAGS,y := -fsanitize=type
UBSAN_CFLAGS,y := -fsanitize=undefined
_CFLAGS += ${ASAN_CFLAGS,${_ASAN}}
_CFLAGS += ${LSAN_CFLAGS,${_LSAN}}
_CFLAGS += ${MSAN_CFLAGS,${_MSAN}}
_CFLAGS += ${TSAN_CFLAGS,${_TSAN}}
+_CFLAGS += ${TYSAN_CFLAGS,${_TYSAN}}
_CFLAGS += ${UBSAN_CFLAGS,${_UBSAN}}
SAN_CFLAGS,y := -fno-sanitize-recover=all
-INSANE := ${NOT,${_ASAN}${_LSAN}${_MSAN}${_TSAN}${_UBSAN}}
+INSANE := ${NOT,${_ASAN}${_LSAN}${_MSAN}${_TSAN}${_TYSAN}${_UBSAN}}
SAN := ${NOT,${INSANE}}
_CFLAGS += ${SAN_CFLAGS,${SAN}}
-# MSAN and TSAN both need all code to be instrumented
-YESLIBS := ${NOT,${_MSAN}${_TSAN}}
+# MSan, TSan, and TySan need all code to be instrumented
+YESLIBS := ${NOT,${_MSAN}${_TSAN}${_TYSAN}}
NOLIBS ?= ${NOT,${YESLIBS}}
# gcov only intercepts fork()/exec() with -std=gnu*
diff --git a/configure b/configure
index 7f0bd04..51b543e 100755
--- a/configure
+++ b/configure
@@ -40,7 +40,7 @@ The default flags result in a plain debug build. Other build profiles include:
--enable-release
Enable optimizations, disable assertions
- --enable-{asan,lsan,msan,tsan,ubsan}
+ --enable-{asan,lsan,msan,tsan,tysan,ubsan}
Enable sanitizers
--enable-gcov
Enable code coverage instrumentation
@@ -164,7 +164,7 @@ for arg; do
--enable-*|--disable-*)
case "$name" in
- release|lto|asan|lsan|msan|tsan|ubsan|lint|gcov)
+ release|lto|asan|lsan|msan|tsan|tysan|ubsan|lint|gcov)
set -- "$@" "$NAME=$yn"
;;
*)
@@ -197,7 +197,7 @@ for arg; do
;;
# Warn about MAKE variables that have documented configure flags
- RELEASE=*|LTO=*|ASAN=*|LSAN=*|MSAN=*|TSAN=*|UBSAN=*|LINT=*|GCOV=*)
+ RELEASE=*|LTO=*|ASAN=*|LSAN=*|MSAN=*|TSAN=*|TYSAN=*|UBSAN=*|LINT=*|GCOV=*)
name=$(printf '%s' "$NAME" | tr 'A-Z_' 'a-z-')
warn '"%s" is deprecated; use --enable-%s' "$arg" "$name"
set -- "$@" "$arg"
diff --git a/src/bfs.h b/src/bfs.h
index 3cee727..70a7282 100644
--- a/src/bfs.h
+++ b/src/bfs.h
@@ -202,7 +202,10 @@ extern const char bfs_ldlibs[];
* Disabled on TSan due to https://github.com/google/sanitizers/issues/342.
*/
#ifndef BFS_USE_TARGET_CLONES
-# if __has_attribute(target_clones) && (__GLIBC__ || __FreeBSD__) && !__SANITIZE_THREAD__
+# if __has_attribute(target_clones) \
+ && (__GLIBC__ || __FreeBSD__) \
+ && !__SANITIZE_THREAD__ \
+ && !__SANITIZE_TYPE__
# define BFS_USE_TARGET_CLONES true
# else
# define BFS_USE_TARGET_CLONES false
diff --git a/src/prelude.h b/src/prelude.h
index de89a6c..3b1c4e5 100644
--- a/src/prelude.h
+++ b/src/prelude.h
@@ -126,5 +126,8 @@
#if __has_feature(thread_sanitizer) && !defined(__SANITIZE_THREAD__)
# define __SANITIZE_THREAD__ true
#endif
+#if __has_feature(type_sanitizer) && !defined(__SANITIZE_TYPE__)
+# define __SANITIZE_TYPE__ true
+#endif
#endif // BFS_PRELUDE_H