From 31fcfa2e2469dae7aa52b39c4e5698d39afe36d9 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Thu, 23 May 2019 19:55:43 +0200 Subject: [PATCH 1/2] sqlite3: always build a thread-safe library Pull request #9033 showed that there are problems with builds where thread-safe mode is disabled. The binaries still reference functions from libpthread. This commit removes the thread-safe choice for now. Once this is addressed upstream the choice can be added back. Signed-off-by: Sebastian Kemper --- libs/sqlite3/Config-lib.in | 6 ------ libs/sqlite3/Makefile | 7 +++---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/libs/sqlite3/Config-lib.in b/libs/sqlite3/Config-lib.in index aa6357b53..6e7ea18dc 100644 --- a/libs/sqlite3/Config-lib.in +++ b/libs/sqlite3/Config-lib.in @@ -44,10 +44,4 @@ config SQLITE3_SESSION help Enable the session extension (default no). -config SQLITE3_THREADSAFE - bool "Thread-safe library" - default y - help - Build a thread-safe library. - endmenu diff --git a/libs/sqlite3/Makefile b/libs/sqlite3/Makefile index 1ceffa036..059efa6f1 100644 --- a/libs/sqlite3/Makefile +++ b/libs/sqlite3/Makefile @@ -37,8 +37,7 @@ PKG_CONFIG_DEPENDS := \ CONFIG_SQLITE3_LIBEDIT \ CONFIG_SQLITE3_READLINE \ CONFIG_SQLITE3_RTREE \ - CONFIG_SQLITE3_SESSION \ - CONFIG_SQLITE3_THREADSAFE + CONFIG_SQLITE3_SESSION include $(INCLUDE_DIR)/package.mk @@ -105,14 +104,14 @@ CONFIGURE_ARGS += \ --disable-static-shell \ --enable-shared \ --enable-static \ + --enable-threadsafe \ $(if $(CONFIG_SQLITE3_DYNAMIC_EXTENSIONS),--enable-dynamic-extensions,--disable-dynamic-extensions) \ $(if $(CONFIG_SQLITE3_FTS3),--enable-fts3,--disable-fts3) \ $(if $(CONFIG_SQLITE3_FTS3),--enable-fts4,--disable-fts4) \ $(if $(CONFIG_SQLITE3_FTS3),--enable-fts5,--disable-fts5) \ $(if $(CONFIG_SQLITE3_JSON1),--enable-json1,--disable-json1) \ $(if $(CONFIG_SQLITE3_RTREE),--enable-rtree,--disable-rtree) \ - $(if $(CONFIG_SQLITE3_SESSION),--enable-session,--disable-session) \ - $(if $(CONFIG_SQLITE3_THREADSAFE),--enable-threadsafe,--disable-threadsafe) + $(if $(CONFIG_SQLITE3_SESSION),--enable-session,--disable-session) ifeq ($(CONFIG_SQLITE3_LIBEDIT),y) CONFIGURE_ARGS+=--disable-readline From 2573c9c7c1e40ca4c2bc1df0e932dd2a91bf1587 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Thu, 23 May 2019 20:03:00 +0200 Subject: [PATCH 2/2] sqlite3: fix arm endian issue Forum user portuquesa raised a topic (see [1]) about being unable to use Asterisk on his armeb xscale device. We narrowed it down to sqlite3. Asterisk was unable to insert a simple table into its db. In short, sqlite3 assumes little endian for every ARM device. This worked OK for 4 Byte bit (unaligned) access. But once upstream (back in 2015) added a function which accesses 2 Bytes (see [2]) this failed for some (if not all) ARM big endian devices. ARM CPUs are bi-endian for 4 Byte reads but not for 2 Byte reads. This patch fixes the problem by setting the endianness adequately for ARM targets, for both 32 bit and 64 bit varieties. The patch was applied upstream (see [3]). [1] https://forum.openwrt.org/t/solved-asterisk13-or-15-sqlite3-database-problem/36856 [2] https://github.com/sqlite/sqlite/commit/329428e2088aabb1db2dc6e48108b76551405a8e [3] https://www.sqlite.org/src/info/b7aad929619f7043 Signed-off-by: Sebastian Kemper --- libs/sqlite3/Makefile | 2 +- .../patches/01-sqlite-arm-endian.patch | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 libs/sqlite3/patches/01-sqlite-arm-endian.patch diff --git a/libs/sqlite3/Makefile b/libs/sqlite3/Makefile index 059efa6f1..ffa0a68a4 100644 --- a/libs/sqlite3/Makefile +++ b/libs/sqlite3/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sqlite PKG_VERSION:=3270200 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-autoconf-$(PKG_VERSION).tar.gz PKG_HASH:=50c39e85ea28b5ecfdb3f9e860afe9ba606381e21836b2849efca6a0bfe6ef6e diff --git a/libs/sqlite3/patches/01-sqlite-arm-endian.patch b/libs/sqlite3/patches/01-sqlite-arm-endian.patch new file mode 100644 index 000000000..65fe7715b --- /dev/null +++ b/libs/sqlite3/patches/01-sqlite-arm-endian.patch @@ -0,0 +1,21 @@ +--- a/sqlite3.c ++++ b/sqlite3.c +@@ -13920,12 +13920,13 @@ typedef INT16_TYPE LogEst; + ** at run-time. + */ + #ifndef SQLITE_BYTEORDER +-# 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(_M_ARM64) ++# 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) + # define SQLITE_BYTEORDER 1234 +-# elif defined(sparc) || defined(__ppc__) ++# elif defined(sparc) || defined(__ppc__) || \ ++ defined(__ARMEB__) || defined(__AARCH64EB__) + # define SQLITE_BYTEORDER 4321 + # else + # define SQLITE_BYTEORDER 0