104 lines
3.2 KiB
Diff
104 lines
3.2 KiB
Diff
Source: Debian, q66
|
|
|
|
This ensures arches that need libatomic properly get it where necessary.
|
|
It also removes the sync builtin checks that are not necessary when
|
|
using C11 atomics (like we always are because we're on a modern gcc)
|
|
that break build on e.g. ppc32 and mips.
|
|
|
|
--- configure.cmake
|
|
+++ configure.cmake
|
|
@@ -992,35 +992,19 @@ SET(SIGNAL_WITH_VIO_CLOSE 1)
|
|
|
|
MARK_AS_ADVANCED(NO_ALARM)
|
|
|
|
-
|
|
-IF(WITH_ATOMIC_OPS STREQUAL "up")
|
|
- SET(MY_ATOMIC_MODE_DUMMY 1 CACHE BOOL "Assume single-CPU mode, no concurrency")
|
|
-ELSEIF(WITH_ATOMIC_OPS STREQUAL "smp")
|
|
-ELSEIF(NOT WITH_ATOMIC_OPS)
|
|
- CHECK_CXX_SOURCE_COMPILES("
|
|
- int main()
|
|
- {
|
|
- int foo= -10; int bar= 10;
|
|
- long long int foo64= -10; long long int bar64= 10;
|
|
- if (!__sync_fetch_and_add(&foo, bar) || foo)
|
|
- return -1;
|
|
- bar= __sync_lock_test_and_set(&foo, bar);
|
|
- if (bar || foo != 10)
|
|
- return -1;
|
|
- bar= __sync_val_compare_and_swap(&bar, foo, 15);
|
|
- if (bar)
|
|
- return -1;
|
|
- if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
|
|
- return -1;
|
|
- bar64= __sync_lock_test_and_set(&foo64, bar64);
|
|
- if (bar64 || foo64 != 10)
|
|
- return -1;
|
|
- bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
|
|
- if (bar64)
|
|
- return -1;
|
|
- return 0;
|
|
- }"
|
|
- HAVE_GCC_ATOMIC_BUILTINS)
|
|
+CHECK_CXX_SOURCE_COMPILES("
|
|
+int main()
|
|
+{
|
|
+ long long int var= 1;
|
|
+ long long int *ptr= &var;
|
|
+ return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
|
+}"
|
|
+HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
|
|
+IF (HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
|
|
+ SET(HAVE_GCC_C11_ATOMICS True)
|
|
+ELSE()
|
|
+ SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
|
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
int main()
|
|
{
|
|
@@ -1028,14 +1012,13 @@ ELSEIF(NOT WITH_ATOMIC_OPS)
|
|
long long int *ptr= &var;
|
|
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
|
}"
|
|
- HAVE_GCC_C11_ATOMICS)
|
|
-ELSE()
|
|
- MESSAGE(FATAL_ERROR "${WITH_ATOMIC_OPS} is not a valid value for WITH_ATOMIC_OPS!")
|
|
+ HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
|
|
+ IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
|
|
+ SET(HAVE_GCC_C11_ATOMICS True)
|
|
+ ENDIF()
|
|
+ SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
|
|
ENDIF()
|
|
|
|
-SET(WITH_ATOMIC_OPS "${WITH_ATOMIC_OPS}" CACHE STRING "Implement atomic operations using atomic CPU instructions for multi-processor (smp) or uniprocessor (up) configuration. By default gcc built-in sync functions are used, if available and 'smp' configuration otherwise.")
|
|
-MARK_AS_ADVANCED(WITH_ATOMIC_OPS MY_ATOMIC_MODE_DUMMY)
|
|
-
|
|
IF(WITH_VALGRIND)
|
|
SET(HAVE_valgrind 1)
|
|
ENDIF()
|
|
--- mysys/CMakeLists.txt
|
|
+++ mysys/CMakeLists.txt
|
|
@@ -74,6 +74,10 @@ TARGET_LINK_LIBRARIES(mysys dbug strings mysys_ssl ${ZLIB_LIBRARY}
|
|
${LIBNSL} ${LIBM} ${LIBRT} ${LIBDL} ${LIBSOCKET} ${LIBEXECINFO})
|
|
DTRACE_INSTRUMENT(mysys)
|
|
|
|
+IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
|
|
+ TARGET_LINK_LIBRARIES(mysys atomic)
|
|
+ENDIF()
|
|
+
|
|
IF(HAVE_BFD_H)
|
|
TARGET_LINK_LIBRARIES(mysys bfd)
|
|
ENDIF(HAVE_BFD_H)
|
|
--- sql/CMakeLists.txt
|
|
+++ sql/CMakeLists.txt
|
|
@@ -172,6 +172,9 @@ ELSE()
|
|
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
|
|
ENDIF()
|
|
|
|
+IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
|
|
+ TARGET_LINK_LIBRARIES(sql atomic)
|
|
+ENDIF()
|
|
|
|
IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
|
|
|