Add a config for max optimizations in the GN build.

This emulates optimize=max from GYP. One difference is that this applies for all build types. The GYP one only applied optimize=max for the Official build. I can't think of why this should be the case, and it seems confusing to have such arbitrary official build differences.

R=bbudge@chromium.org

Review URL: https://codereview.chromium.org/138903002

git-svn-id: http://src.chromium.org/svn/trunk/src/build@244839 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
brettw@chromium.org 2014-01-15 06:09:16 +00:00
Родитель e73f1bf025
Коммит c2b3031962
1 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -581,13 +581,26 @@ config("default_warnings") {
}
# Optimization -----------------------------------------------------------------
#
# Note that BUILDCONFIG.gn sets up a variable "default_optimization_config"
# which it will assign to the config it implicitly applies to every target. If
# you want to override the optimization level for your target, remove this
# config (which will expand differently for debug or release builds), and then
# add back the one you want to override it with:
#
# configs -= default_optimization_config
# configs += [ "//build/config/compiler/optimize_max" ]
# Default "optimization on" config. On Windows, this favors size over speed.
#
# IF YOU CHANGE THIS also consider whether optimize_max should be updated.
config("optimize") {
if (is_win) {
cflags = [
"/O2",
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Os", # Favor size over speed.
]
} else {
if (is_ios) {
@ -598,6 +611,7 @@ config("optimize") {
}
}
# Turn off optimizations.
config("no_optimize") {
if (is_win) {
cflags = [
@ -610,6 +624,27 @@ config("no_optimize") {
}
}
# On Windows, turns up the optimization level. This implies whole program
# optimization and link-time code generation which is very expensive and should
# be used sparingly. For non-Windows, this is the same as "optimize".
config("optimize_max") {
if (is_win) {
cflags = [
"/O2",
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Ot", # Favor speed over size.
"/GL", # Whole program optimization.
]
} else {
if (is_ios) {
cflags = [ "-Os" ]
} else {
cflags = [ "-O2" ]
}
}
}
# Symbols ----------------------------------------------------------------------
# TODO(brettw) Since this sets ldflags on Windows which is inherited across