From b47c623c3ab7a75621f5739fad0ae169be18d12a Mon Sep 17 00:00:00 2001 From: Prabhdeep Singh Soni Date: Thu, 14 Nov 2024 23:44:35 -0500 Subject: [PATCH] Enable PGO, PLT inlining, and -Bsymbolic Signed-off-by: Bryan Chan --- base/BUILD.gn | 21 +++++++++++++++++++++ bundle.json | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/base/BUILD.gn b/base/BUILD.gn index 82586fb..e4ca743 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -21,6 +21,8 @@ declare_args() { c_utils_debug_log_enabled = false c_utils_feature_intsan = true c_utils_parcel_object_check = true + c_utils_feature_enable_pgo = false + c_utils_feature_pgo_path = "" } config("utils_config") { @@ -228,6 +230,25 @@ ohos_shared_library("utils") { "updater", ] } + if (is_ohos && is_clang && enhanced_opt && + (target_cpu == "arm" || target_cpu == "arm64")) { + if (c_utils_feature_enable_pgo) { + cflags = [ + "-fprofile-use=" + + rebase_path("${c_utils_feature_pgo_path}/libutils.profdata", + root_build_dir), + "-Wno-error=backend-plugin", + "-Wno-profile-instr-out-of-date", + "-Wno-profile-instr-unprofiled", + ] + } + + ldflags = [ "-Wl,-Bsymbolic" ] + if (c_utils_feature_enable_pgo && target_cpu == "arm64" && + enable_enhanced_opt) { + ldflags += [ "-Wl,--aarch64-inline-plt" ] + } + } } ########## modules for `c_utils` in rust ########## diff --git a/bundle.json b/bundle.json index 1d43dbd..3042fa4 100644 --- a/bundle.json +++ b/bundle.json @@ -23,7 +23,9 @@ "c_utils_print_track_at_once", "c_utils_debug_log_enabled", "c_utils_feature_intsan", - "c_utils_parcel_object_check" + "c_utils_parcel_object_check", + "c_utils_feature_enable_pgo", + "c_utils_feature_pgo_path" ], "deps": { "components": [ -- Gitee