From 92a393166aa0e4e21afcf6604e285f437879127e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 14 Jun 2024 10:49:13 +0200 Subject: [PATCH] Add use_asan build option --- SConstruct | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SConstruct b/SConstruct index ada886be152..5a0e2bb77a8 100644 --- a/SConstruct +++ b/SConstruct @@ -78,6 +78,8 @@ opts.Add( ) ) +opts.Add(BoolVariable("use_asan", "Use address sanitizer (ASAN) in MSVC", False)) + # Add platform options tools = {} for pl in platforms: @@ -177,6 +179,12 @@ if env["platform"] == "macos": elif env["platform"] == "windows": env.AppendUnique(CPPDEFINES=["WINVER=0x0603", "_WIN32_WINNT=0x0603"]) +# Sanitizers. +if env.get("use_asan", False) and and env.get("is_msvc", False): + env["extra_suffix"] = "san" + env.Append(LINKFLAGS=["/INFERASANLIBS"]) + env.Append(CCFLAGS=["/fsanitize=address"]) + scons_cache_path = os.environ.get("SCONS_CACHE") if scons_cache_path is not None: