提交 fb8f1534 编写于 作者: M Megvii Engine Team 提交者: huangxinda

fix(cmake/debug): fix asan do not work at windows env

GitOrigin-RevId: 6638194fd724f9d3455d2587080142479683cdb1
上级 40085acb
......@@ -211,6 +211,11 @@ if(MSVC OR WIN32)
# on windows need append VS_PATH/VC/Tools/Llvm/x64/lib/clang/${CMAKE_CXX_COMPILER_VERSION}/lib/windows
# and VS_PATH/VC/Tools/Llvm/lib/clang/${CMAKE_CXX_COMPILER_VERSION}/lib/windows to PATH env
if (MGE_BUILD_WITH_ASAN)
message(WARNING "please do (set)export ASAN_OPTIONS=windows_hook_rtl_allocators=true when run test after build finish, caused by we link asan dll!!")
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
message(WARNING "Windows AddressSanitizer doesn't support linking with debug runtime libraries yet, which means do not support CMAKE_BUILD_TYPE=Debug")
message(FATAL_ERROR "Please build with RelWithDebInfo or Release by : EXTRA_CMAKE_ARGS=\"-DMGE_BUILD_WITH_ASAN=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ...\"")
endif()
if("$ENV{VS_PATH}" STREQUAL "")
message(FATAL_ERROR "can not find VS_PATH, please export Visual Studio root dir to VS_PATH env")
endif()
......@@ -239,6 +244,12 @@ if(MSVC OR WIN32)
link_libraries(${WINDOWS_ASAN_DLL_NAME})
link_libraries(${WINDOWS_ASAN_RUNTIME_THUNK_NAME})
set(WIN_FLAGS "/Od -DNDEBUG -fsanitize=address")
# windows Llvm asan do not take effect when /O2
# RELWITHDEBINFO default value is /O2, so override it
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Zi /Od /Ob1 /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi /Od /Ob1 /DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "/Zi /Od /Ob1 /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "/Zi /Od /Ob1 /DNDEBUG")
else()
set(WIN_FLAGS "/O2")
endif()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册