Skip to content

Commit

Permalink
mariadb: fix build on powerpc
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed May 24, 2024
1 parent b689812 commit 4e46661
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 2 deletions.
10 changes: 8 additions & 2 deletions databases/mariadb/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ set version_branch [join [lrange [split ${version} .] 0 1] .]
set revision_client 0
set revision_server 0
categories databases
platforms darwin
license GPL-2
maintainers {michaelld @michaelld} openmaintainer
homepage https://mariadb.org/
Expand Down Expand Up @@ -46,7 +45,8 @@ if {$subport eq $name} {
patch.pre_args-replace -p0 -p1
patchfiles patch-cmake-install_layout.cmake.diff \
patch-CMakeLists.txt.diff \
patch-mariadb-Ventura-and-arm64.diff
patch-mariadb-Ventura-and-arm64.diff \
patch-powerpc.diff

checksums rmd160 c1df56d5c9ae118693e721aefb18fb19277bf5c0 \
sha256 23ff96db2215d3d2eb8697488719153c83ac4d131f504ae397f43c14c6d91ba3 \
Expand Down Expand Up @@ -83,6 +83,12 @@ if {$subport eq $name} {
${worksrcpath}/cmake/libutils.cmake
}

# Consider installing them to enable more features from this software.
# C++11 enabled compiler <http://www.open-std.org/jtc1/sc22/wg21/>
# REQUIRED: You need a more modern compiler in order to build the Activity Manager daemon
# Moreover, a newer GCC is needed for atomics support.
compiler.cxx_standard 2011

configure.args-delete \
-DCMAKE_INSTALL_NAME_DIR=${prefix}/lib
configure.args-append \
Expand Down
97 changes: 97 additions & 0 deletions databases/mariadb/files/patch-powerpc.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
--- a/include/my_cpu.h 2020-05-06 18:54:21.000000000 +0800
+++ b/include/my_cpu.h 2024-05-24 14:50:49.000000000 +0800
@@ -34,6 +34,19 @@
#define HMT_medium_high() asm volatile("or 5,5,5")
/* High priority */
#define HMT_high() asm volatile("or 3,3,3")
+#elif defined(__POWERPC__)
+/* Very low priority */
+#define HMT_very_low() asm volatile("or r31,r31,r31")
+/* Low priority */
+#define HMT_low() asm volatile("or r1,r1,r1")
+/* Medium low priority */
+#define HMT_medium_low() asm volatile("or r6,r6,r6")
+/* Medium priority */
+#define HMT_medium() asm volatile("or r2,r2,r2")
+/* Medium high priority */
+#define HMT_medium_high() asm volatile("or r5,r5,r5")
+/* High priority */
+#define HMT_high() asm volatile("or r3,r3,r3")
#else
#define HMT_very_low()
#define HMT_low()

--- a/packaging/rpm-oel/my_config.h 2020-05-06 18:54:22.000000000 +0800
+++ b/packaging/rpm-oel/my_config.h 2024-05-24 14:53:59.000000000 +0800
@@ -11,9 +11,9 @@
#include "my_config_i386.h"
#elif defined(__ia64__)
#include "my_config_ia64.h"
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) || defined(__ppc__)
#include "my_config_ppc.h"
-#elif defined(__powerpc64__)
+#elif defined(__powerpc64__) || defined(__ppc64__)
#include "my_config_ppc64.h"
#elif defined(__s390x__)
#include "my_config_s390x.h"

--- a/storage/innobase/os/os0sync.c 2020-05-06 18:54:22.000000000 +0800
+++ b/storage/innobase/os/os0sync.c 2024-05-24 14:56:58.000000000 +0800
@@ -900,7 +900,7 @@
LeaveCriticalSection(fast_mutex);
#else
pthread_mutex_unlock(fast_mutex);
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__POWERPC__)
os_mb;
#endif
#endif

--- a/storage/innobase/sync/sync0sync.c 2020-05-06 18:54:22.000000000 +0800
+++ b/storage/innobase/sync/sync0sync.c 2024-05-24 14:57:41.000000000 +0800
@@ -594,7 +594,7 @@
mutex_set_waiters(mutex, 1);

/* Make sure waiters store won't pass over mutex_test_and_set */
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__POWERPC__)
os_mb;
#endif


--- a/storage/xtradb/include/os0sync.h 2020-05-06 18:54:23.000000000 +0800
+++ b/storage/xtradb/include/os0sync.h 2024-05-24 14:58:17.000000000 +0800
@@ -345,7 +345,7 @@
/**********************************************************//**
Returns the old value of *ptr, atomically sets *ptr to new_val */

-#if defined(__powerpc__) || defined(__aarch64__)
+#if defined(__powerpc__) || defined(__POWERPC__) || defined(__aarch64__)
/*
os_atomic_test_and_set_byte_release() should imply a release barrier before
setting, and a full barrier after. But __sync_lock_test_and_set() is only

--- a/storage/xtradb/os/os0sync.c 2020-05-06 18:54:23.000000000 +0800
+++ b/storage/xtradb/os/os0sync.c 2024-05-24 14:59:35.000000000 +0800
@@ -882,7 +882,7 @@
LeaveCriticalSection(fast_mutex);
#else
pthread_mutex_unlock(fast_mutex);
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__POWERPC__)
os_mb;
#endif
#endif

--- a/storage/xtradb/sync/sync0sync.c 2020-05-06 18:54:23.000000000 +0800
+++ b/storage/xtradb/sync/sync0sync.c 2024-05-24 15:00:05.000000000 +0800
@@ -589,7 +589,7 @@
mutex_set_waiters(mutex, 1);

/* Make sure waiters store won't pass over mutex_test_and_set */
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__POWERPC__)
os_mb;
#endif

0 comments on commit 4e46661

Please sign in to comment.