MDEV-17703 Add WITH_UBSAN switch to CMake similar to WITH_ASAN

This can be useful:
UBSAN_OPTIONS=log_path=/some/path

clang users may want to increase stack size in include/my_pthread.h or enable
some optimizations
This commit is contained in:
Eugene Kosov 2019-01-29 14:45:51 +03:00 committed by Sergey Vojtovich
commit 2a2ab121b0
3 changed files with 11 additions and 2 deletions

View file

@ -214,6 +214,15 @@ IF (WITH_ASAN)
ENDIF()
ENDIF()
OPTION(WITH_UBSAN "Enable undefined behavior sanitizer" OFF)
IF (WITH_UBSAN)
IF(SECURITY_HARDENED)
MESSAGE(FATAL_ERROR "WITH_UBSAN and SECURITY_HARDENED are mutually exclusive")
ENDIF()
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined" DEBUG RELWITHDEBINFO)
ENDIF()
# enable security hardening features, like most distributions do
# in our benchmarks that costs about ~1% of performance, depending on the load
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "4.6")