diff --git a/mariadb-fix-building-with-Clang-and-GCC-on-RISC-V.patch b/mariadb-fix-building-with-Clang-and-GCC-on-RISC-V.patch new file mode 100644 index 0000000000000000000000000000000000000000..dc76a28a74e359df89b885c7e4bef7ba08b21185 --- /dev/null +++ b/mariadb-fix-building-with-Clang-and-GCC-on-RISC-V.patch @@ -0,0 +1,28 @@ +From 05be1865a9c16e34296ea0fa28b9bee921f0b907 Mon Sep 17 00:00:00 2001 +From: Brad Smith +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(). +--- + include/my_cpu.h | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/include/my_cpu.h b/include/my_cpu.h +index bd5fca5f21bd8..2b34e03fce347 100644 +--- 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"); diff --git a/mariadb-riscv64-asm-pause.patch b/mariadb-riscv64-asm-pause.patch deleted file mode 100644 index a3d088adf5c66f7fc07f9e70bb7f747d1555b74b..0000000000000000000000000000000000000000 --- a/mariadb-riscv64-asm-pause.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff -Naur mariadb-11.8.1.org/CMakeLists.txt mariadb-11.8.1/CMakeLists.txt ---- mariadb-11.8.1.org/CMakeLists.txt 2025-02-12 18:13:20.000000000 +0800 -+++ mariadb-11.8.1/CMakeLists.txt 2025-04-07 14:41:02.273851900 +0800 -@@ -124,6 +124,10 @@ - IF(DEFINED ENV{CPPFLAGS}) - ADD_DEFINITIONS($ENV{CPPFLAGS}) - ENDIF() -+# Force Zihintpause for RISC-V arch -+IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64") -+ ADD_COMPILE_OPTIONS(-march=rv64g_zihintpause) -+ENDIF() - - # NUMA - SET(WITH_NUMA "AUTO" CACHE STRING "Build with non-uniform memory access, allowing --innodb-numa-interleave. Options are ON|OFF|AUTO. ON = enabled (requires NUMA library), OFF = disabled, AUTO = enabled if NUMA library found.") -diff -Naur mariadb-11.8.1.org/include/my_cpu.h mariadb-11.8.1/include/my_cpu.h ---- mariadb-11.8.1.org/include/my_cpu.h 2025-02-12 18:13:20.000000000 +0800 -+++ mariadb-11.8.1/include/my_cpu.h 2025-04-08 11:24:07.839425200 +0800 -@@ -97,7 +97,11 @@ - /* Changed from __ppc_get_timebase for musl and clang compatibility */ - __builtin_ppc_get_timebase(); - #elif defined __GNUC__ && defined __riscv -+#if __GNUC__ >= 13 - __builtin_riscv_pause(); -+#else -+ __asm__ __volatile__ ("pause":::"memory"); -+#endif - #elif defined __GNUC__ - /* Mainly, prevent the compiler from optimizing away delay loops */ - __asm__ __volatile__ ("":::"memory"); diff --git a/mariadb.spec b/mariadb.spec index dbfa1000114af8ffc11bca6318a5e5e1f1764bf6..af9f050ff5cf0b7a6f6502b65f4125d3dd6a72ce 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -74,7 +74,7 @@ Name: mariadb Version: 11.8.1 -Release: 2 +Release: 3 Epoch: 4 Summary: A very fast and robust SQL database server @@ -113,8 +113,8 @@ Patch9: %{pkgnamepatch}-ownsetup.patch Patch10: %{pkgnamepatch}-ssl-cipher-tests.patch # Patch11: Use PCDIR CMake option, if configured Patch11: %{pkgnamepatch}-pcdir.patch -# Patch12: Use inline asm to replace __builtin_riscv_pause() -Patch12: %{pkgnamepatch}-riscv64-asm-pause.patch +# Patch12: Older version of GCC and Clang does not have the builtin __builtin_riscv_pause() +Patch12: %{pkgnamepatch}-fix-building-with-Clang-and-GCC-on-RISC-V.patch BuildRequires: ninja-build mold BuildRequires: cmake gcc-c++ @@ -1458,7 +1458,10 @@ fi %endif %changelog -* Sun Apr 06 2025 Zijian Li - 4:11.8.1-2 +* Wed May 7 2025 Dingli Zhang - 4:11.8.1-3 +- Fix building with Clang and GCC on RISC-V + +* Sun Apr 06 2025 Zijian Li - 4:11.8.1-2 - RISC-V: use inline asm to replace __builtin_riscv_pause * Fri Mar 21 2025 Funda Wang - 4:11.8.1-1