Skip to contentSkip to conversation

mariadb: Fix build with clang

PATCH New Khem Raj 1 participant 3 messages Apr 8, 2025 RISC-V

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 mariadb: Fix build with clang

---
 meta-oe/recipes-dbs/mysql/mariadb.inc        |  1 +
 meta-oe/recipes-dbs/mysql/mariadb/3871.patch | 29 ++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 meta-oe/recipes-dbs/mysql/mariadb/3871.patch
meta-oe/recipes-dbs/mysql/mariadb.inc +1 -0
index f704ff6dec..eedb6735a4 100644
@@ -24,6 +24,7 @@ SRC_URI = "https://archive.mariadb.org/${BP}/source/${BP}.tar.gz \
            file://lfs64.patch \
            file://0001-Add-missing-includes-cstdint-and-cstdio.patch \
            file://0001-Ensure-compatibility-with-ARMv9-by-updating-.arch-di.patch \
+           file://3871.patch \
           "
 SRC_URI[sha256sum] = "ff6595f8c482f9921e39b97fa1122377a69f0dcbd92553c6b9032cbf0e9b5354"
 
meta-oe/recipes-dbs/mysql/mariadb/3871.patch new file +29 -0
new file mode 100644
index 0000000000..4bbca2d706
@@ -0,0 +1,29 @@
+From d6923ac0adc11a0364acd421316116190eedb508 Mon Sep 17 00:00:00 2001
+From: Brad Smith <[email protected]>
+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().
+
+Upstream-Status: Backport [https://github.com/MariaDB/server/pull/3871]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ include/my_cpu.h | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- 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");
author
#1 lore raw

PATCH 2/3 mariadb: Fix build on riscv32

---
 meta-oe/recipes-dbs/mysql/mariadb.inc         |  1 +
 .../recipes-dbs/mysql/mariadb/riscv32.patch   | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 meta-oe/recipes-dbs/mysql/mariadb/riscv32.patch
meta-oe/recipes-dbs/mysql/mariadb.inc +1 -0
index eedb6735a4..3a39d036f7 100644
@@ -25,6 +25,7 @@ SRC_URI = "https://archive.mariadb.org/${BP}/source/${BP}.tar.gz \
            file://0001-Add-missing-includes-cstdint-and-cstdio.patch \
            file://0001-Ensure-compatibility-with-ARMv9-by-updating-.arch-di.patch \
            file://3871.patch \
+           file://riscv32.patch \
           "
 SRC_URI[sha256sum] = "ff6595f8c482f9921e39b97fa1122377a69f0dcbd92553c6b9032cbf0e9b5354"
 
meta-oe/recipes-dbs/mysql/mariadb/riscv32.patch new file +19 -0
new file mode 100644
index 0000000000..24b86584e3
@@ -0,0 +1,19 @@
+Do not use static_cast in C sources
+
+C compiler does not recognise static_cast which is a C++ keyword
+and bails out compiling mysys/my_rdtsc.c, use traditional typecast
+instead
+
+Upstream-Status: Submitted [https://github.com/MariaDB/server/pull/1981/files#r2032207090]
+Signed-off-by: Khem Raj <[email protected]>
+--- a/include/my_rdtsc.h
++++ b/include/my_rdtsc.h
+@@ -226,7 +226,7 @@ static inline ulonglong my_timer_cycles(
+         "sub %0, zero, %0\n"
+         "and %1, %1, %0\n"
+         : "=r"(result_hi0), "=r"(result_lo), "=r"(result_hi1));
+-    return (static_cast<ulonglong>(result_hi1) << 32) | result_lo;
++    return ((ulonglong)result_hi1 << 32) | result_lo;
+ # else
+     ulonglong result;
+     __asm __volatile__("rdtime %0" : "=r"(result));
author
#2 lore raw

PATCH 3/3 webkitgtk3: Fix build break due to a typo

In reply to Khem Raj

Also fix building on riscv64

---
 .../webkitgtk3/fix-ftbfs-riscv64.patch        | 39 +++++++++++++++++++
 .../fix-typo-denormaldisabler.patch           | 18 +++++++++
 .../webkitgtk/webkitgtk3_2.48.1.bb            |  2 +
 3 files changed, 59 insertions(+)
 create mode 100644 meta-oe/recipes-support/webkitgtk/webkitgtk3/fix-ftbfs-riscv64.patch
 create mode 100644 meta-oe/recipes-support/webkitgtk/webkitgtk3/fix-typo-denormaldisabler.patch
meta-oe/recipes-support/webkitgtk/webkitgtk3/fix-ftbfs-riscv64.patch new file +39 -0
new file mode 100644
index 0000000000..00347ef3e1
@@ -0,0 +1,39 @@
+From: Alberto Garcia <[email protected]>
+Description: Use WTF_CPU_UNKNOWN when building for riscv64
+ WebKitGTK doesn't build on riscv64 even with the JIT disabled.
+ Treating the CPU as unknown is perhaps a bit severe, but it allows us
+ to get the build done until someone steps up to maintain this
+ properly.
+Bug: https://bugs.webkit.org/show_bug.cgi?id=271371
+Forwarded: no
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+--- a/Source/WTF/wtf/PlatformCPU.h
++++ b/Source/WTF/wtf/PlatformCPU.h
+@@ -286,14 +286,6 @@
+ 
+ #endif /* ARM */
+ 
+-/* CPU(RISCV64) - RISC-V 64-bit */
+-#if    defined(__riscv) \
+-    && defined(__riscv_xlen) \
+-    && (__riscv_xlen == 64)
+-#define WTF_CPU_RISCV64 1
+-#define WTF_CPU_KNOWN 1
+-#endif
+-
+ #if !CPU(KNOWN)
+ #define WTF_CPU_UNKNOWN 1
+ #endif
+--- a/Source/cmake/WebKitCommon.cmake
++++ b/Source/cmake/WebKitCommon.cmake
+@@ -125,8 +125,6 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
+         set(WTF_CPU_PPC64 1)
+     elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
+         set(WTF_CPU_PPC64LE 1)
+-    elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64")
+-        set(WTF_CPU_RISCV64 1)
+     elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
+         set(WTF_CPU_LOONGARCH64 1)
+     else ()
meta-oe/recipes-support/webkitgtk/webkitgtk3/fix-typo-denormaldisabler.patch new file +18 -0
new file mode 100644
index 0000000000..c3383fcd41
@@ -0,0 +1,18 @@
+From: Alberto Garcia <[email protected]>
+Subject: Fix build failure due to missing semicolon
+
+Source: https://sources.debian.org/data/main/w/webkit2gtk/2.48.1-2/debian/patches/fix-typo-denormaldisabler.patch
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+--- a/Source/WebCore/platform/audio/DenormalDisabler.cpp
++++ b/Source/WebCore/platform/audio/DenormalDisabler.cpp
+@@ -91,7 +91,7 @@ DenormalDisabler::~DenormalDisabler()
+     }
+ }
+ #else
+-DenormalDisabler::DenormalDisabler() = default
++DenormalDisabler::DenormalDisabler() = default;
+ DenormalDisabler::~DenormalDisabler() = default;
+ #endif
+ 
meta-oe/recipes-support/webkitgtk/webkitgtk3_2.48.1.bb +2 -0
index 14dc3a841d..b03ed3cbb9 100644
@@ -19,6 +19,8 @@ SRC_URI = "https://www.webkitgtk.org/releases/webkitgtk-${PV}.tar.xz \
            file://no-musttail-arm.patch \
            file://sys_futex.patch \
            file://0001-Fix-build-errors-on-RISCV-https-bugs.webkit.org-show.patch \
+           file://fix-typo-denormaldisabler.patch \
+           file://fix-ftbfs-riscv64.patch \
            "
 SRC_URI[sha256sum] = "98efdf21c4cdca0fe0b73ab5a8cb52093b5aa52d9b1b016a93f71dbfa1eb258f"