Commit 2a2ab121 authored by Eugene Kosov's avatar Eugene Kosov Committed by Sergey Vojtovich

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
parent 04150218
......@@ -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")
......
......@@ -35,7 +35,7 @@ ENDFOREACH()
# Ensure we have clean build for shared libraries
# without unresolved symbols
# Not supported with AddressSanitizer
IF(NOT WITH_ASAN)
IF(NOT WITH_ASAN AND NOT WITH_UBSAN)
SET(LINK_FLAG_NO_UNDEFINED "-Wl,--no-undefined")
ENDIF()
......
......@@ -209,7 +209,7 @@ MACRO(MYSQL_ADD_PLUGIN)
ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
TARGET_LINK_LIBRARIES (${target} mysqld)
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN AND NOT WITH_UBSAN)
TARGET_LINK_LIBRARIES (${target} "-Wl,--no-undefined")
ENDIF()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment