MDEV-34996 Buildbot MSAN options should be in server

All the options that where in buildbot, should
be in the server making it accessible to all
without any special invocation.

If WITH_MSAN=ON, we want to make sure that the
compiler options are supported and it will result
in an error if not supported.

We make the -WITH_MSAN=ON append -stdlib=libc++
to the CXX_FLAGS if supported.

With SECURITY_HARDENING options the bootstrap
currently crashes, so for now, we disable SECRUITY_HARDENING
if there is MSAN enable.

Option WITH_DBUG_TRACE has no effect in MSAN builds.
This commit is contained in:
Daniel Black
2024-09-24 17:47:34 +10:00
parent ad5b9c207c
commit 42eb64e64d

View File

@ -244,6 +244,19 @@ ENDIF()
OPTION(WITH_MSAN "Enable memory sanitizer" OFF)
IF (WITH_MSAN)
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO)
IF(NOT (have_C__fsanitize_memory__fsanitize_memory_track_origins__U_FORTIFY_SOURCE
AND have_CXX__fsanitize_memory__fsanitize_memory_track_origins__U_FORTIFY_SOURCE))
MESSAGE(FATAL_ERROR "Compiler doesn't support -fsanitize=memory flags")
ENDIF()
MY_CHECK_CXX_COMPILER_FLAG("-stdlib=libc++")
IF(NOT have_CXX__stdlib_libc__)
MESSAGE(FATAL_ERROR "C++ Compiler requires support for -stdlib=libc++")
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
MY_CHECK_AND_SET_LINKER_FLAG("-fsanitize=memory" DEBUG RELWITHDEBINFO)
IF(NOT HAVE_LINK_FLAG__fsanitize_memory)
MESSAGE(FATAL_ERROR "Linker doesn't support -fsanitize=memory flags")
ENDIF()
ENDIF()
OPTION(WITH_GPROF "Enable profiling with gprof" OFF)
@ -257,7 +270,7 @@ MY_CHECK_AND_SET_COMPILER_FLAG("-fno-omit-frame-pointer" RELWITHDEBINFO)
# enable security hardening features, like most distributions do
# in our benchmarks that costs about ~1% of performance, depending on the load
OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ON)
IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN AND NOT WITH_GPROF)
IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN AND NOT WITH_GPROF AND NOT WITH_MSAN)
# security-enhancing flags
MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
MY_CHECK_AND_SET_LINKER_FLAG("-Wl,-z,relro,-z,now")