diff options
author | Ray Molenkamp <github@lazydodo.com> | 2021-03-30 04:11:17 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2021-03-30 04:11:17 +0300 |
commit | f9eaf93d37957fb29eefb720022edd988c540369 (patch) | |
tree | 00c3913978394a63679b1b947793e6b8b3d7f500 /source | |
parent | 6c33d3d01b6237cbe854b1d6ca54ac9680bb0563 (diff) |
MSVC: ASAN support for VS 16.9
This enables ASAN support when used with VS 16.9
enable as usual in cmake with the WITH_COMPILER_ASAN
option, or when using make.bat just tag on `asan'
to the invocation, ie: `make lite 2019 asan`
MSVC: Asan support for 16.9
This enables ASAN support when used with VS 16.9
enable as usual in cmake with the WITH_COMPILER_ASAN
option, or when using make.bat just tag on `asan'
to the invocation, ie: `make lite 2019 asan`
Differential Revision: https://developer.blender.org/D7794
Reviewed By: brecht, sergey
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blendthumb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_asan.h | 2 | ||||
-rw-r--r-- | source/creator/CMakeLists.txt | 20 |
3 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/blendthumb/CMakeLists.txt b/source/blender/blendthumb/CMakeLists.txt index cb121cb9c8d..b42ca284ecb 100644 --- a/source/blender/blendthumb/CMakeLists.txt +++ b/source/blender/blendthumb/CMakeLists.txt @@ -31,6 +31,7 @@ set(SRC string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /nodefaultlib:MSVCRT.lib") add_library(BlendThumb SHARED ${SRC}) +setup_platform_linker_flags(BlendThumb) target_link_libraries(BlendThumb ${ZLIB_LIBRARIES}) install( diff --git a/source/blender/blenlib/BLI_asan.h b/source/blender/blenlib/BLI_asan.h index a2a44e164ab..c38ad6b39d0 100644 --- a/source/blender/blenlib/BLI_asan.h +++ b/source/blender/blenlib/BLI_asan.h @@ -21,7 +21,7 @@ # define __has_feature(x) 0 #endif -#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) +#if (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)) && !defined(_MSC_VER) # include "sanitizer/asan_interface.h" #else /* Ensure return value is used. Just using UNUSED_VARS results in a warning. */ diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index d9064682203..90840aa8358 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -693,6 +693,26 @@ elseif(WIN32) DESTINATION "." ) endif() + if(MSVC_ASAN) + # The asan dll's can be found in the same folder as the compiler, this is the easiest way to find these. + string(REPLACE "cl.exe" "clang_rt.asan_dynamic-x86_64.dll" ASAN_DLL ${CMAKE_C_COMPILER}) + string(REPLACE "cl.exe" "clang_rt.asan_dbg_dynamic-x86_64.dll" ASAN_DEBUG_DLL ${CMAKE_C_COMPILER}) + if(NOT EXISTS "${ASAN_DLL}") + message(FATAL_ERROR "Asan is enabled, but the ASAN runtime is not detected, this is an optional component during the MSVC install, please install it") + endif() + install( + FILES ${ASAN_DLL} + DESTINATION "." + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + install( + FILES ${ASAN_DEBUG_DLL} + DESTINATION "." + CONFIGURATIONS Debug + ) + unset(ASAN_DLL) + unset(ASAN_DEBUG_DLL) + endif() if(WITH_GMP) install( |