Commit 1f696d60 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

pgo: Make chrome_pgo_phase have an effect on all files, not just files in the chrome target.

Bug: 1056189
Change-Id: Iee607dda6c4788d836115c53e43c5c93f63486a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078426
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarSébastien Marchand <sebmarchand@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745196}
parent 02387044
...@@ -436,6 +436,7 @@ default_compiler_configs = [ ...@@ -436,6 +436,7 @@ default_compiler_configs = [
"//build/config/compiler:runtime_library", "//build/config/compiler:runtime_library",
"//build/config/compiler:thin_archive", "//build/config/compiler:thin_archive",
"//build/config/compiler:default_init_stack_vars", "//build/config/compiler:default_init_stack_vars",
"//build/config/compiler/pgo:default_pgo_flags",
"//build/config/coverage:default_coverage", "//build/config/coverage:default_coverage",
"//build/config/sanitizers:default_sanitizer_flags", "//build/config/sanitizers:default_sanitizer_flags",
] ]
......
...@@ -5,24 +5,22 @@ ...@@ -5,24 +5,22 @@
import("//build/config/clang/clang.gni") import("//build/config/clang/clang.gni")
import("//build/config/compiler/compiler.gni") import("//build/config/compiler/compiler.gni")
import("//build/config/compiler/pgo/pgo.gni") import("//build/config/compiler/pgo/pgo.gni")
import("//build/toolchain/toolchain.gni")
# Configuration that enables PGO instrumentation. # Configuration that enables PGO instrumentation.
config("pgo_instrumentation_flags") { config("pgo_instrumentation_flags") {
visibility = [ ":default_pgo_flags" ] visibility = [ ":default_pgo_flags" ]
cflags = []
ldflags = []
# Only add flags when chrome_pgo_phase == 1, so that variables we would use # 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. # are not required to be defined when we're not actually using PGO.
if (chrome_pgo_phase == 1) { if (chrome_pgo_phase == 1 && is_clang && use_lld && !is_nacl &&
if (is_clang) { is_a_target_toolchain) {
cflags = [ "-fprofile-instr-generate" ] cflags = [ "-fprofile-instr-generate" ]
if (!is_win) { if (!is_win) {
# Windows directly calls link.exe instead of the compiler driver when # Windows directly calls link.exe instead of the compiler driver when
# linking, and embeds the path to the profile runtime library as # linking, and embeds the path to the profile runtime library as
# dependent library into each object file. # dependent library into each object file.
ldflags += [ "-fprofile-instr-generate" ] ldflags = [ "-fprofile-instr-generate" ]
}
} }
} }
} }
...@@ -30,25 +28,22 @@ config("pgo_instrumentation_flags") { ...@@ -30,25 +28,22 @@ config("pgo_instrumentation_flags") {
# Configuration that enables optimization using profile data. # Configuration that enables optimization using profile data.
config("pgo_optimization_flags") { config("pgo_optimization_flags") {
visibility = [ ":default_pgo_flags" ] visibility = [ ":default_pgo_flags" ]
cflags = []
ldflags = []
# Only add flags when chrome_pgo_phase == 2, so that variables we would use # 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. # are not required to be defined when we're not actually using PGO.
if (chrome_pgo_phase == 2) { if (chrome_pgo_phase == 2 && is_clang && use_lld && !is_nacl &&
if (is_clang) { is_a_target_toolchain) {
assert(pgo_data_path != "", assert(pgo_data_path != "",
"Please set pgo_data_path to point at the profile data") "Please set pgo_data_path to point at the profile data")
cflags += [ cflags += [
"-fprofile-instr-use=$pgo_data_path", "-fprofile-instr-use=$pgo_data_path",
# It's possible to have some profile data legitimately missing, # It's possible to have some profile data legitimately missing,
# and at least some profile data always ends up being considered # and at least some profile data always ends up being considered
# out of date, so make sure we don't error for those cases. # out of date, so make sure we don't error for those cases.
"-Wno-profile-instr-unprofiled", "-Wno-profile-instr-unprofiled",
"-Wno-error=profile-instr-out-of-date", "-Wno-error=profile-instr-out-of-date",
] ]
}
} }
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import("//build/config/chrome_build.gni") import("//build/config/chrome_build.gni")
import("//build/config/compiler/compiler.gni") import("//build/config/compiler/compiler.gni")
import("//build/config/compiler/pgo/pgo.gni")
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/config/locales.gni") import("//build/config/locales.gni")
import("//build/config/sanitizers/sanitizers.gni") import("//build/config/sanitizers/sanitizers.gni")
...@@ -146,16 +145,6 @@ if (!is_android && !is_mac) { ...@@ -146,16 +145,6 @@ if (!is_android && !is_mac) {
output_name = "chrome" output_name = "chrome"
} }
if (!is_win || is_clang) {
# Normally, we need to pass specific flags to the linker to
# create an executable that gathers profile data. However, when
# using MSVC, we need to make sure we *don't* pass /GENPROFILE
# when linking without generating any code, or else the linker
# will give us fatal error LNK1264. So we add the PGO flags
# on all configurations, execpt MSVC on Windows.
configs += [ "//build/config/compiler/pgo:default_pgo_flags" ]
}
# Because the sources list varies so significantly per-platform, generally # Because the sources list varies so significantly per-platform, generally
# each platform lists its own files rather than relying on filtering or # each platform lists its own files rather than relying on filtering or
# removing unused files. # removing unused files.
...@@ -468,7 +457,6 @@ if (is_win) { ...@@ -468,7 +457,6 @@ if (is_win) {
configs -= [ "//build/config/win:default_incremental_linking" ] configs -= [ "//build/config/win:default_incremental_linking" ]
configs += [ "//build/config/win:no_incremental_linking" ] configs += [ "//build/config/win:no_incremental_linking" ]
} }
configs += [ "//build/config/compiler/pgo:default_pgo_flags" ]
} }
} }
copy("copy_first_run") { copy("copy_first_run") {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment