From 3e173880a7a8e6507080298d6fc20b719b6a2acb Mon Sep 17 00:00:00 2001 From: doyle Date: Mon, 9 Aug 2021 12:50:46 +1000 Subject: [PATCH] build: Turn on asan --- build.bat | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/build.bat b/build.bat index d970fbe..4fbf042 100644 --- a/build.bat +++ b/build.bat @@ -4,6 +4,9 @@ set code_dir=%~dp0 if not exist Build mkdir Build pushd Build + REM ------------------------------------------------------------------------ + REM Flags + REM ------------------------------------------------------------------------ REM MT Static CRT REM EHa- Disable exception handling REM GR- Disable C RTTI @@ -12,17 +15,33 @@ pushd Build REM Z7 Combine multi-debug files to one debug file REM wd4201 Nonstandard extension used: nameless struct/union REM Tp Treat header file as CPP source file + set flags=-MT -EHa -GR- -Od -Oi -Z7 -wd4201 -D DQN_TEST_WITH_MAIN %code_dir%Dqn_Tests.cpp -link -nologo + set msvc_flags=-fsanitize=address -D STBSP__ASAN=__declspec(no_sanitize_address) + set clang_flags=-fsanitize=address + + REM ------------------------------------------------------------------------ + REM Compiler: MSVC cl + REM ------------------------------------------------------------------------ + where /q cl || ( + echo [ERROR] cl is not found, please put MSVC's cl on the path + exit /b 1 + ) if not exist msvc mkdir msvc - if not exist clang mkdir clang - - set flags=/MT /EHa /GR- /Od /Oi /Z7 /wd4201 /D DQN_TEST_WITH_MAIN %code_dir%Dqn_Tests.cpp /link /nologo - pushd msvc - cl %flags% + cl %msvc_flags% %flags% popd + REM ------------------------------------------------------------------------ + REM Compiler: clang-cl + REM ------------------------------------------------------------------------ + where /q clang-cl || ( + echo [WARN] Optional clang compile via clang-cl if it's in the path, please put clang-cl on the path for this feature + exit /b 0 + ) + + if not exist clang mkdir clang pushd clang - clang-cl %flags% + clang-cl %clang_flags% %flags% popd popd