diff options
author | Vicențiu Ciorbaru <cvicentiu@gmail.com> | 2021-10-15 16:51:05 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <cvicentiu@gmail.com> | 2021-10-19 16:08:51 +0300 |
commit | f502ccbcb5dfce29067434885a23db8d1bd5f134 (patch) | |
tree | 7464c90d50ad9549f9b8db672c04c68cbd9e1338 /configure.cmake | |
parent | 39f6315612149860ffdb92d433a6bace2096b9c1 (diff) | |
download | mariadb-git-f502ccbcb5dfce29067434885a23db8d1bd5f134.tar.gz |
Link with libatomic to enable C11 atomics support
Some architectures (mips) require libatomic to support proper
atomic operations. Check first if support is available without
linking, otherwise use the library.
Contributors:
James Cowgill <jcowgill@debian.org>
Jessica Clarke <jrtc27@debian.org>
Vicențiu Ciorbaru <vicentiu@mariadb.org>
Diffstat (limited to 'configure.cmake')
-rw-r--r-- | configure.cmake | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/configure.cmake b/configure.cmake index 7a1369d7770..db8742bb93b 100644 --- a/configure.cmake +++ b/configure.cmake @@ -895,7 +895,25 @@ int main() long long int *ptr= &var; return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST); }" -HAVE_GCC_C11_ATOMICS) +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() + { + long long int var= 1; + long long int *ptr= &var; + return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST); + }" + 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() IF(WITH_VALGRIND) SET(HAVE_valgrind 1) |