From d61034bda21643afe5921debbc6a19dbfe4c192f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 14 Jun 2024 10:48:56 +0200 Subject: [PATCH] Add use_asan build option --- SConstruct | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SConstruct b/SConstruct index f71f2cf..6f4a432 100644 --- a/SConstruct +++ b/SConstruct @@ -119,6 +119,7 @@ opts.Add("cxxflags", "Custom flags for the C++ compiler") opts.Add("cflags", "Custom flags for the C compiler") opts.Add("linkflags", "Custom flags for the linker") opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files.", "") +opts.Add(BoolVariable("use_asan", "Use address sanitizer (ASAN) in MSVC", False)) # Targets flags tool (optimizations, debug symbols) target_tool = Tool("targets", toolpath=["godot-tools"]) @@ -191,6 +192,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 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: