Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
031b3dfc
Commit
031b3dfc
authored
Mar 12, 2021
by
Vladislav Vaintroub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-25123 support MSVC ASAN
parent
4c2b6be3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
15 deletions
+29
-15
cmake/os/Windows.cmake
cmake/os/Windows.cmake
+22
-12
cmake/pcre.cmake
cmake/pcre.cmake
+2
-2
include/my_pthread.h
include/my_pthread.h
+4
-0
include/my_valgrind.h
include/my_valgrind.h
+1
-1
No files found.
cmake/os/Windows.cmake
View file @
031b3dfc
...
@@ -68,17 +68,12 @@ MACRO(ENABLE_SANITIZERS)
...
@@ -68,17 +68,12 @@ MACRO(ENABLE_SANITIZERS)
MESSAGE
(
FATAL_ERROR
"clang-cl or MSVC necessary to enable asan/ubsan"
)
MESSAGE
(
FATAL_ERROR
"clang-cl or MSVC necessary to enable asan/ubsan"
)
ENDIF
()
ENDIF
()
# currently, asan is broken with static CRT.
# currently, asan is broken with static CRT.
IF
(
NOT
(
MSVC_CRT_TYPE STREQUAL
"/MD"
))
IF
(
CLANG_CL AND
NOT
(
MSVC_CRT_TYPE STREQUAL
"/MD"
))
IF
(
NOT DYNAMIC_UCRT_LINK
)
SET
(
MSVC_CRT_TYPE
"/MD"
CACHE INTERNAL
""
FORCE
)
MESSAGE
(
FATAL_ERROR
"-DWITH_ASAN cmake parameter also requires -DMSVC_CRT_TYPE=/MD OR DYNAMIC_UCRT_LINK=ON"
)
ENDIF
()
ENDIF
()
ENDIF
()
IF
(
CMAKE_SIZEOF_VOID_P EQUAL 4
)
IF
(
CMAKE_SIZEOF_VOID_P EQUAL 4
)
SET
(
ASAN_ARCH i386
)
SET
(
ASAN_ARCH i386
)
ELSE
()
ELSE
()
IF
(
NOT CLANG_CL
)
MESSAGE
(
FATAL_ERROR
"sanitizers do not yet work on MSVC x64, try 32 bit or clang-cl"
)
ENDIF
()
SET
(
ASAN_ARCH x86_64
)
SET
(
ASAN_ARCH x86_64
)
ENDIF
()
ENDIF
()
...
@@ -88,8 +83,10 @@ MACRO(ENABLE_SANITIZERS)
...
@@ -88,8 +83,10 @@ MACRO(ENABLE_SANITIZERS)
SET
(
SANITIZER_LINK_LIBRARIES
)
SET
(
SANITIZER_LINK_LIBRARIES
)
SET
(
SANITIZER_COMPILE_FLAGS
)
SET
(
SANITIZER_COMPILE_FLAGS
)
IF
(
WITH_ASAN
)
IF
(
WITH_ASAN
)
LIST
(
APPEND SANITIZER_LIBS
IF
(
CLANG_CL
)
clang_rt.asan_dynamic-
${
ASAN_ARCH
}
.lib clang_rt.asan_dynamic_runtime_thunk-
${
ASAN_ARCH
}
.lib
)
LIST
(
APPEND SANITIZER_LIBS
clang_rt.asan_dynamic-
${
ASAN_ARCH
}
.lib clang_rt.asan_dynamic_runtime_thunk-
${
ASAN_ARCH
}
.lib
)
ENDIF
()
STRING
(
APPEND SANITIZER_COMPILE_FLAGS
" -fsanitize=address"
)
STRING
(
APPEND SANITIZER_COMPILE_FLAGS
" -fsanitize=address"
)
ENDIF
()
ENDIF
()
IF
(
WITH_UBSAN
)
IF
(
WITH_UBSAN
)
...
@@ -134,7 +131,13 @@ IF(MSVC)
...
@@ -134,7 +131,13 @@ IF(MSVC)
INCLUDE
(
InstallRequiredSystemLibraries
)
INCLUDE
(
InstallRequiredSystemLibraries
)
ENDIF
()
ENDIF
()
OPTION
(
DYNAMIC_UCRT_LINK
"Link Universal CRT dynamically, if MSVC_CRT_TYPE=/MT"
ON
)
IF
(
WITH_ASAN
AND
(
NOT CLANG_CL
))
SET
(
DYNAMIC_UCRT_LINK_DEFAULT OFF
)
ELSE
()
SET
(
DYNAMIC_UCRT_LINK_DEFAULT ON
)
ENDIF
()
OPTION
(
DYNAMIC_UCRT_LINK
"Link Universal CRT dynamically, if MSVC_CRT_TYPE=/MT"
${
DYNAMIC_UCRT_LINK_DEFAULT
}
)
SET
(
DYNAMIC_UCRT_LINKER_OPTION
" /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib"
)
SET
(
DYNAMIC_UCRT_LINKER_OPTION
" /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib"
)
# Enable debug info also in Release build,
# Enable debug info also in Release build,
...
@@ -191,8 +194,15 @@ IF(MSVC)
...
@@ -191,8 +194,15 @@ IF(MSVC)
FOREACH
(
type EXE SHARED MODULE
)
FOREACH
(
type EXE SHARED MODULE
)
STRING
(
REGEX REPLACE
"/STACK:([^ ]+)"
""
CMAKE_
${
type
}
_LINKER_FLAGS
"
${
CMAKE_
${
type
}
_LINKER_FLAGS
}
"
)
STRING
(
REGEX REPLACE
"/STACK:([^ ]+)"
""
CMAKE_
${
type
}
_LINKER_FLAGS
"
${
CMAKE_
${
type
}
_LINKER_FLAGS
}
"
)
STRING
(
REGEX REPLACE
"/INCREMENTAL:([^ ]+)"
"/INCREMENTAL:NO"
CMAKE_
${
type
}
_LINKER_FLAGS_RELWITHDEBINFO
"
${
CMAKE_
${
type
}
_LINKER_FLAGS_RELWITHDEBINFO
}
"
)
IF
(
WITH_ASAN
)
STRING
(
REGEX REPLACE
"/INCREMENTAL$"
"/INCREMENTAL:NO"
CMAKE_
${
type
}
_LINKER_FLAGS_RELWITHDEBINFO
"
${
CMAKE_
${
type
}
_LINKER_FLAGS_RELWITHDEBINFO
}
"
)
SET
(
build_types RELWITHDEBINFO DEBUG
)
ELSE
()
SET
(
build_types RELWITHDEBINFO
)
ENDIF
()
FOREACH
(
btype
${
build_types
}
)
STRING
(
REGEX REPLACE
"/INCREMENTAL:([^ ]+)"
"/INCREMENTAL:NO"
CMAKE_
${
type
}
_LINKER_FLAGS_
${
btype
}
"
${
CMAKE_
${
type
}
_LINKER_FLAGS_
${
btype
}}
"
)
STRING
(
REGEX REPLACE
"/INCREMENTAL$"
"/INCREMENTAL:NO"
CMAKE_
${
type
}
_LINKER_FLAGS_
${
btype
}
"
${
CMAKE_
${
type
}
_LINKER_FLAGS_
${
btype
}}
"
)
ENDFOREACH
()
IF
(
NOT CLANG_CL
)
IF
(
NOT CLANG_CL
)
STRING
(
APPEND CMAKE_
${
type
}
_LINKER_FLAGS_RELWITHDEBINFO
" /release /OPT:REF,ICF"
)
STRING
(
APPEND CMAKE_
${
type
}
_LINKER_FLAGS_RELWITHDEBINFO
" /release /OPT:REF,ICF"
)
ENDIF
()
ENDIF
()
...
...
cmake/pcre.cmake
View file @
031b3dfc
...
@@ -36,8 +36,8 @@ MACRO(BUNDLE_PCRE2)
...
@@ -36,8 +36,8 @@ MACRO(BUNDLE_PCRE2)
IF
(
MSVC
)
IF
(
MSVC
)
# Suppress a warning
# Suppress a warning
STRING
(
APPEND pcre2_flags
${
v
}
" /wd4244 "
)
STRING
(
APPEND pcre2_flags
${
v
}
" /wd4244 "
)
#
Need this only for ASAN
support
#
Disable asan
support
S
ET
(
stdlibs
"-DCMAKE_C_STANDARD_LIBRARIES=
${
CMAKE_C_STANDARD_LIBRARIES
}
"
)
S
TRING
(
REPLACE
"-fsanitize=address"
""
pcre2_flags
${
v
}
"
${
CMAKE_C_FLAGS
${
v
}
}
"
)
ENDIF
()
ENDIF
()
ENDFOREACH
()
ENDFOREACH
()
ExternalProject_Add
(
ExternalProject_Add
(
...
...
include/my_pthread.h
View file @
031b3dfc
...
@@ -667,7 +667,11 @@ extern void my_mutex_end(void);
...
@@ -667,7 +667,11 @@ extern void my_mutex_end(void);
with the current number of keys and key parts.
with the current number of keys and key parts.
*/
*/
#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
#ifndef DBUG_OFF
#define DEFAULT_THREAD_STACK (1024*1024L)
#else
#define DEFAULT_THREAD_STACK (383*1024L)
/* 392192 */
#define DEFAULT_THREAD_STACK (383*1024L)
/* 392192 */
#endif
#else
#else
#define DEFAULT_THREAD_STACK (292*1024L)
/* 299008 */
#define DEFAULT_THREAD_STACK (292*1024L)
/* 299008 */
#endif
#endif
...
...
include/my_valgrind.h
View file @
031b3dfc
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
# define MEM_GET_VBITS(a,b,len) VALGRIND_GET_VBITS(a,b,len)
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
# define MEM_SET_VBITS(a,b,len) VALGRIND_SET_VBITS(a,b,len)
# define REDZONE_SIZE 8
# define REDZONE_SIZE 8
#elif defined(__SANITIZE_ADDRESS__)
#elif defined(__SANITIZE_ADDRESS__)
&& (!defined(_MSC_VER) || defined (__clang__))
# include <sanitizer/asan_interface.h>
# include <sanitizer/asan_interface.h>
/* How to do manual poisoning:
/* How to do manual poisoning:
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment