Skip to content

Commit

Permalink
build Windows debug client/server with ASAN
Browse files Browse the repository at this point in the history
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
cpu committed Oct 29, 2024
1 parent c8612fd commit 4c98260
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -111,6 +111,14 @@ jobs:
persist-credentials: false
- name: Install nightly rust toolchain
uses: dtolnay/rust-toolchain@nightly
# For Debug builds we use ASAN, which requires a modern MSVC on $PATH
# to provide the ASAN clang_rt.asan_*.dll runtime deps or
# the built client/server binary will exit immediately with
# exit code -1073741515
- name: Setup MSVC
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Configure CMake
run: cmake -DCRYPTO_PROVIDER="${{ matrix.crypto }}" -S . -B build
- name: Build, debug configuration
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ elseif (CRYPTO_PROVIDER STREQUAL "ring")
add_compile_definitions(DEFINE_RING)
endif ()

# Set ASAN sanitizer flags conditionally for Debug builds
set(sanitizer_flags "$<$<CONFIG:Debug>:-fsanitize=address>")
add_compile_options(${sanitizer_flags})

add_executable(client client.c common.c)
add_dependencies(client rustls-ffi)
target_include_directories(client PUBLIC ${CMAKE_SOURCE_DIR}/src)

0 comments on commit 4c98260

Please sign in to comment.