diff --git a/mariadb-riscv64-asm-pause.patch b/mariadb-riscv64-asm-pause.patch new file mode 100644 index 0000000000000000000000000000000000000000..a3d088adf5c66f7fc07f9e70bb7f747d1555b74b --- /dev/null +++ b/mariadb-riscv64-asm-pause.patch @@ -0,0 +1,29 @@ +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 a9f9f4dd2c782ac4c968b635666af964275616be..dbfa1000114af8ffc11bca6318a5e5e1f1764bf6 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -74,7 +74,7 @@ Name: mariadb Version: 11.8.1 -Release: 1 +Release: 2 Epoch: 4 Summary: A very fast and robust SQL database server @@ -113,6 +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 BuildRequires: ninja-build mold BuildRequires: cmake gcc-c++ @@ -1456,6 +1458,9 @@ fi %endif %changelog +* 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 - update to 11.8.1 (RC)