Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 1 | From 976468458d53d8bb71acf48ddfc852a60557acb9 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= <vicentiu@mariadb.org> |
| 3 | Date: Thu, 23 Jul 2020 00:02:21 -0700 |
| 4 | Subject: [PATCH] Link with libatomic to enable C11 atomics support |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 | |
| 6 | Some architectures (mips) require libatomic to support proper |
| 7 | atomic operations. Check first if support is available without |
| 8 | linking, otherwise use the library. |
| 9 | |
| 10 | Upstream-Status: Pending |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 12 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> |
| 13 | --- |
| 14 | configure.cmake | 20 +++++++++++++++++++- |
| 15 | mysys/CMakeLists.txt | 4 ++++ |
| 16 | sql/CMakeLists.txt | 4 ++++ |
| 17 | 3 files changed, 27 insertions(+), 1 deletion(-) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 18 | |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 19 | diff --git a/configure.cmake b/configure.cmake |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 20 | index 4fc324a9..23a2ea91 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | --- a/configure.cmake |
| 22 | +++ b/configure.cmake |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 23 | @@ -862,7 +862,25 @@ int main() |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | long long int *ptr= &var; |
| 25 | return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST); |
| 26 | }" |
| 27 | -HAVE_GCC_C11_ATOMICS) |
| 28 | +HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC) |
| 29 | +IF (HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC) |
| 30 | + SET(HAVE_GCC_C11_ATOMICS True) |
| 31 | +ELSE() |
| 32 | + SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) |
| 33 | + LIST(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") |
| 34 | + CHECK_CXX_SOURCE_COMPILES(" |
| 35 | + int main() |
| 36 | + { |
| 37 | + long long int var= 1; |
| 38 | + long long int *ptr= &var; |
| 39 | + return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST); |
| 40 | + }" |
| 41 | + HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC) |
| 42 | + IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC) |
| 43 | + SET(HAVE_GCC_C11_ATOMICS True) |
| 44 | + ENDIF() |
| 45 | + SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) |
| 46 | +ENDIF() |
| 47 | |
| 48 | IF(WITH_VALGRIND) |
| 49 | SET(HAVE_valgrind 1) |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 50 | diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 51 | index 6aab788f..91b9c393 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 52 | --- a/mysys/CMakeLists.txt |
| 53 | +++ b/mysys/CMakeLists.txt |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 54 | @@ -154,6 +154,10 @@ TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY} |
Andrew Geissler | eef6386 | 2021-01-29 15:58:13 -0600 | [diff] [blame] | 55 | ${LIBNSL} ${LIBM} ${LIBRT} ${CMAKE_DL_LIBS} ${LIBSOCKET} ${LIBEXECINFO}) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 56 | DTRACE_INSTRUMENT(mysys) |
| 57 | |
| 58 | +IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC) |
| 59 | + TARGET_LINK_LIBRARIES(mysys atomic) |
| 60 | +ENDIF() |
| 61 | + |
| 62 | IF(HAVE_BFD_H) |
| 63 | TARGET_LINK_LIBRARIES(mysys bfd) |
| 64 | ENDIF(HAVE_BFD_H) |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 65 | diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 66 | index b9cd418f..d42e5017 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 67 | --- a/sql/CMakeLists.txt |
| 68 | +++ b/sql/CMakeLists.txt |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 69 | @@ -222,6 +222,10 @@ ELSE() |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 70 | SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL}) |
| 71 | ENDIF() |
| 72 | |
| 73 | +IF (HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC) |
| 74 | + TARGET_LINK_LIBRARIES(sql atomic) |
| 75 | +ENDIF() |
| 76 | + |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 77 | IF(MSVC OR CMAKE_SYSTEM_NAME MATCHES AIX) |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 78 | SET(libs_to_export_symbols sql mysys dbug strings) |
| 79 | # Create shared library of already compiled object |
| 80 | -- |
Andrew Geissler | e34f896 | 2021-04-15 15:53:51 -0500 | [diff] [blame] | 81 | 2.25.1 |
Andrew Geissler | bffdb3e | 2020-08-21 16:13:29 -0500 | [diff] [blame] | 82 | |