Reland^2 "[build] disable C++ optimization for mksnapshot code."

This is a reland of a6b95a6acf

In addition to UBSan, also ASAN needs optimizations.
So this CL doesn't disable optimizations for all sanitizer builds.

Original change's description:
> Reland "[build] disable C++ optimization for mksnapshot code."
>
> This is a reland of cee2f772c7
>
> Original change's description:
> > [build] disable C++ optimization for mksnapshot code.
> >
> > By disabling C++ optimizations for code that's only run in mksnapshot,
> > that is, CSA and Torque-generated code, we can save compile time.
> > I observed up to 2x improvements of compile time for some files,
> > while the mksnapshot time did not increase significantly.
> >
> > Bug: v8:7629
> > Change-Id: I96be2966611b2471b68023e0dd9e351d94f0013c
> > Reviewed-on: https://chromium-review.googlesource.com/c/1460941
> > Reviewed-by: Yang Guo <yangguo@chromium.org>
> > Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> > Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#59585}
>
> Bug: v8:7629
> Change-Id: I8330f93173ab3d7b400e15ea4935bbe8256b250f
> Reviewed-on: https://chromium-review.googlesource.com/c/1473292
> Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#59606}

Bug: v8:7629
Change-Id: I42175c472d8e41345573df81645dfe3accc9d8c4
Reviewed-on: https://chromium-review.googlesource.com/c/1475396
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59632}
This commit is contained in:
Tobias Tebbi 2019-02-14 16:57:21 +01:00 committed by Commit Bot
parent 722f7139e1
commit 6beea97e09
2 changed files with 39 additions and 23 deletions

View File

@ -670,6 +670,32 @@ config("toolchain") {
}
}
config("default_optimization") {
if (is_debug && !v8_optimized_debug) {
configs = [ "//build/config/compiler:no_optimize" ]
} else {
# TODO(crbug.com/621335) Rework this so that we don't have the confusion
# between "optimize_speed" and "optimize_max".
if (((is_posix && !is_android) || is_fuchsia) && !using_sanitizer) {
configs = [ "//build/config/compiler:optimize_speed" ]
} else {
configs = [ "//build/config/compiler:optimize_max" ]
}
}
}
# For code that is only run a few times during the build, C++ optimizations
# are a waste of time.
config("unoptimized_initializer") {
configs = [ ":internal_config" ]
if (using_sanitizer) {
# Some sanitizers rely on optimizations.
configs += [ ":default_optimization" ]
} else {
configs += [ "//build/config/compiler:no_optimize" ]
}
}
# Configs for code coverage with gcov. Separate configs for cflags and ldflags
# to selectively influde cflags in non-test targets only.
config("v8_gcov_coverage_cflags") {
@ -984,7 +1010,8 @@ v8_source_set("torque_generated_initializers") {
]
}
configs = [ ":internal_config" ]
remove_configs = [ v8_path_prefix + ":default_optimization" ]
configs = [ ":unoptimized_initializer" ]
}
action("generate_bytecode_builtins_list") {
@ -1460,7 +1487,8 @@ v8_source_set("v8_initializers") {
sources -= [ "src/builtins/builtins-intl-gen.cc" ]
}
configs = [ ":internal_config" ]
remove_configs = [ v8_path_prefix + ":default_optimization" ]
configs = [ ":unoptimized_initializer" ]
}
v8_source_set("v8_init") {

View File

@ -94,20 +94,8 @@ v8_add_configs = [
v8_path_prefix + ":toolchain",
]
if (is_debug && !v8_optimized_debug) {
v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
v8_add_configs += [ "//build/config/compiler:no_optimize" ]
} else {
v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
# TODO(crbug.com/621335) Rework this so that we don't have the confusion
# between "optimize_speed" and "optimize_max".
if (((is_posix && !is_android) || is_fuchsia) && !using_sanitizer) {
v8_add_configs += [ "//build/config/compiler:optimize_speed" ]
} else {
v8_add_configs += [ "//build/config/compiler:optimize_max" ]
}
}
v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
v8_add_configs += [ v8_path_prefix + ":default_optimization" ]
if (v8_code_coverage && !is_clang) {
v8_add_configs += [
@ -149,21 +137,21 @@ template("v8_source_set") {
"configs",
"remove_configs",
])
configs -= v8_remove_configs
configs += v8_add_configs
if (defined(invoker.remove_configs)) {
configs -= invoker.remove_configs
}
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
}
}
template("v8_header_set") {
jumbo_source_set(target_name) {
forward_variables_from(invoker, "*", [ "configs" ])
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
configs += invoker.configs
}
}
@ -175,12 +163,12 @@ template("v8_executable") {
"configs",
"remove_configs",
])
configs -= v8_remove_configs
configs += v8_add_configs
if (defined(invoker.remove_configs)) {
configs -= invoker.remove_configs
}
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
if (is_linux) {
# For enabling ASLR.
ldflags = [ "-pie" ]
@ -203,9 +191,9 @@ template("v8_executable") {
template("v8_component") {
component(target_name) {
forward_variables_from(invoker, "*", [ "configs" ])
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
configs += invoker.configs
}
}
@ -213,9 +201,9 @@ template("v8_static_library") {
static_library(target_name) {
complete_static_lib = true
forward_variables_from(invoker, "*", [ "configs" ])
configs += invoker.configs
configs -= v8_remove_configs
configs -= [ "//build/config/compiler:thin_archive" ]
configs += v8_add_configs
configs += invoker.configs
}
}