From 6beea97e090423aec4f6e5eeb20d4ed84559a79b Mon Sep 17 00:00:00 2001 From: Tobias Tebbi Date: Thu, 14 Feb 2019 16:57:21 +0100 Subject: [PATCH] Reland^2 "[build] disable C++ optimization for mksnapshot code." This is a reland of a6b95a6acf23516d82fcfeba9e5d0e88dc64288a 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 cee2f772c7e5c33967321b190cf568ff15497bc0 > > 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 > > Reviewed-by: Sigurd Schneider > > Commit-Queue: Tobias Tebbi > > 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 > Commit-Queue: Sigurd Schneider > Reviewed-by: Sigurd Schneider > 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 Commit-Queue: Tobias Tebbi Cr-Commit-Position: refs/heads/master@{#59632} --- BUILD.gn | 32 ++++++++++++++++++++++++++++++-- gni/v8.gni | 30 +++++++++--------------------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 700b696c30..df67500275 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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") { diff --git a/gni/v8.gni b/gni/v8.gni index 727b517a08..9c0db3d47a 100644 --- a/gni/v8.gni +++ b/gni/v8.gni @@ -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 } }