summaryrefslogtreecommitdiff
path: root/chromium/build/config/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/build/config/compiler')
-rw-r--r--chromium/build/config/compiler/BUILD.gn77
-rw-r--r--chromium/build/config/compiler/compiler.gni14
-rw-r--r--chromium/build/config/compiler/pgo/BUILD.gn25
-rw-r--r--chromium/build/config/compiler/pgo/pgo.gni3
4 files changed, 86 insertions, 33 deletions
diff --git a/chromium/build/config/compiler/BUILD.gn b/chromium/build/config/compiler/BUILD.gn
index 01d97a3605f..6e219b3994e 100644
--- a/chromium/build/config/compiler/BUILD.gn
+++ b/chromium/build/config/compiler/BUILD.gn
@@ -121,9 +121,6 @@ declare_args() {
thin_lto_enable_optimizations =
(is_chromeos || is_android || is_win) && is_official_build
- # 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 makes behavior of uninitialized memory bugs consistent,
@@ -143,6 +140,15 @@ declare_args() {
# reduce TLB misses which gives performance improvement on cpu usage.
# The gold linker by default has text section splitting enabled.
use_text_section_splitting = false
+
+ # Token limits may not be accurate for build configs not covered by the CQ,
+ # so only enable them by default for mainstream build configs.
+ enable_wmax_tokens =
+ !is_official_build &&
+ (is_mac || (is_linux && !is_chromeos && target_cpu == "x64") ||
+ (is_win && target_cpu == "x86") || (is_win && target_cpu == "x64") ||
+ (is_android && target_cpu == "arm") ||
+ (is_android && target_cpu == "arm64"))
}
declare_args() {
@@ -323,14 +329,16 @@ config("compiler") {
}
}
- if (is_official_build || force_local_build_id) {
- # Explicitly pass --build-id to ld. Compilers used to always pass this
- # implicitly but don't any more (in particular clang when built without
- # ENABLE_LINKER_BUILD_ID=ON). The crash infrastructure does need a build
- # id, so explicitly enable it in official builds. It's not needed in
- # unofficial builds and computing it does slow down the link, so go with
- # faster links in unofficial builds.
+ # Explicitly pass --build-id to ld. Compilers used to always pass this
+ # implicitly but don't any more (in particular clang when built without
+ # ENABLE_LINKER_BUILD_ID=ON).
+ if (is_official_build) {
+ # The sha1 build id has lower risk of collision but is more expensive to
+ # compute, so only use it in the official build to avoid slowing down
+ # links.
ldflags += [ "-Wl,--build-id=sha1" ]
+ } else if (current_os != "aix") {
+ ldflags += [ "-Wl,--build-id" ]
}
if (!is_android) {
@@ -543,6 +551,23 @@ config("compiler") {
}
}
+ # C++17 removes trigraph support, so preemptively disable trigraphs. This is
+ # especially useful given the collision with ecmascript's logical assignment
+ # operators: https://github.com/tc39/proposal-logical-assignment
+ if (is_clang) {
+ # clang-cl disables trigraphs by default
+ if (!is_win) {
+ # The gnu variants of C++11 and C++14 already disable trigraph support,
+ # but when building with clang, we use -std=c++11 / -std=c++14, which
+ # enables trigraph support: override that here.
+ cflags_cc += [ "-fno-trigraphs" ]
+ }
+
+ # Don't warn that trigraphs are ignored, since trigraphs are disabled
+ # anyway.
+ cflags_cc += [ "-Wno-trigraphs" ]
+ }
+
if (is_mac) {
# The system libc++ on Mac doesn't have aligned allocation in C++17.
defines += [ "_LIBCPP_HAS_NO_ALIGNED_ALLOCATION" ]
@@ -1468,14 +1493,6 @@ config("default_warnings") {
cflags += [ "-Wno-nonportable-include-path" ]
}
- if (target_os == "chromeos") {
- # Disable clang warnings of "-Wmax-tokens" because CQ doesn't cover all CrOS use
- # cases, so it's too late to fix when the error goes to CrOS side.
- # Also nacl toolchain doesn't recognize the flag, so avoid passing to nacl clang
- # See crbug.com/1079053 for more details.
- cflags += [ "-Wno-max-tokens" ]
- }
-
if (current_toolchain == host_toolchain || !use_xcode_clang) {
# Flags NaCl (Clang 3.7) and Xcode 9.2 (Clang clang-900.0.39.2) do not
# recognize.
@@ -1504,6 +1521,13 @@ config("default_warnings") {
# TODO(https://crbug.com/995993): Clean up and enable.
"-Wno-implicit-fallthrough",
]
+
+ if (enable_wmax_tokens) {
+ cflags += [ "-Wmax-tokens" ]
+ } else {
+ # TODO(https://crbug.com/1049569): Remove after Clang 87b235db.
+ cflags += [ "-Wno-max-tokens" ]
+ }
}
}
}
@@ -1970,6 +1994,14 @@ config("optimize") {
} else {
cflags = [ "-Os" ] + common_optimize_on_cflags
}
+ } else if (is_chromeos) {
+ # TODO(gbiv): This is partially favoring size over speed. CrOS exclusively
+ # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
+ # any cost" (AKA -Oz). It'd be nice to:
+ # - Make `optimize_for_size` apply to all platforms where we're optimizing
+ # for size by default (so, also Windows)
+ # - Investigate -Oz here, maybe just for ARM?
+ cflags = [ "-Os" ] + common_optimize_on_cflags
} else {
cflags = [ "-O2" ] + common_optimize_on_cflags
}
@@ -1998,6 +2030,12 @@ config("no_optimize") {
} else {
cflags = [ "-Os" ] + common_optimize_on_cflags
}
+
+ if (!is_component_build) {
+ # Required for library partitions. Without this all symbols just end up
+ # in the base partition.
+ ldflags = [ "-Wl,--gc-sections" ]
+ }
} else if (is_fuchsia) {
# On Fuchsia, we optimize for size here to reduce the size of debug build
# packages so they can be run in a KVM. See crbug.com/910243 for details.
@@ -2249,7 +2287,8 @@ config("symbols") {
cflags += [ "-g2" ]
}
- if (is_clang && !is_nacl && !use_xcode_clang) {
+ # TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
+ if (is_clang && !is_nacl && !use_xcode_clang && !is_mac && !is_ios) {
cflags += [
"-Xclang",
"-debug-info-kind=constructor",
diff --git a/chromium/build/config/compiler/compiler.gni b/chromium/build/config/compiler/compiler.gni
index bd21ffe5dc3..ef8cc5fdfd5 100644
--- a/chromium/build/config/compiler/compiler.gni
+++ b/chromium/build/config/compiler/compiler.gni
@@ -110,7 +110,13 @@ declare_args() {
# Determine whether to enable or disable frame pointers, based on the platform
# and build arguments.
-if (is_mac || is_ios || is_linux) {
+if (is_chromeos) {
+ # ChromeOS generally prefers frame pointers, to support CWP.
+ # However, Clang does not currently generate usable frame pointers in ARM
+ # 32-bit builds (https://bugs.llvm.org/show_bug.cgi?id=18505) so disable them
+ # there to avoid the unnecessary overhead.
+ enable_frame_pointers = current_cpu != "arm"
+} else if (is_mac || is_ios || is_linux) {
enable_frame_pointers = true
} else if (is_win) {
# 64-bit Windows ABI doesn't support frame pointers.
@@ -119,12 +125,6 @@ if (is_mac || is_ios || is_linux) {
} else {
enable_frame_pointers = true
}
-} else if (is_chromeos) {
- # ChromeOS generally prefers frame pointers, to support CWP.
- # However, Clang does not currently generate usable frame pointers in ARM
- # 32-bit builds (https://bugs.llvm.org/show_bug.cgi?id=18505) so disable them
- # there to avoid the unnecessary overhead.
- enable_frame_pointers = current_cpu != "arm"
} else if (is_android) {
enable_frame_pointers =
enable_profiling ||
diff --git a/chromium/build/config/compiler/pgo/BUILD.gn b/chromium/build/config/compiler/pgo/BUILD.gn
index 84c941faaf6..20f01f3cafa 100644
--- a/chromium/build/config/compiler/pgo/BUILD.gn
+++ b/chromium/build/config/compiler/pgo/BUILD.gn
@@ -14,16 +14,12 @@ config("pgo_instrumentation_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) {
- # TODO(sebmarchand): Add a GN flag that allows setting the PGO profile
- # name or find a way to remove use {target_name} in the filename?
- # This uses the "%m" specifier to allow concurrent runs of the
- # instrumented image.
- cflags = [ "-fprofile-instr-generate=%m.profraw" ]
+ 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-instr-generate" ]
+ ldflags = [ "-fprofile-generate" ]
}
}
}
@@ -37,14 +33,22 @@ config("pgo_optimization_flags") {
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" ]
}
if (pgo_data_path == "" && _pgo_target != "") {
@@ -66,7 +70,14 @@ config("pgo_optimization_flags") {
# 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-error=profile-instr-out-of-date",
+ "-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",
]
}
}
diff --git a/chromium/build/config/compiler/pgo/pgo.gni b/chromium/build/config/compiler/pgo/pgo.gni
index a0cbb6acc05..f616b88a052 100644
--- a/chromium/build/config/compiler/pgo/pgo.gni
+++ b/chromium/build/config/compiler/pgo/pgo.gni
@@ -9,6 +9,9 @@ declare_args() {
# 1 : Used during the PGI (instrumentation) phase.
# 2 : Used during the PGO (optimization) phase.
chrome_pgo_phase = 0
+ if (is_official_build && (is_win || is_mac)) {
+ chrome_pgo_phase = 2
+ }
# When using chrome_pgo_phase = 2, read profile data from this path.
pgo_data_path = ""