Skip to content

Commit ab6ebf0

Browse files
committed
Fix building with Clang on RISC-V
Clang does not have the builtin __builtin_riscv_pause(). Forwarded: MariaDB#3871
1 parent 535700d commit ab6ebf0

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From: Jeremie Courreges-Anglas <[email protected]>
2+
Date: Wed, 5 Mar 2025 16:10:38 -0500
3+
Subject: MDEV-36217 Fix building with Clang and GCC on RISC-V
4+
5+
Clang does not have the builtin __builtin_riscv_pause().
6+
7+
Forwarded: https://github.com/MariaDB/server/pull/3871
8+
Origin: https://patch-diff.githubusercontent.com/raw/MariaDB/server/pull/3871.patch
9+
at commit b3ac29a326fb05af71331827e5e8e9e009e139a3
10+
---
11+
include/my_cpu.h | 7 ++++++-
12+
1 file changed, 6 insertions(+), 1 deletion(-)
13+
14+
diff --git a/include/my_cpu.h b/include/my_cpu.h
15+
index bd5fca5..2b34e03 100644
16+
--- a/include/my_cpu.h
17+
+++ b/include/my_cpu.h
18+
@@ -97,7 +97,12 @@ static inline void MY_RELAX_CPU(void)
19+
/* Changed from __ppc_get_timebase for musl and clang compatibility */
20+
__builtin_ppc_get_timebase();
21+
#elif defined __GNUC__ && defined __riscv
22+
- __builtin_riscv_pause();
23+
+ /* The GCC-only __builtin_riscv_pause() or the pause instruction is
24+
+ encoded like a fence instruction with special parameters. On RISC-V
25+
+ implementations that do not support arch=+zihintpause this
26+
+ instruction could be interpreted as a more expensive memory fence;
27+
+ it should not be an illegal instruction. */
28+
+ __asm__ volatile(".long 0x0100000f" ::: "memory");
29+
#elif defined __GNUC__
30+
/* Mainly, prevent the compiler from optimizing away delay loops */
31+
__asm__ __volatile__ ("":::"memory");

debian/patches/series

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ hurd-i386-plugin_disks_information_schema_disks.cc.patch
1111
hurd-i386-storage_connect_ioapi.h.patch
1212
hide-mysql-command-deprecation-warnings.patch
1313
1063738-x32-compile-time-assert.patch
14+
MDEV-36217-Fix-building-with-older-Clang-on-RISC-V.patch

0 commit comments

Comments
 (0)