aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2023-10-07 15:07:45 +0200
committerdundargoc <33953936+dundargoc@users.noreply.github.com>2023-11-05 21:39:12 +0100
commit397b92e02dbe7996a9da14aac73003fc8ddd1674 (patch)
tree542d6698545b8ba855bfec3f650eba152a19629d /src
parentacc646ad8fc3ef11fcc63b69f3d8484e4a91accd (diff)
downloadrneovim-397b92e02dbe7996a9da14aac73003fc8ddd1674.tar.gz
rneovim-397b92e02dbe7996a9da14aac73003fc8ddd1674.tar.bz2
rneovim-397b92e02dbe7996a9da14aac73003fc8ddd1674.zip
build: enable ASAN for MSVC
It is enabled with ENABLE_ASAN_UBSAN like other compilers. Technically it only enables ASAN as UBSAN is not available, meaning to make the variable names fully correct we'd need to separate it into two checks: ENABLE_ASAN and ENABLE_UBSAN, but the convenience of combining them into the same flag outweighs the theoretical correctness. Also note in CONTRIBUTING.md that debug builds in ASAN is not supported. Technically it is the debug runtime that is not supported, which cmake automatically enables when using the debug build type. However, neovim can't be built with debug builds without linking to the debug runtime since the third party libraries has likely been linked to the debug runtime if it was built with debug build type. This technicality is likely uninteresting to the potential developer and it's easier to just say to use a release build type.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/CMakeLists.txt23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 71e99538c7..e881214f40 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -764,17 +764,20 @@ target_link_libraries(libnvim PRIVATE main_lib PUBLIC libuv)
if(ENABLE_ASAN_UBSAN)
message(STATUS "Enabling address sanitizer and undefined behavior sanitizer for nvim.")
- if(CI_BUILD)
- # Try to recover from all sanitize issues so we get reports about all failures
- target_compile_options(nvim PRIVATE -fsanitize-recover=all)
- else()
- target_compile_options(nvim PRIVATE -fno-sanitize-recover=all)
+ if(NOT MSVC)
+ if(CI_BUILD)
+ # Try to recover from all sanitize issues so we get reports about all failures
+ target_compile_options(nvim PRIVATE -fsanitize-recover=all)
+ else()
+ target_compile_options(nvim PRIVATE -fno-sanitize-recover=all)
+ endif()
+ target_compile_options(nvim PRIVATE
+ -fno-omit-frame-pointer
+ -fno-optimize-sibling-calls
+ -fsanitize=undefined)
endif()
- target_compile_options(nvim PRIVATE
- -fno-omit-frame-pointer
- -fno-optimize-sibling-calls
- -fsanitize=address
- -fsanitize=undefined)
+
+ target_compile_options(nvim PRIVATE -fsanitize=address)
target_link_libraries(nvim PRIVATE -fsanitize=address -fsanitize=undefined)
target_compile_definitions(nvim PRIVATE ENABLE_ASAN_UBSAN)
elseif(ENABLE_MSAN)