commit:     2b5e0d06d46241cc2d8c58b7e4a32527534cb4b1
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 12:12:48 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 12:48:56 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2b5e0d06

dev-db/sqlite: Don't use rdtsc on i486

If -DSQLITE_ENABLE_STMT_SCANSTATUS is passed, rdtsc is used for profiling
purposes, but that's not available on i486 CPUs (e.g. Soekris 4501 / AMD Elan
in the linked bug).

Just look for i586 instead of i386. For the i386/i486 case, it's fine if we
use the stub implementation. This feels cleaner than toggling functionality
in the ebuild, even if it's unlikely anyone on i486 is going to use that.

Thanks to amonakov who found the problem quickly and the relevant part of 
SQLite.

SQLITE_ENABLE_STMT_SCANSTATUS was first enabled with 
6d8922b1541e86d62546808b1edca6fe422fc560
(grafted from migration), but I suspect the reason nobody noticed this before is
(apart from i486 being rare) that only fairly recent gnupg-2.4.x starts to use
SQLite (and we default-enable USE=tofu in-line with some upstream 
reocmmendations).

Bug: https://bugs.gentoo.org/948671
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...e-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch | 31 ++++++++++++++++++++++
 ...qlite-3.47.2.ebuild => sqlite-3.47.2-r1.ebuild} |  1 +
 ...qlite-3.48.0.ebuild => sqlite-3.48.0-r1.ebuild} |  4 +++
 dev-db/sqlite/sqlite-9999.ebuild                   |  6 ++++-
 4 files changed, 41 insertions(+), 1 deletion(-)

diff --git 
a/dev-db/sqlite/files/sqlite-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch 
b/dev-db/sqlite/files/sqlite-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch
new file mode 100644
index 000000000000..b1f1b6a3aa81
--- /dev/null
+++ b/dev-db/sqlite/files/sqlite-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch
@@ -0,0 +1,31 @@
+From 0f2389e42ec65fd925e1bce608f382f3b35ee0f6 Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Sat, 25 Jan 2025 12:10:24 +0000
+Subject: [PATCH] hwtime.h: Don't use rdtsc on i486
+
+If -DSQLITE_ENABLE_STMT_SCANSTATUS is passed, rdtsc is used for profiling
+purposes, but that's not available on i486 CPUs (e.g. Soekris 4501 / AMD Elan
+in the linked bug).
+
+Just look for i586 instead of i386. For the i386/i486 case, it's fine if we
+use the stub implementation. This feels cleaner than toggling functionality
+in the ebuild, even if it's unlikely anyone on i486 is going to use that.
+
+Thanks to amonakov who found the problem quickly and the relevant part of 
SQLite.
+
+Bug: https://bugs.gentoo.org/948671
+Signed-off-by: Sam James <[email protected]>
+--- a/src/hwtime.h
++++ b/src/hwtime.h
+@@ -24,7 +24,7 @@
+ */
+ #if !defined(__STRICT_ANSI__) && \
+     (defined(__GNUC__) || defined(_MSC_VER)) && \
+-    (defined(i386) || defined(__i386__) || defined(_M_IX86))
++    (defined(i586) || defined(__i586__) || defined(_M_IX86))
+ 
+   #if defined(__GNUC__)
+ 
+-- 
+2.48.1
+

diff --git a/dev-db/sqlite/sqlite-3.47.2.ebuild 
b/dev-db/sqlite/sqlite-3.47.2-r1.ebuild
similarity index 99%
rename from dev-db/sqlite/sqlite-3.47.2.ebuild
rename to dev-db/sqlite/sqlite-3.47.2-r1.ebuild
index ca490c5917e3..044a48ee68f5 100644
--- a/dev-db/sqlite/sqlite-3.47.2.ebuild
+++ b/dev-db/sqlite/sqlite-3.47.2-r1.ebuild
@@ -53,6 +53,7 @@ fi
 PATCHES=(
        "${FILESDIR}"/${PN}-3.45.1-ppc64-ptr.patch
        "${FILESDIR}"/${PN}-3.47.1-buildtclext.patch
+       "${FILESDIR}"/${PN}-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch
 )
 
 _fossil_fetch() {

diff --git a/dev-db/sqlite/sqlite-3.48.0.ebuild 
b/dev-db/sqlite/sqlite-3.48.0-r1.ebuild
similarity index 99%
rename from dev-db/sqlite/sqlite-3.48.0.ebuild
rename to dev-db/sqlite/sqlite-3.48.0-r1.ebuild
index d5b15dc53f6c..ffb79ecc5f1d 100644
--- a/dev-db/sqlite/sqlite-3.48.0.ebuild
+++ b/dev-db/sqlite/sqlite-3.48.0-r1.ebuild
@@ -49,6 +49,10 @@ else
        BDEPEND+=" app-arch/unzip"
 fi
 
+PATCHES=(
+       "${FILESDIR}"/${PN}-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch
+)
+
 _fossil_fetch() {
        local distdir="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}"
        local repo_id="${1}"

diff --git a/dev-db/sqlite/sqlite-9999.ebuild b/dev-db/sqlite/sqlite-9999.ebuild
index 53686a767f9b..e0fe683ea625 100644
--- a/dev-db/sqlite/sqlite-9999.ebuild
+++ b/dev-db/sqlite/sqlite-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -50,6 +50,10 @@ else
        BDEPEND+=" app-arch/unzip"
 fi
 
+PATCHES=(
+       "${FILESDIR}"/${PN}-3.47.2-hwtime.h-Don-t-use-rdtsc-on-i486.patch
+)
+
 _fossil_fetch() {
        local distdir="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}"
        local repo_id="${1}"

Reply via email to