Skip to content

Commit f509a09

Browse files
committed
feat: Add support for AddressSanitizer runtime DLLs in MSVC build
1 parent 07e644d commit f509a09

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ cmake --list-presets # show all available presets
192192

193193
### Windows (Visual Studio)
194194

195+
> **Note:** The `dev-win` preset enables AddressSanitizer (ASan), which
196+
> requires the MSVC ASan runtime DLLs on `PATH`. Use **Visual Studio
197+
> Developer PowerShell** (or `VsDevCmd.bat`) to ensure they are available.
198+
> The `release-win` preset does not require this.
199+
195200
```powershell
196201
git submodule update --init --recursive
197202

cmake/MSVCGlobal.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>)
2020
if (VMPILOT_ENABLE_SANITIZERS)
2121
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/fsanitize=address>)
2222
add_link_options(/INCREMENTAL:NO)
23+
24+
# Copy MSVC ASan runtime DLLs to the output directory so tests can find
25+
# them without requiring a Developer Command Prompt or manual PATH setup.
26+
get_filename_component(_msvc_tool_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
27+
file(GLOB _asan_dlls "${_msvc_tool_dir}/clang_rt.asan*.dll")
28+
foreach(_dll IN LISTS _asan_dlls)
29+
file(COPY "${_dll}" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
30+
endforeach()
2331
endif()
2432

2533
# TODO: fix the underlying alignment issues and remove these suppressions.

0 commit comments

Comments
 (0)