Skip to contentSkip to conversation

package/sqlite: Fix build on riscv32

PATCH New Bernd Kuhls 1 participant 1 message Apr 27

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/sqlite: Fix build on riscv32

Buildroot commit 7cf7140b4832d1281fd352893d3f7cfc92e8eef3 bumped the package from 3.51.3 to 3.53.0. Version 3.52.0 contains upstream commit
https://github.com/sqlite/sqlite/commit/db84cdb747ac926d3f272933386fc6196c40cb19
which added the usage of __uint128_t with a dependency on, among others, __riscv. This matches riscv32 and riscv64 but only riscv64 has __uint128_t defined.

Added upstream patch to fix the problem.

Fixes:
https://autobuild.buildroot.net/results/a6e/a6e4f391081c8059d93fb5b7bd33e08c57b27dcf/

---
v2: replaced patch with upstream commit

 ...tion-fix-for-uint128-on-RISCV-32-bit.patch | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 package/sqlite/0001-Feature-detection-fix-for-uint128-on-RISCV-32-bit.patch
package/sqlite/0001-Feature-detection-fix-for-uint128-on-RISCV-32-bit.patch new file +70 -0
new file mode 100644
index 0000000000..5d5a197b1f
@@ -0,0 +1,70 @@
+From 27e808ff2cdb6541c12793ccaa09949b5898f14b Mon Sep 17 00:00:00 2001
+From: drh <>
+Date: Mon, 27 Apr 2026 12:25:36 +0000
+Subject: [PATCH] Feature detection fix for uint128 on RISCV 32-bit.
+
+FossilOrigin-Name: e3f318bf52932460890333c6dcae352ab4b0c943d7be67734649eff1ff9fc9fc
+
+Upstream: https://sqlite.org/src/info/e3f318bf52932460
+
+Patch created from github repo commit:
+https://github.com/sqlite/sqlite/commit/27e808ff2cdb6541c12793ccaa09949b5898f14b
+
+[Bernd: rebased for "the amalgamation"
+        https://sqlite.org/amalgamation.html]
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ sqlite3.c    | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/sqlite3.c b/sqlite3.c
+index 67e6e2ee03..57b98ad4c9 100644
+--- a/sqlite3.c
++++ b/sqlite3.c
+@@ -458,15 +458,20 @@ u8 sqlite3StrIHash(const char *z){
+   return h;
+ }
+ 
++#if !defined(SQLITE_DISABLE_INTRINSIC)               \
++  && (defined(__GNUC__) || defined(__clang__))       \
++  && (defined(__x86_64__) || defined(__aarch64__) || \
++      (defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen>32)))
++#define SQLITE_USE_UINT128
++#endif
++
+ /*
+ ** Two inputs are multiplied to get a 128-bit result.  Write the
+ ** lower 64-bits of the result into *pLo, and return the high-order
+ ** 64 bits.
+ */
+ static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
+-#if (defined(__GNUC__) || defined(__clang__)) \
+-        && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
+-        && !defined(SQLITE_DISABLE_INTRINSIC)
++#if defined(SQLITE_USE_UINT128)
+   __uint128_t r = (__uint128_t)a * b;
+   *pLo = (u64)r;
+   return (u64)(r>>64);
+@@ -500,9 +505,7 @@ static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
+ ** The lower 64 bits of A*B are discarded.
+ */
+ static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
+-#if (defined(__GNUC__) || defined(__clang__)) \
+-        && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
+-        && !defined(SQLITE_DISABLE_INTRINSIC)
++#if defined(SQLITE_USE_UINT128)
+   __uint128_t r = (__uint128_t)a * b;
+   r += ((__uint128_t)aLo * b) >> 32;
+   *pLo = (r>>32)&0xffffffff;
+@@ -540,6 +543,8 @@ static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
+ #endif
+ }
+ 
++#undef SQLITE_USE_UINT128
++
+ /*
+ ** Return a u64 with the N-th bit set.
+ */
+-- 
+2.47.3
+
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot