mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:24:14 +08:00
mdbx: поддержка ASAN (Address Sanitizer) при сборке посредством MSVC.
This commit is contained in:
parent
359489e271
commit
6d74b10db1
@ -348,6 +348,8 @@ endif()
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
check_compiler_flag("/WX" CC_HAS_WERROR)
|
check_compiler_flag("/WX" CC_HAS_WERROR)
|
||||||
|
check_compiler_flag("/fsanitize=address" CC_HAS_ASAN)
|
||||||
|
check_compiler_flag("/fsanitize=undefined" CC_HAS_UBSAN)
|
||||||
else()
|
else()
|
||||||
#
|
#
|
||||||
# GCC started to warn for unused result starting from 4.2, and
|
# GCC started to warn for unused result starting from 4.2, and
|
||||||
@ -839,19 +841,26 @@ macro(setup_compile_flags)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_ASAN)
|
if(ENABLE_ASAN)
|
||||||
|
if(NOT MSVC)
|
||||||
add_compile_flags("C;CXX" "-fsanitize=address")
|
add_compile_flags("C;CXX" "-fsanitize=address")
|
||||||
|
else()
|
||||||
|
add_compile_flags("C;CXX" "/fsanitize=address")
|
||||||
|
endif()
|
||||||
add_definitions(-DASAN_ENABLED=1)
|
add_definitions(-DASAN_ENABLED=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_UBSAN)
|
if(ENABLE_UBSAN)
|
||||||
|
if(NOT MSVC)
|
||||||
add_compile_flags("C;CXX" "-fsanitize=undefined" "-fsanitize-undefined-trap-on-error")
|
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)
|
add_definitions(-DUBSAN_ENABLED=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_GCOV)
|
if(ENABLE_GCOV)
|
||||||
if(NOT HAVE_GCOV)
|
if(NOT HAVE_GCOV)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR "ENABLE_GCOV option requested but gcov library is not found")
|
||||||
"ENABLE_GCOV option requested but gcov library is not found")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_flags("C;CXX" "-fprofile-arcs" "-ftest-coverage")
|
add_compile_flags("C;CXX" "-fprofile-arcs" "-ftest-coverage")
|
||||||
|
@ -25654,7 +25654,10 @@ __dll_export
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __SANITIZE_ADDRESS__
|
#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:"
|
return "symbolize=1:allow_addr2line=1:"
|
||||||
#if MDBX_DEBUG
|
#if MDBX_DEBUG
|
||||||
"debug=1:"
|
"debug=1:"
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
#define __USE_MINGW_ANSI_STDIO 1
|
#define __USE_MINGW_ANSI_STDIO 1
|
||||||
#endif /* MinGW */
|
#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 "../mdbx.h++"
|
||||||
|
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
#define _WIN32_WINNT 0x0601 /* Windows 7 */
|
#define _WIN32_WINNT 0x0601 /* Windows 7 */
|
||||||
#endif
|
#endif
|
||||||
#ifdef _MSC_VER
|
#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
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#endif /* _CRT_SECURE_NO_WARNINGS */
|
#endif /* _CRT_SECURE_NO_WARNINGS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user