aboutsummaryrefslogtreecommitdiff
path: root/src/zencore
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-17 13:56:50 +0100
committerGitHub Enterprise <[email protected]>2026-03-17 13:56:50 +0100
commit90ca5315b2745fde3ccf9ce9d7106537cae566c8 (patch)
tree4f44464225dc8c8e8386f428b31697971e0f0a2f /src/zencore
parentrevise oplog block arrangement (#842) (diff)
downloadzen-90ca5315b2745fde3ccf9ce9d7106537cae566c8.tar.xz
zen-90ca5315b2745fde3ccf9ce9d7106537cae566c8.zip
add sanitizer options to xmake (#847)v5.7.23-pre1v5.7.23-pre0
- Improvement: Add easy access options for sanitizers with `xmake config` and `xmake test` as options - `--msan=[y|n]` Enable MemorySanitizer (Linux only, requires all deps instrumented) - `--asan=[y|n]` Enable AddressSanitizer (disables mimalloc and sentry) - `--tsan=[y|n]` Enable ThreadSanitizer (Linux/Mac only)
Diffstat (limited to 'src/zencore')
-rw-r--r--src/zencore/include/zencore/memory/fmalloc.h11
-rw-r--r--src/zencore/xmake.lua4
2 files changed, 11 insertions, 4 deletions
diff --git a/src/zencore/include/zencore/memory/fmalloc.h b/src/zencore/include/zencore/memory/fmalloc.h
index 0c183cfd0..c50a9729c 100644
--- a/src/zencore/include/zencore/memory/fmalloc.h
+++ b/src/zencore/include/zencore/memory/fmalloc.h
@@ -9,6 +9,7 @@
// Detect if any sanitizers are enabled.
#if defined(__has_feature)
+// Clang: query each sanitizer individually
# if __has_feature(address_sanitizer)
# define ZEN_ADDRESS_SANITIZER 1
# endif
@@ -21,8 +22,14 @@
# if __has_feature(leak_sanitizer)
# define ZEN_LEAK_SANITIZER 1
# endif
-#elif defined(__SANITIZE_ADDRESS__) // For Windows
-# define ZEN_ADDRESS_SANITIZER 1
+#else
+// MSVC and GCC: check predefined macros set by the compiler when sanitizers are active
+# if defined(__SANITIZE_ADDRESS__) // MSVC (ASAN only), GCC
+# define ZEN_ADDRESS_SANITIZER 1
+# endif
+# if defined(__SANITIZE_THREAD__) // GCC
+# define ZEN_THREAD_SANITIZER 1
+# endif
#endif
#if !defined(ZEN_ADDRESS_SANITIZER)
diff --git a/src/zencore/xmake.lua b/src/zencore/xmake.lua
index 171f4c533..b08975df1 100644
--- a/src/zencore/xmake.lua
+++ b/src/zencore/xmake.lua
@@ -21,7 +21,7 @@ target('zencore')
add_deps("rpmalloc")
end
- if has_config("zenmimalloc") then
+ if has_config("zenmimalloc") and not use_asan then
add_packages("mimalloc")
end
@@ -47,7 +47,7 @@ target('zencore')
{public=true}
)
- if has_config("zensentry") then
+ if has_config("zensentry") and not use_asan then
add_packages("sentry-native")
if is_os("windows") then