Subject: [alpine-aports] [PATCH] main/mariadb: fix build on mips{el} (-latomic)

From: alpine-mips-patches <[email-masked]>
Date: Wed, 28 Nov 2018 07:01:20 +0000

This adds generic -latomic check so likely covers all architectures
without 64-bit atomic built-ins (e.g. armel too).
---
 main/mariadb/APKBUILD                    |  4 +-
 main/mariadb/fix-c11-atomics-check.patch | 67 ++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 main/mariadb/fix-c11-atomics-check.patch

diff --git a/main/mariadb/APKBUILD b/main/mariadb/APKBUILD
index a1d65838a4..03256605b7 100644
--- a/main/mariadb/APKBUILD
+++ b/main/mariadb/APKBUILD
@@ -6,7 +6,7 @@
 # Maintainer: Natanael Copa <[email-masked]>
 pkgname=mariadb
 pkgver=10.3.10
-pkgrel=0
+pkgrel=1
 pkgdesc="A fast SQL database server"
 url="http://www.mariadb.org"
 pkgusers="mysql"
@@ -39,6 +39,7 @@ fi
 
 source="https://downloads.mariadb.org/interstitial/mariadb-$pkgver/source/mariadb-$pkgver.tar.gz
 	$pkgname.initd
+	fix-c11-atomics-check.patch
 	fix-mysql-install-db-path.patch
 	fix-ucontext-check.patch
 	fix-pthread-detach.patch
@@ -406,6 +407,7 @@ _plugin_rocksdb() {
 
 sha512sums="dee7789dff359a6352ceacb2db6bcb4730940e9458adda4e23894f9bfa0a7ff8c238060bffca58a60b662275e52a31ea1784d51fae114312b003c024e9412b31  mariadb-10.3.10.tar.gz
 06751768cb00d2e433655635c38d267ef25084a5830ff40e719ac579223c7192dc34b43f919ab6faf480094632327511cbd22456064dde2d04dc15648b9e3b9f  mariadb.initd
+b4469f2f0299e71c09b65c91373f2d72b7fe9a9cd58ad24737a78a8097473b29c32b7267e173a2dfe1158f2f7d40a7fb02fb1b35caeda44d16ae3b9e2602a75f  fix-c11-atomics-check.patch
 0c08198b907dad18c5a7ab89f37ff53da7cb102b0848fb58912900bd92468a0d4f853bc5c0116f655c500d5ed20dcbf20d3884dcd0040634e23c911dfeaf7001  fix-mysql-install-db-path.patch
 2d42a3e4051aaeee49da52947dbc354d44d975ca50571777a0aba8bed032ccd6a07c29e0cbb9f74c396dce9937b5d16af19ab310638c285e418e0281361024f3  fix-ucontext-check.patch
 60450ccc3b089953cb20ddd7c81aa1afbb52aa9d28211eeec0b9c04653b2bf5f56561315d8c8e0444d263cd412c28df91936d78daf1919dda9e402beb2243a43  fix-pthread-detach.patch
diff --git a/main/mariadb/fix-c11-atomics-check.patch b/main/mariadb/fix-c11-atomics-check.patch
new file mode 100644
index 0000000000..f98c0a20fd
--- /dev/null
+++ b/main/mariadb/fix-c11-atomics-check.patch
@@ -0,0 +1,67 @@
+--- a/configure.cmake
++++ b/configure.cmake
+@@ -135,10 +135,11 @@
+   IF(NOT LIBRT)
+     MY_SEARCH_LIBS(clock_gettime rt LIBRT)
+   ENDIF()
++  MY_SEARCH_LIBS(__atomic_load_8 atomic LIBATOMIC)
+   FIND_PACKAGE(Threads)
+ 
+   SET(CMAKE_REQUIRED_LIBRARIES 
+-    ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBEXECINFO})
++    ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${LIBATOMIC} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBEXECINFO})
+   # Need explicit pthread for gcc -fsanitize=address
+   IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
+     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread)
+@@ -919,14 +920,26 @@
+   return 0;
+ }"
+ HAVE_GCC_ATOMIC_BUILTINS)
+-CHECK_CXX_SOURCE_COMPILES("
++
++SET(MAIN__ATOMIC_LOAD_N "
+ 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)
++}")
++CHECK_CXX_SOURCE_COMPILES("${MAIN__ATOMIC_LOAD_N}" HAVE_GCC_C11_ATOMICS)
++IF(HAVE_GCC_C11_ATOMICS AND HAVE_LIBATOMIC)
++  SET(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
++  LIST(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${LIBATOMIC}")
++  CHECK_CXX_SOURCE_COMPILES("${MAIN__ATOMIC_LOAD_N}" HAVE_GCC_C11_INLINE_ATOMICS)
++  IF(HAVE_GCC_C11_INLINE_ATOMICS)
++    UNSET(HAVE_LIBATOMIC)
++    UNSET(LIBATOMIC)
++  ELSE()
++    SET(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
++  ENDIF()
++ENDIF()
+ 
+ IF(WITH_VALGRIND)
+   SET(HAVE_valgrind 1)
+--- a/mysys/CMakeLists.txt
++++ b/mysys/CMakeLists.txt
+@@ -74,7 +74,7 @@
+ 
+ ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
+ TARGET_LINK_LIBRARIES(mysys dbug strings mysys_ssl ${ZLIB_LIBRARY} 
+- ${LIBNSL} ${LIBM} ${LIBRT} ${LIBDL} ${LIBSOCKET} ${LIBEXECINFO} ${CRC32_LIBRARY})
++ ${LIBNSL} ${LIBM} ${LIBRT} ${LIBDL} ${LIBATOMIC} ${LIBSOCKET} ${LIBEXECINFO} ${CRC32_LIBRARY})
+ DTRACE_INSTRUMENT(mysys)
+ 
+ IF(HAVE_BFD_H)
+--- a/storage/rocksdb/build_rocksdb.cmake
++++ b/storage/rocksdb/build_rocksdb.cmake
+@@ -142,7 +142,7 @@
+ if(WIN32)
+   set(SYSTEM_LIBS ${SYSTEM_LIBS} Shlwapi.lib Rpcrt4.lib)
+ else()
+-  set(SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT} ${LIBRT})
++  set(SYSTEM_LIBS ${LIBATOMIC} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT})
+ endif()
+ 
+ set(ROCKSDB_LIBS rocksdblib})
-- 
2.19.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---