Skip to content

Commit

Permalink
Fixed & enabled ASan
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWanderer committed Mar 26, 2024
1 parent 98abd88 commit 08b1e66
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
conf: [release, debug]
conf: [release, debug, asan]
arch: [x64]
exclude:
- os: ubuntu
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
conf: [debug]
conf: [debug, asan]
arch: [x64]
uses: ./.github/workflows/build.yml
with:
Expand Down
4 changes: 4 additions & 0 deletions ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ endif()
set(BOOST_INCLUDE_LIBRARIES asio accumulators beast json url)
set(BOOST_USE_STATIC_LIBS ON)
set(BOOST_ENABLE_CMAKE ON)
if (METRICS_BUILD_SANITIZER)
set(BOOST_USE_ASAN ON)
endif()

message(STATUS "Downloading and extracting boost library sources. This will take some time...")
set(FETCHCONTENT_QUIET FALSE) # Needed to print downloading progress
FetchContent_Declare(
Expand Down
1 change: 0 additions & 1 deletion sanitizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function(enable_sanitizer SANITIZER)
)

add_custom_target(CopyAsanBinaries ALL DEPENDS ${ASAN_LIBRARY_NAME} ${LLVM_SYMBOLIZER_NAME})
add_compile_options(/fsanitize=${SANITIZER} /Zi /Oy-)
else()
message(FATAL_ERROR "MSVC does not support sanitizer ${SANITIZER}")
endif()
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ target_link_libraries(metrics PRIVATE Boost::asio Boost::accumulators Boost::bea
generate_export_header(metrics)
add_library(METRICS::lib ALIAS metrics)

if (METRICS_BUILD_SANITIZER)
add_compile_options(metrics PUBLIC /fsanitize=${METRICS_BUILD_SANITIZER} /Zi /Oy-)
endif()

# Data to properly create install package
set_target_properties(metrics PROPERTIES PUBLIC_HEADER "${METRICS_HEADER_FILES}")
install(TARGETS metrics PUBLIC_HEADER)

0 comments on commit 08b1e66

Please sign in to comment.