SQLite User Forum

Bug in sqlite3 affecting ppc64: wrong defines used
Login

Bug in sqlite3 affecting ppc64: wrong defines used

(1.1) By Sergey Fedorov (barracuda156) on 2024-01-31 11:31:21 edited from 1.0 [source]

Could someone assist with fixing the following in SQLite please? The existing code has an effect of defining pointer size for Darwin ppc64 to 4 bytes, which is obviously wrong. The issue is that __POWERPC__ is defined both for ppc and ppc64. Instead, the right way will be to use __ppc__:

--- sqlite3.c	2024-01-31
+++ sqlite3.c	2024-01-31
@@ -14860,7 +14860,7 @@
 #   define SQLITE_PTRSIZE __SIZEOF_POINTER__
 # elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
        defined(_M_ARM)   || defined(__arm__)    || defined(__x86)   ||    \
-      (defined(__APPLE__) && defined(__POWERPC__)) ||                     \
+      (defined(__APPLE__) && defined(__ppc__)) ||                         \
       (defined(__TOS_AIX__) && !defined(__64BIT__))
 #   define SQLITE_PTRSIZE 4
 # else

--- tea/generic/tclsqlite3.c	2024-01-31
+++ tea/generic/tclsqlite3.c	2024-01-31
@@ -65,7 +65,7 @@
 #     define SQLITE_PTRSIZE __SIZEOF_POINTER__
 #   elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
          defined(_M_ARM)   || defined(__arm__)    || defined(__x86)   ||    \
-        (defined(__APPLE__) && defined(__POWERPC__)) ||                     \
+        (defined(__APPLE__) && defined(__ppc__)) ||                         \
         (defined(__TOS_AIX__) && !defined(__64BIT__))
 #     define SQLITE_PTRSIZE 4
 #   else

Likewise, powerpc64 should not be overridden here:

--- config.guess	2024-01-31
+++ config.guess	2024-01-31
@@ -1425,7 +1425,7 @@
 		esac
 	    fi
 	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
-	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+	    if (echo '#ifdef __ppc__'; echo IS_PPC; echo '#endif') | \
 		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
 		   grep IS_PPC >/dev/null
 	    then

(2) By Richard Hipp (drh) on 2024-01-31 11:35:36 in reply to 1.1 [link] [source]

The fix for this has already been entered on trunk and will be in the 3.46.0 release. Perhaps you are disappointed that the fix was not in the 3.45.1 patch release? We strive to keep the changes in patch releases to a minimum, and this change did not seem to be important enough to justify including it in a patch release.

(3) By Sergey Fedorov (barracuda156) on 2024-01-31 11:58:52 in reply to 2 [link] [source]

Ah, got it. No issues, we can include a local patch in Macports for now. Thank you!