summaryrefslogtreecommitdiffstats
path: root/chromium/build/config/compiler/BUILD.gn
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/build/config/compiler/BUILD.gn')
-rw-r--r--chromium/build/config/compiler/BUILD.gn72
1 files changed, 58 insertions, 14 deletions
diff --git a/chromium/build/config/compiler/BUILD.gn b/chromium/build/config/compiler/BUILD.gn
index 352cb646dd5..93ad68a613b 100644
--- a/chromium/build/config/compiler/BUILD.gn
+++ b/chromium/build/config/compiler/BUILD.gn
@@ -104,6 +104,15 @@ declare_args() {
clang_use_default_sample_profile = build_with_chromium && is_official_build &&
(is_android || is_desktop_linux)
+ # This configuration is used to select a default profile in Chrome OS based on
+ # the microarchitectures we are using. This is only used if
+ # clang_use_default_sample_profile is true and clang_sample_profile_path is
+ # empty.
+ chromeos_afdo_platform = "silvermont"
+
+ # Emit debug information for profiling wile building with clang.
+ clang_emit_debug_info_for_profiling = false
+
# Turn this on to have the compiler output extra timing information.
compiler_timing = false
@@ -128,6 +137,12 @@ declare_args() {
# By default only the binaries in official builds get build IDs.
force_local_build_id = false
+
+ # Initialize all local variables with a pattern. This flag will fill uninitialized
+ # floating-point types (and 32-bit pointers) with 0xFF and the rest with 0xAA.
+ # This allows to make behavior of uninitialized memory bugs consistent, easier to
+ # recognize when debugging and often just to crash immediately.
+ init_stack_vars = false
}
declare_args() {
@@ -591,7 +606,7 @@ config("compiler") {
# files on Windows (https://crbug.com/871962).
ldflags += [
"/opt:lldlto=" + lto_opt_level,
- "/opt:lldltojobs=8",
+ "/opt:lldltojobs=" + max_jobs_per_link,
# Experimentally determined to yield a reasonable trade-off between
# build time, run-time performance, and binary size.
@@ -604,7 +619,7 @@ config("compiler") {
# linker jobs. This is still suboptimal to a potential dynamic
# resource allocation scheme, but should be good enough.
if (use_lld) {
- ldflags += [ "-Wl,--thinlto-jobs=8" ]
+ ldflags += [ "-Wl,--thinlto-jobs=" + max_jobs_per_link ]
# Caching on Chrome OS materially slows the PFQ down; disable it until
# we can figure out why. (crbug.com/964328)
@@ -620,7 +635,7 @@ config("compiler") {
]
}
} else {
- ldflags += [ "-Wl,-plugin-opt,jobs=8" ]
+ ldflags += [ "-Wl,-plugin-opt,jobs=" + max_jobs_per_link ]
}
if (use_lld) {
@@ -1504,9 +1519,6 @@ config("default_warnings") {
# TODO(https://crbug.com/989932): Evaluate and possibly enable.
"-Wno-implicit-int-float-conversion",
- # TODO(https://crbug.com/995200): Clean up and enable.
- "-Wno-xor-used-as-pow",
-
# TODO(https://crbug.com/999871): Decide if we want to clean up the
# codebase or just disable this. Doesn't seem super useful, but
# also fires in only 4 files.
@@ -1517,7 +1529,11 @@ config("default_warnings") {
# TODO(https://crbug.com/999886): Clean up, enable.
"-Wno-final-dtor-non-final-class",
+
+ # TODO(https://crbug.com/1002945): Evaluate and possibly enable.
+ "-Wno-sizeof-array-div",
]
+
cflags_c += [
# TODO(https://crbug.com/995993): Clean up and enable.
"-Wno-implicit-fallthrough",
@@ -1879,11 +1895,7 @@ if (is_win) {
# TODO(thakis): Remove is_clang here, https://crbug.com/598772
if (!use_lld && !is_clang) {
- common_optimize_on_ldflags += [
- # Set the number of LTCG code-gen threads to eight. The default is four.
- # This gives a 5-10% link speedup.
- "/cgthreads:8",
- ]
+ common_optimize_on_ldflags += [ "/cgthreads:" + max_jobs_per_link ]
if (use_incremental_wpo) {
# Incremental Link-time code generation.
common_optimize_on_ldflags += [ "/LTCG:INCREMENTAL" ]
@@ -2027,6 +2039,12 @@ config("no_optimize") {
"/Ob0", # Disable all inlining (on by default).
"/GF", # Enable string pooling (off by default).
]
+
+ if (target_cpu == "arm64") {
+ # Disable omitting frame pointers for no_optimize build because stack
+ # trace on Windows ARM64 relies on it.
+ cflags += [ "/Oy-" ]
+ }
} else if (is_android && !android_full_debug) {
# On Android we kind of optimize some things that don't affect debugging
# much even when optimization is disabled to get the binary size down.
@@ -2153,9 +2171,19 @@ if (is_clang && is_a_target_toolchain) {
} else if (clang_use_default_sample_profile) {
assert(build_with_chromium,
"Our default profiles currently only apply to Chromium")
- assert(is_android || is_desktop_linux,
+ assert(is_android || is_desktop_linux || is_chromeos,
"The current platform has no default profile")
- _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+ if (is_android || is_desktop_linux) {
+ _clang_sample_profile = "//chrome/android/profiles/afdo.prof"
+ } else {
+ assert(
+ chromeos_afdo_platform == "silvermont" ||
+ chromeos_afdo_platform == "airmont" ||
+ chromeos_afdo_platform == "broadwell",
+ "Only silvermont, airmont and broadwell are valid Chrome OS profiles.")
+ _clang_sample_profile =
+ "//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
+ }
}
}
@@ -2175,10 +2203,18 @@ config("afdo_optimize_size") {
# config to allow AFDO to be disabled per-target.
config("afdo") {
if (is_clang) {
+ cflags = []
+ if (clang_emit_debug_info_for_profiling) {
+ # Add the following flags to generate debug info for profiling.
+ cflags += [
+ "-fdebug-info-for-profiling",
+ "-gline-tables-only",
+ ]
+ }
if (_clang_sample_profile != "") {
rebased_clang_sample_profile =
rebase_path(_clang_sample_profile, root_build_dir)
- cflags = [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
+ cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
inputs = [
_clang_sample_profile,
]
@@ -2467,3 +2503,11 @@ if (is_win || is_android || is_chromeos) {
}
}
}
+
+# Initialize all variables on the stack if needed.
+config("default_init_stack_vars") {
+ cflags = []
+ if (init_stack_vars && is_clang && !is_nacl && !using_sanitizer) {
+ cflags += [ "-ftrivial-auto-var-init=pattern" ]
+ }
+}