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] 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