mariadb: Fix build on newer 32bit architectures

newer 32bit arches e.g. RV32 and ARC do not have __NR_io_getevents
syscall and have started of with 64bit time_t so there is no 32bit
version

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2021-04-03 12:40:14 -07:00
parent 7e64cce442
commit bd8e72c139
3 changed files with 67 additions and 0 deletions

View File

@ -20,6 +20,8 @@ SRC_URI = "https://downloads.mariadb.org/interstitial/${BP}/source/${BP}.tar.gz
file://fix-arm-atomic.patch \
file://0001-Fix-library-LZ4-lookup.patch \
file://0001-innobase-Define-__NR_futex-if-it-does-not-exist.patch \
file://0001-aio_linux-Check-if-syscall-exists-before-using-it.patch \
file://sys_futex.patch \
"
SRC_URI_append_libc-musl = " file://ppc-remove-glibc-dep.patch"

View File

@ -0,0 +1,43 @@
From 5d9a869a72420cf0bb08b6aa93e980df90bdcf2e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 3 Apr 2021 12:02:36 -0700
Subject: [PATCH] aio_linux: Check if syscall exists before using it
Return -ENOSYS if not implememented, fixes build on arches like RISCV32
Fixes
tpool/aio_linux.cc:63:20: error: '__NR_io_getevents' was not declared in this scope; did you mean 'io_getevents'?
63 | int ret= syscall(__NR_io_getevents, reinterpret_cast<long>(ctx),
| ^~~~~~~~~~~~~~~~~
| io_getevents
Upstream-Staus: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
tpool/aio_linux.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tpool/aio_linux.cc b/tpool/aio_linux.cc
index d9aa8be2..d8a87a8f 100644
--- a/tpool/aio_linux.cc
+++ b/tpool/aio_linux.cc
@@ -59,6 +59,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/
*/
static int my_getevents(io_context_t ctx, long min_nr, long nr, io_event *ev)
{
+#ifdef __NR_io_getevents
int saved_errno= errno;
int ret= syscall(__NR_io_getevents, reinterpret_cast<long>(ctx),
min_nr, nr, ev, 0);
@@ -68,6 +69,9 @@ static int my_getevents(io_context_t ctx, long min_nr, long nr, io_event *ev)
errno= saved_errno;
}
return ret;
+#else
+ return -ENOSYS;
+#endif
}
#endif
--
2.31.1

View File

@ -0,0 +1,22 @@
Use SYS_futex for syscall
glibc defines SYS_futex and on newer 32bit CPUs like RISCV-32, arc there
is no 32bit time_t therefore define SYS_futex in terms of SYS_futex_time64
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/storage/innobase/include/ib0mutex.h
+++ b/storage/innobase/include/ib0mutex.h
@@ -150,6 +150,12 @@ private:
#include <linux/futex.h>
#include <sys/syscall.h>
+/** Newer 32bit CPUs eg. RISCV-32 are defaulting to 64bit time_t from get go and
+ therefore do not define __NR_futex */
+#if !defined(SYS_futex) && defined(SYS_futex_time64)
+# define SYS_futex SYS_futex_time64
+#endif
+
/** Mutex implementation that used the Linux futex. */
template <template <typename> class Policy>
struct TTASFutexMutex {