summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2017-09-15 14:08:29 +0300
committerSergey Vojtovich <svoj@mariadb.org>2017-09-15 15:08:29 +0400
commit8d64da85701e397ad41a5ca735487866dcc75e11 (patch)
tree701c69644ac3491d0e6035d94cf51df2955d75c5 /CMakeLists.txt
parentc8cba4af553d863a937a168bd83ad302b64dae53 (diff)
downloadmariadb-git-8d64da85701e397ad41a5ca735487866dcc75e11.tar.gz
add TSAN option to cmake (#444)
* add TSAN option to cmake * disable security hardened build when TSAN is on * handling user-specified SECURITY_HARDEDED option
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt36
1 files changed, 23 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f0b08e2202..709ae826dc5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -204,20 +204,30 @@ IF (WITH_ASAN)
ENDIF()
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")
- SET(security_default OFF)
-ELSE()
- SET(security_default ON)
+OPTION(WITH_TSAN "Enable thread sanitizer" OFF)
+IF (WITH_TSAN)
+ IF(SECURITY_HARDENED)
+ MESSAGE(FATAL_ERROR "WITH_TSAN and SECURITY_HARDENED are mutually exclusive")
+ ENDIF()
+ MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=thread" DEBUG RELWITHDEBINFO)
ENDIF()
-OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ${security_default})
-IF(SECURITY_HARDENED)
- # security-enhancing flags
- MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
- MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now")
- MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4")
- MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO)
+
+IF(NOT WITH_TSAN)
+ # 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")
+ SET(security_default OFF)
+ ELSE()
+ SET(security_default ON)
+ ENDIF()
+ OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ${security_default})
+ IF(SECURITY_HARDENED)
+ # security-enhancing flags
+ MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
+ MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now")
+ MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4")
+ MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO)
+ ENDIF()
ENDIF()
# Always enable debug sync for debug builds.