mariadb: Fix build with clang

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2025-04-07 14:29:03 -07:00
parent 8e423a43b8
commit 09f110b8a0
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 30 additions and 0 deletions

View File

@ -24,6 +24,7 @@ SRC_URI = "https://archive.mariadb.org/${BP}/source/${BP}.tar.gz \
file://lfs64.patch \
file://0001-Add-missing-includes-cstdint-and-cstdio.patch \
file://0001-Ensure-compatibility-with-ARMv9-by-updating-.arch-di.patch \
file://3871.patch \
"
SRC_URI[sha256sum] = "ff6595f8c482f9921e39b97fa1122377a69f0dcbd92553c6b9032cbf0e9b5354"

View File

@ -0,0 +1,29 @@
From d6923ac0adc11a0364acd421316116190eedb508 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Fri, 7 Mar 2025 02:04:01 -0500
Subject: [PATCH] Fix building with Clang and GCC on RISC-V
Clang does not have the builtin __builtin_riscv_pause().
Upstream-Status: Backport [https://github.com/MariaDB/server/pull/3871]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
include/my_cpu.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/include/my_cpu.h
+++ b/include/my_cpu.h
@@ -97,7 +97,12 @@ static inline void MY_RELAX_CPU(void)
/* Changed from __ppc_get_timebase for musl and clang compatibility */
__builtin_ppc_get_timebase();
#elif defined __GNUC__ && defined __riscv
- __builtin_riscv_pause();
+ /* The GCC-only __builtin_riscv_pause() or the pause instruction is
+ encoded like a fence instruction with special parameters. On RISC-V
+ implementations that do not support arch=+zihintpause this
+ instruction could be interpreted as a more expensive memory fence;
+ it should not be an illegal instruction. */
+ __asm__ volatile(".long 0x0100000f" ::: "memory");
#elif defined __GNUC__
/* Mainly, prevent the compiler from optimizing away delay loops */
__asm__ __volatile__ ("":::"memory");