From 3d9d6d1ce6eeebc005ed651b0367d12e5cabe8e4 Mon Sep 17 00:00:00 2001 From: zzhang85 <925889398@qq.com> Date: Sat, 10 May 2025 11:08:10 +0800 Subject: [PATCH 1/2] Apply PGO optimization on SQLite Signed-off-by: zzhang85 <925889398@qq.com> --- BUILD.gn | 17 +++++++++++++++++ bundle.json | 6 +++++- sqlite.gni | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 3b03c37..99a516f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -154,6 +154,23 @@ ohos_shared_library("sqlite") { "openssl:libcrypto_shared", ] } + if (is_ohos && is_clang && enhanced_opt && + (target_cpu == "arm" || target_cpu == "arm64")) { + ldflags += [ "-Wl,-Bsymbolic" ] + if (sqlite_feature_enable_pgo) { + cflags_c += [ + "-fprofile-use=" + + rebase_path("${sqlite_feature_pgo_path}/libsqlite.profdata", + root_build_dir), + "-Wno-error=backend_plugin", + "-Wno-profile-instr-out-of-date", + "-Wno-profile-instr-unprofiled", + ] + if(target_cpu == "arm64" && enable_enhanced_opt) { + ldflags += [ "-Wl,--aarch64-inline-plt" ] + } + } + } } ohos_executable("sqlite3") { diff --git a/bundle.json b/bundle.json index b733d95..910ada0 100644 --- a/bundle.json +++ b/bundle.json @@ -14,7 +14,11 @@ "name": "sqlite", "subsystem": "thirdparty", "syscap": [], - "features": [ "sqlite_support_check_pages" ], + "features": [ + "sqlite_support_check_pages", + "sqlite_feature_enable_pgo", + "sqlite_feature_pgo_path" + ], "adapted_system_type": [ "standard" ], "rom": "2200KB", "ram": "1024KB", diff --git a/sqlite.gni b/sqlite.gni index 0f9c791..e26e462 100644 --- a/sqlite.gni +++ b/sqlite.gni @@ -13,4 +13,6 @@ declare_args() { sqlite_support_check_pages = false + sqlite_feature_enable_pgo = false + sqlite_feature_pgo_path = "" } -- Gitee From 6754023c6f8f73f332ef1932cee86a6c374ce1bf Mon Sep 17 00:00:00 2001 From: qianyong325 Date: Thu, 22 May 2025 11:44:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?sqlite=E6=94=AF=E6=8C=81hdc=20Signed-off-by?= =?UTF-8?q?:=20qianyong325=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 35 +++++++------------ bundle.json | 10 +++--- patch/0007-DatabaseDebugTool.patch | 35 +++++++++++++++++++ ...h => 0008-Bugfix-on-current-version.patch} | 0 sqlite.gni | 2 -- 5 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 patch/0007-DatabaseDebugTool.patch rename patch/{0007-Bugfix-on-current-version.patch => 0008-Bugfix-on-current-version.patch} (100%) diff --git a/BUILD.gn b/BUILD.gn index 6dd8294..0c72d7b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -112,6 +112,7 @@ ohos_shared_library("sqlite") { "SQLITE_DIRECT_OVERFLOW_READ", "SQLITE_HAS_CODEC", "SQLITE_EXPORT_SYMBOLS", + "SQLITE_API=SQLITE_EXPORT", "SQLITE_SHARED_BLOCK_OPTIMIZATION", "SQLITE_CODEC_ATTACH_CHANGED", "SQLITE_ENABLE_DROPTABLE_CALLBACK", @@ -155,31 +156,11 @@ ohos_shared_library("sqlite") { "openssl:libcrypto_shared", ] } - if (is_ohos && is_clang && enhanced_opt && - (target_cpu == "arm" || target_cpu == "arm64")) { - ldflags += [ "-Wl,-Bsymbolic" ] - if (sqlite_feature_enable_pgo) { - cflags_c += [ - "-fprofile-use=" + - rebase_path("${sqlite_feature_pgo_path}/libsqlite.profdata", - root_build_dir), - "-Wno-error=backend_plugin", - "-Wno-profile-instr-out-of-date", - "-Wno-profile-instr-unprofiled", - ] - if(target_cpu == "arm64" && enable_enhanced_opt) { - ldflags += [ "-Wl,--aarch64-inline-plt" ] - } - } - } } ohos_executable("sqlite3") { include_dirs = [ "$sqlite_patched_dir/include" ] - sources = [ - "$sqlite_patched_dir/src/shell.c", - "$sqlite_patched_dir/src/sqlite3.c", - ] + sources = [ "$sqlite_patched_dir/src/shell.c" ] defines = [ "NDEBUG=1", @@ -210,10 +191,20 @@ ohos_executable("sqlite3") { cflags = [ "-Wno-error=implicit-function-declaration", + "-Wno-macro-redefined", "-Wno-implicit-fallthrough", ] - deps = [ "//third_party/sqlite/patch:apply_patch" ] + deps = [ + ":sqlite", + "//third_party/sqlite/patch:apply_patch", + ] + + public_configs = [ ":sqlite_config" ] + external_deps = [ "c_utils:utils" ] + configs = [ ":sqlite3_private_config" ] + part_name = "sqlite" + subsystem_name = "thirdparty" } if (is_mingw || is_mac) { diff --git a/bundle.json b/bundle.json index a72e6fb..ac0ddba 100644 --- a/bundle.json +++ b/bundle.json @@ -14,11 +14,7 @@ "name": "sqlite", "subsystem": "thirdparty", "syscap": [], - "features": [ - "sqlite_support_check_pages", - "sqlite_feature_enable_pgo", - "sqlite_feature_pgo_path" - ], + "features": [ "sqlite_support_check_pages" ], "adapted_system_type": [ "standard" ], "rom": "2200KB", "ram": "1024KB", @@ -35,6 +31,7 @@ "build": { "sub_component": [ "//third_party/sqlite:sqlite", + "//third_party/sqlite:sqlite3", "//third_party/sqlite:sqliteicu" ], "inner_kits": [ @@ -50,6 +47,9 @@ }, { "name": "//third_party/sqlite:sqliteicu" + }, + { + "name": "//third_party/sqlite:sqlite3" } ], "test": [ diff --git a/patch/0007-DatabaseDebugTool.patch b/patch/0007-DatabaseDebugTool.patch new file mode 100644 index 0000000..3e2ac23 --- /dev/null +++ b/patch/0007-DatabaseDebugTool.patch @@ -0,0 +1,35 @@ +diff --git a/src/shell.c b/src/shell.c +index 7fb190e..07fe381 100644 +--- a/src/shell.c ++++ b/src/shell.c +@@ -119,6 +119,7 @@ typedef unsigned short int u16; + #include + #include + #include "sqlite3.h" ++#include "sqlite3sym.h" + typedef sqlite3_int64 i64; + typedef sqlite3_uint64 u64; + typedef unsigned char u8; +@@ -28874,6 +28875,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ + warnInmemoryDb = 0; + } + #endif ++ // The icu analyzer is enabled by default on the client tool. ++ sqlite3_config(SQLITE_CONFIG_ENABLE_ICU); + + /* Do an initial pass through the command-line argument to locate + ** the name of the database file, the name of the initialization file, +diff --git a/src/sqlite3.c b/src/sqlite3.c +index 7fb290f..0024163 100644 +--- a/src/sqlite3.c ++++ b/src/sqlite3.c +@@ -20,6 +20,9 @@ + ** The content in this amalgamation comes from Fossil check-in + ** f1e31fd9961ac82535a5d0702b127d84de8c. + */ ++#ifndef SQLITE_EXPORT ++#define SQLITE_EXPORT ++#endif + #define SQLITE_CORE 1 + #define SQLITE_AMALGAMATION 1 + #ifndef SQLITE_PRIVATE diff --git a/patch/0007-Bugfix-on-current-version.patch b/patch/0008-Bugfix-on-current-version.patch similarity index 100% rename from patch/0007-Bugfix-on-current-version.patch rename to patch/0008-Bugfix-on-current-version.patch diff --git a/sqlite.gni b/sqlite.gni index e26e462..0f9c791 100644 --- a/sqlite.gni +++ b/sqlite.gni @@ -13,6 +13,4 @@ declare_args() { sqlite_support_check_pages = false - sqlite_feature_enable_pgo = false - sqlite_feature_pgo_path = "" } -- Gitee