Skip to content

Commit 4c98260

Browse files
committed
build Windows debug client/server with ASAN
This commit updates the `tests/CMakeLists.txt` configuration for building the client/server examples on Windows to enable address sanitizer (ASAN). We were already doing this for Linux and MacOS builds but were missing Windows coverage. Notably this requires a modern MSVC configured on the $PATH at runtime so that the ASAN DLLs are present. Otherwise the built binaries cryptically exit immediately with no output, just the exit status -1073741515. We use the setup-msvc-dev action in CI to do this for us. See the Microsoft documentation for more information: https://devblogs.microsoft.com/cppblog/addresssanitizer-asan-for-windows-with-msvc/#compiling-with-asan-from-the-console
1 parent c8612fd commit 4c98260

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/test.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ jobs:
111111
persist-credentials: false
112112
- name: Install nightly rust toolchain
113113
uses: dtolnay/rust-toolchain@nightly
114+
# For Debug builds we use ASAN, which requires a modern MSVC on $PATH
115+
# to provide the ASAN clang_rt.asan_*.dll runtime deps or
116+
# the built client/server binary will exit immediately with
117+
# exit code -1073741515
118+
- name: Setup MSVC
119+
uses: TheMrMilchmann/setup-msvc-dev@v3
120+
with:
121+
arch: x64
114122
- name: Configure CMake
115123
run: cmake -DCRYPTO_PROVIDER="${{ matrix.crypto }}" -S . -B build
116124
- name: Build, debug configuration

tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ elseif (CRYPTO_PROVIDER STREQUAL "ring")
1313
add_compile_definitions(DEFINE_RING)
1414
endif ()
1515

16+
# Set ASAN sanitizer flags conditionally for Debug builds
17+
set(sanitizer_flags "$<$<CONFIG:Debug>:-fsanitize=address>")
18+
add_compile_options(${sanitizer_flags})
19+
1620
add_executable(client client.c common.c)
1721
add_dependencies(client rustls-ffi)
1822
target_include_directories(client PUBLIC ${CMAKE_SOURCE_DIR}/src)

0 commit comments

Comments
 (0)