diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ec1c59b50..e2d5ba585e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,12 +144,6 @@ if((ENABLE_ASAN_UBSAN AND ENABLE_MSAN) message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously") endif() -if(ENABLE_ASAN_UBSAN OR ENABLE_MSAN OR ENABLE_TSAN) - if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_ID MATCHES "GNU") - message(FATAL_ERROR "Sanitizers are only supported for Clang and GCC") - endif() -endif() - # Place targets in bin/ or lib/ for all build configurations set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c73c205183..f574953b28 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -124,7 +124,8 @@ Each pull request must pass the automated builds on [Cirrus CI] and [GitHub Acti - If any tests fail, the build will fail. See [test/README.md#running-tests][run-tests] to run tests locally. - CI runs [ASan] and other analyzers. - To run valgrind locally: `VALGRIND=1 make test` - - To run Clang ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DENABLE_ASAN_UBSAN=ON"` + - To run ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DENABLE_ASAN_UBSAN=ON"`. + Note that MSVC requires Release or RelWithDebInfo build type to work properly. - The [lint](#lint) build checks modified lines _and their immediate neighbors_, to encourage incrementally updating the legacy style to meet our [style](#style). (See [#3174][3174] for background.) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 75c9821a2c..fabf3de447 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -811,17 +811,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) elseif(ENABLE_MSAN) message(STATUS "Enabling memory sanitizer for nvim.")