mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Fix -DBUILD_CONFIG=mysql_release to keep standard cmake flags
-DCMAKE_BUILD_TYPE=xxx sets some C compiler flags according to the build type.
-DBUILD_CONFIG was completely overwriting them in some compiler / arch
combinations and not in others. Make it consistently "append-only", not
overwrite.
Also, enforce the same set of flags for Release and RelWithDebInfo.
This reverts ff1f611a0d
as it is no longer
necessary.
Avoid assert()
By default, CMAKE_BUILD_TYPE RelWithDebInfo or Release implies
-DNDEBUG, which disables the assert() macro. MariaDB is deviating
from that. Let us be explicit to use assert() only in debug builds.
This commit is contained in:
parent
ff1f611a0d
commit
43233fe469
2 changed files with 73 additions and 39 deletions
|
@ -187,30 +187,40 @@ IF(UNIX)
|
|||
# Default GCC flags
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMMON_C_FLAGS}")
|
||||
# MariaDB uses -O3 for release builds
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
ENDIF()
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMMON_CXX_FLAGS}")
|
||||
# MariaDB uses -O3 for release builds
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
ENDIF()
|
||||
|
||||
# IBM Z flags
|
||||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
|
||||
IF(RPM MATCHES "(rhel|centos)6" OR RPM MATCHES "(suse|sles)11")
|
||||
SET(z_flags "-funroll-loops -march=z9-109 -mtune=z10 ")
|
||||
SET(z_flags "-funroll-loops -march=z9-109 -mtune=z10")
|
||||
ELSEIF(RPM MATCHES "(rhel|centos)7" OR RPM MATCHES "(suse|sles)12")
|
||||
SET(z_flags "-funroll-loops -march=z196 -mtune=zEC12 ")
|
||||
SET(z_flags "-funroll-loops -march=z196 -mtune=zEC12")
|
||||
ELSE()
|
||||
SET(z_flags "")
|
||||
ENDIF()
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${z_flags}${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " ${z_flags}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${z_flags}")
|
||||
ENDIF()
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${z_flags}${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " ${z_flags}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${z_flags}")
|
||||
ENDIF()
|
||||
UNSET(z_flags)
|
||||
ENDIF()
|
||||
|
@ -221,11 +231,13 @@ IF(UNIX)
|
|||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
|
||||
SET(COMMON_C_FLAGS "+DSitanium2 -mt -AC99")
|
||||
SET(COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "+O0 -g ${COMMON_CXX_FLAGS}")
|
||||
# We have seen compiler bugs with optimisation and -g, so disabled for now
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_DEBUG " +O0 -g ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_DEBUG " +O0 -g ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " +O0 -g ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " +O0 -g ${COMMON_CXX_FLAGS}")
|
||||
# We have seen compiler bugs with optimisation and -g, so disabled for now
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " +O2 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " +O2 ${COMMON_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
SET(WITH_SSL no)
|
||||
|
@ -240,10 +252,18 @@ IF(UNIX)
|
|||
SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch")
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch")
|
||||
ENDIF()
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " -unroll2 -ip ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " -unroll2 -ip ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -unroll2 -ip ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -unroll2 -ip ${COMMON_CXX_FLAGS}")
|
||||
|
||||
# MariaDB uses -O3 for release builds.
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
SET(WITH_SSL no)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
@ -251,13 +271,21 @@ IF(UNIX)
|
|||
# Default Clang flags
|
||||
IF(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMMON_C_FLAGS}")
|
||||
# MariaDB uses -O3 for release builds.
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
ENDIF()
|
||||
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMMON_CXX_FLAGS}")
|
||||
# MariaDB uses -O3 for release builds.
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
STRING(REGEX REPLACE "-O2" "-O3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
ENDIF()
|
||||
|
||||
# Solaris flags
|
||||
|
@ -270,27 +298,33 @@ IF(UNIX)
|
|||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
|
||||
SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
|
||||
SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-xO1 ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-xO1 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_DEBUG " -xO1 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_DEBUG " -xO1 ${COMMON_CXX_FLAGS}")
|
||||
IF(32BIT)
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " -xO2 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " -xO2 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -xO2 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xO2 ${COMMON_CXX_FLAGS}")
|
||||
ELSEIF(64BIT)
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " -xO3 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " -xO3 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
ELSE()
|
||||
# Assume !x86 is SPARC
|
||||
SET(COMMON_C_FLAGS "-g -Xa -xstrconst -mt")
|
||||
SET(COMMON_CXX_FLAGS "-g0 -noex -mt")
|
||||
IF(32BIT)
|
||||
SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc")
|
||||
SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc")
|
||||
ENDIF()
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND COMMON_C_FLAGS " -xarch=sparc")
|
||||
STRING(APPEND COMMON_CXX_FLAGS " -xarch=sparc")
|
||||
ENDIF()
|
||||
STRING(APPEND CMAKE_C_FLAGS_DEBUG " ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " -xO3 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " -xO3 ${COMMON_CXX_FLAGS}")
|
||||
STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_C_FLAGS}")
|
||||
STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xO3 ${COMMON_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
|
|
@ -618,14 +618,14 @@ public:
|
|||
{
|
||||
ut_ad(!mutex_is_owner());
|
||||
mutex.wr_lock();
|
||||
ut_d(assert(!mutex_owner.exchange(pthread_self(),
|
||||
std::memory_order_relaxed)));
|
||||
assert(!mutex_owner.exchange(pthread_self(),
|
||||
std::memory_order_relaxed));
|
||||
}
|
||||
/** Release the mutex */
|
||||
void mutex_unlock()
|
||||
{
|
||||
ut_d(assert(mutex_owner.exchange(0, std::memory_order_relaxed) ==
|
||||
pthread_self()));
|
||||
assert(mutex_owner.exchange(0, std::memory_order_relaxed) ==
|
||||
pthread_self());
|
||||
mutex.wr_unlock();
|
||||
}
|
||||
#ifndef SUX_LOCK_GENERIC
|
||||
|
|
Loading…
Reference in a new issue