diff --git a/SConstruct b/SConstruct index ada886be1..5a0e2bb77 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: