|
| 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"); |
0 commit comments