diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/libwebrtc/build/config/compiler/pgo | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/build/config/compiler/pgo')
-rw-r--r-- | third_party/libwebrtc/build/config/compiler/pgo/BUILD.gn | 100 | ||||
-rw-r--r-- | third_party/libwebrtc/build/config/compiler/pgo/pgo.gni | 25 |
2 files changed, 125 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/config/compiler/pgo/BUILD.gn b/third_party/libwebrtc/build/config/compiler/pgo/BUILD.gn new file mode 100644 index 0000000000..3e8502ed77 --- /dev/null +++ b/third_party/libwebrtc/build/config/compiler/pgo/BUILD.gn @@ -0,0 +1,100 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/chromeos/ui_mode.gni") +import("//build/config/clang/clang.gni") +import("//build/config/compiler/compiler.gni") +import("//build/config/compiler/pgo/pgo.gni") +import("//build/toolchain/toolchain.gni") + +# Configuration that enables PGO instrumentation. +config("pgo_instrumentation_flags") { + visibility = [ ":default_pgo_flags" ] + + # Only add flags when chrome_pgo_phase == 1, so that variables we would use + # are not required to be defined when we're not actually using PGO. + if (chrome_pgo_phase == 1 && is_clang && !is_nacl && is_a_target_toolchain) { + cflags = [ "-fprofile-generate" ] + if (!is_win) { + # Windows directly calls link.exe instead of the compiler driver when + # linking, and embeds the path to the profile runtime library as + # dependent library into each object file. + ldflags = [ "-fprofile-generate" ] + } + } +} + +# Configuration that enables optimization using profile data. +config("pgo_optimization_flags") { + visibility = [ ":default_pgo_flags" ] + + # Only add flags when chrome_pgo_phase == 2, so that variables we would use + # are not required to be defined when we're not actually using PGO. + if (chrome_pgo_phase == 2 && is_clang && !is_nacl && is_a_target_toolchain) { + _pgo_target = "" + + # There are txt files used by //tools/update_pgo_profiles.py to decide which + # profiles to use, adding them as inputs so that analyzer recognizes the + # dependencies. + inputs = [] + + if (is_win) { + if (target_cpu == "x64") { + _pgo_target = "win64" + inputs = [ "//chrome/build/win64.pgo.txt" ] + } else { + _pgo_target = "win32" + inputs = [ "//chrome/build/win32.pgo.txt" ] + } + } else if (is_mac) { + _pgo_target = "mac" + inputs = [ "//chrome/build/mac.pgo.txt" ] + } else if (is_linux || is_chromeos_lacros) { + _pgo_target = "linux" + inputs = [ "//chrome/build/linux.pgo.txt" ] + } + + if (pgo_data_path == "" && _pgo_target != "") { + pgo_data_path = rebase_path(exec_script("//tools/update_pgo_profiles.py", + [ + "--target", + _pgo_target, + "get_profile_path", + ], + "value"), + root_build_dir) + } + assert(pgo_data_path != "", + "Please set pgo_data_path to point at the profile data") + cflags = [ + "-fprofile-instr-use=$pgo_data_path", + + # It's possible to have some profile data legitimately missing, + # and at least some profile data always ends up being considered + # out of date, so make sure we don't error for those cases. + "-Wno-profile-instr-unprofiled", + "-Wno-profile-instr-out-of-date", + + # Some hashing conflict results in a lot of warning like this when doing + # a PGO build: + # warning: foo.cc: Function control flow change detected (hash mismatch) + # [-Wbackend-plugin] + # See https://crbug.com/978401 + "-Wno-backend-plugin", + ] + } +} + +# Applies flags necessary when profile-guided optimization is used. +# Flags are only added if PGO is enabled, so that this config is safe to +# include by default. +config("default_pgo_flags") { + if (chrome_pgo_phase == 0) { + # Nothing. This config should be a no-op when chrome_pgo_phase == 0. + } else if (chrome_pgo_phase == 1) { + configs = [ ":pgo_instrumentation_flags" ] + } else if (chrome_pgo_phase == 2) { + configs = [ ":pgo_optimization_flags" ] + } +} diff --git a/third_party/libwebrtc/build/config/compiler/pgo/pgo.gni b/third_party/libwebrtc/build/config/compiler/pgo/pgo.gni new file mode 100644 index 0000000000..c053eb530b --- /dev/null +++ b/third_party/libwebrtc/build/config/compiler/pgo/pgo.gni @@ -0,0 +1,25 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/chromecast_build.gni") +import("//build/config/chromeos/ui_mode.gni") + +declare_args() { + # Specify the current PGO phase. + # Here's the different values that can be used: + # 0 : Means that PGO is turned off. + # 1 : Used during the PGI (instrumentation) phase. + # 2 : Used during the PGO (optimization) phase. + chrome_pgo_phase = 0 + if (is_official_build && + # TODO(crbug.com/1052397): Remove chromeos_is_browser_only once + # target_os switch for lacros-chrome is completed. + (is_win || is_mac || + (is_linux && !chromeos_is_browser_only && !is_chromecast))) { + chrome_pgo_phase = 2 + } + + # When using chrome_pgo_phase = 2, read profile data from this path. + pgo_data_path = "" +} |