You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.8 KiB

  1. Author: Vicențiu Ciorbaru <vicentiu@mariadb.org>
  2. Date: Fri Dec 21 19:14:04 2018 +0200
  3. Link with libatomic to enable C11 atomics support
  4. Some architectures (mips) require libatomic to support proper
  5. atomic operations. Check first if support is available without
  6. linking, otherwise use the library.
  7. --- a/configure.cmake
  8. +++ b/configure.cmake
  9. @@ -866,7 +866,25 @@ int main()
  10. long long int *ptr= &var;
  11. return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
  12. }"
  13. -HAVE_GCC_C11_ATOMICS)
  14. +HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
  15. +IF (HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
  16. + SET(HAVE_GCC_C11_ATOMICS True)
  17. +ELSE()
  18. + SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  19. + LIST(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
  20. + CHECK_CXX_SOURCE_COMPILES("
  21. + int main()
  22. + {
  23. + long long int var= 1;
  24. + long long int *ptr= &var;
  25. + return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
  26. + }"
  27. + HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
  28. + IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
  29. + SET(HAVE_GCC_C11_ATOMICS True)
  30. + ENDIF()
  31. + SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
  32. +ENDIF()
  33. IF(WITH_VALGRIND)
  34. SET(HAVE_valgrind 1)
  35. --- a/mysys/CMakeLists.txt
  36. +++ b/mysys/CMakeLists.txt
  37. @@ -79,6 +79,10 @@ TARGET_LINK_LIBRARIES(mysys dbug strings
  38. ${LIBNSL} ${LIBM} ${LIBRT} ${LIBDL} ${LIBSOCKET} ${LIBEXECINFO} ${CRC32_LIBRARY})
  39. DTRACE_INSTRUMENT(mysys)
  40. +IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
  41. + TARGET_LINK_LIBRARIES(mysys atomic)
  42. +ENDIF()
  43. +
  44. IF(HAVE_BFD_H)
  45. TARGET_LINK_LIBRARIES(mysys bfd)
  46. ENDIF(HAVE_BFD_H)
  47. --- a/sql/CMakeLists.txt
  48. +++ b/sql/CMakeLists.txt
  49. @@ -190,6 +190,10 @@ ELSE()
  50. SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
  51. ENDIF()
  52. +IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
  53. + TARGET_LINK_LIBRARIES(sql atomic)
  54. +ENDIF()
  55. +
  56. IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)