From 88e60c006d490e495748be35a0fae5ec4d18181f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E5=BB=BA?= Date: Sat, 5 Apr 2025 16:52:47 +0800 Subject: [PATCH] [11.8.1] Fix up the error: '__builtin_riscv_pause'was not declared in this scope; --- mariadb-riscv64-asm-pause.patch | 29 +++++++++++++++++++++++++++++ mariadb.spec | 7 ++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 mariadb-riscv64-asm-pause.patch diff --git a/mariadb-riscv64-asm-pause.patch b/mariadb-riscv64-asm-pause.patch new file mode 100644 index 0000000..a3d088a --- /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 a9f9f4d..dbfa100 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) -- Gitee