mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-28 18:38:48 +08:00
mdbx: поддержка ASAN (Address Sanitizer) при сборке посредством MSVC.
This commit is contained in:
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")
|
||||
|
@ -25654,7 +25654,10 @@ __dll_export
|
||||
};
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
LIBMDBX_API __attribute__((__weak__)) const char *__asan_default_options(void) {
|
||||
#if !defined(_MSC_VER) || __has_attribute(weak)
|
||||
LIBMDBX_API __attribute__((__weak__))
|
||||
#endif
|
||||
const char *__asan_default_options(void) {
|
||||
return "symbolize=1:allow_addr2line=1:"
|
||||
#if MDBX_DEBUG
|
||||
"debug=1:"
|
||||
|
@ -14,6 +14,12 @@
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
#endif /* MinGW */
|
||||
|
||||
/* Workaround for MSVC' header `extern "C"` vs `std::` redefinition bug */
|
||||
#if defined(_MSC_VER) && defined(__SANITIZE_ADDRESS__) && \
|
||||
!defined(_DISABLE_VECTOR_ANNOTATION)
|
||||
#define _DISABLE_VECTOR_ANNOTATION
|
||||
#endif /* _DISABLE_VECTOR_ANNOTATION */
|
||||
|
||||
#include "../mdbx.h++"
|
||||
|
||||
#include "internals.h"
|
||||
|
@ -30,6 +30,10 @@
|
||||
#define _WIN32_WINNT 0x0601 /* Windows 7 */
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
/* Workaround for MSVC' header `extern "C"` vs `std::` redefinition bug */
|
||||
#if defined(__SANITIZE_ADDRESS__) && !defined(_DISABLE_VECTOR_ANNOTATION)
|
||||
#define _DISABLE_VECTOR_ANNOTATION
|
||||
#endif /* _DISABLE_VECTOR_ANNOTATION */
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif /* _CRT_SECURE_NO_WARNINGS */
|
||||
|
Loading…
x
Reference in New Issue
Block a user