From 67157b1aa7da0a146b7d2d5abb9237eea1f434ec Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Fri, 23 Sep 2022 02:38:29 +0200
Subject: [PATCH] fix sqlite3 on ppc with clang

The __ppc__ macro is always defined on clang but not gcc, which
results in sqlite mistakenly thinking that ppc64le with clang
is big endian.

Also disable some inline assembly stuff on ppc that is never used
with gcc and probably was never tested with modern machines.
---
 third_party/sqlite3/src/sqlite3.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/third_party/sqlite3/src/sqlite3.c b/third_party/sqlite3/src/sqlite3.c
index 4f3dc68..9017062 100644
--- a/third_party/sqlite3/src/sqlite3.c
+++ b/third_party/sqlite3/src/sqlite3.c
@@ -14317,9 +14317,9 @@ typedef INT16_TYPE LogEst;
 # if defined(i386)      || defined(__i386__)      || defined(_M_IX86) ||    \
      defined(__x86_64)  || defined(__x86_64__)    || defined(_M_X64)  ||    \
      defined(_M_AMD64)  || defined(_M_ARM)        || defined(__x86)   ||    \
-     defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
+     defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) || defined(__LITTLE_ENDIAN__)
 #   define SQLITE_BYTEORDER    1234
-# elif defined(sparc)     || defined(__ppc__) || \
+# elif defined(sparc)     || defined(__BIG_ENDIAN__) || \
        defined(__ARMEB__) || defined(__AARCH64EB__)
 #   define SQLITE_BYTEORDER    4321
 # else
@@ -20713,7 +20713,7 @@ SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
       return val;
   }
 
-#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__))
+#elif 0
 
   __inline__ sqlite_uint64 sqlite3Hwtime(void){
       unsigned long long retval;
@@ -196385,9 +196385,9 @@ struct RtreeMatchArg {
 #if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
     defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \
     defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \
-    defined(__arm__)
+    defined(__arm__) || defined(__LITTLE_ENDIAN__)
 # define SQLITE_BYTEORDER    1234
-#elif defined(sparc)    || defined(__ppc__)
+#elif defined(sparc)    || defined(__BIG_ENDIAN__)
 # define SQLITE_BYTEORDER    4321
 #else
 # define SQLITE_BYTEORDER    0     /* 0 means "unknown at compile-time" */
-- 
2.37.3

