mirror of
https://github.com/isar/libmdbx.git
synced 2025-08-23 09:04:26 +08:00
mdbx: поддержка ASAN (Address Sanitizer) при сборке посредством MSVC.
This commit is contained in:
committed by
Леонид Юрьев (Leonid Yuriev)
parent
359489e271
commit
6d74b10db1
@@ -348,6 +348,8 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
check_compiler_flag("/WX" CC_HAS_WERROR)
|
||||
check_compiler_flag("/fsanitize=address" CC_HAS_ASAN)
|
||||
check_compiler_flag("/fsanitize=undefined" CC_HAS_UBSAN)
|
||||
else()
|
||||
#
|
||||
# GCC started to warn for unused result starting from 4.2, and
|
||||
@@ -839,19 +841,26 @@ macro(setup_compile_flags)
|
||||
endif()
|
||||
|
||||
if(ENABLE_ASAN)
|
||||
add_compile_flags("C;CXX" "-fsanitize=address")
|
||||
if(NOT MSVC)
|
||||
add_compile_flags("C;CXX" "-fsanitize=address")
|
||||
else()
|
||||
add_compile_flags("C;CXX" "/fsanitize=address")
|
||||
endif()
|
||||
add_definitions(-DASAN_ENABLED=1)
|
||||
endif()
|
||||
|
||||
if(ENABLE_UBSAN)
|
||||
add_compile_flags("C;CXX" "-fsanitize=undefined" "-fsanitize-undefined-trap-on-error")
|
||||
if(NOT MSVC)
|
||||
add_compile_flags("C;CXX" "-fsanitize=undefined" "-fsanitize-undefined-trap-on-error")
|
||||
else()
|
||||
add_compile_flags("C;CXX" "/fsanitize=undefined")
|
||||
endif()
|
||||
add_definitions(-DUBSAN_ENABLED=1)
|
||||
endif()
|
||||
|
||||
if(ENABLE_GCOV)
|
||||
if(NOT HAVE_GCOV)
|
||||
message(FATAL_ERROR
|
||||
"ENABLE_GCOV option requested but gcov library is not found")
|
||||
message(FATAL_ERROR "ENABLE_GCOV option requested but gcov library is not found")
|
||||
endif()
|
||||
|
||||
add_compile_flags("C;CXX" "-fprofile-arcs" "-ftest-coverage")
|
||||
|
Reference in New Issue
Block a user