Remove cfi_linker from tests
Windows 10's implementation of Control Flow Guard costs about 300 ms
per process-create call with unit_tests.exe and other huge executables.
Since process creation is serialized this adds about 300 s to the test
run time of unit_tests.exe (10,000 tests divided by ten tests per
process times 0.3 s), which means it takes significantly longer to run
than it would otherwise. There have been reports that this causes
unit_tests.exe to take 4-5x as long to run as when CFG is disabled.
CFG is not needed for these tests, so disabling it is fine.
unit_tests.exe, for example, has about 180,000 CFG functions, which is a
lot, but it's not clear why it costs so much to set a bit for each
function in the ~1.5 MB CFG bitmap. That is a problem for Microsoft to
figure out and this is being discussed with them.
The underlying issue and this change do not affect chrome.exe.
See http://www.alex-ionescu.com/?p=246 for more information on CFG.
Bug: 950923
Change-Id: I660ef68ca33141e54cfe895efaa3e7c11bc7118a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570694
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652279}
diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn
index 6a6b8f8..3f37c75 100644
--- a/build/config/BUILD.gn
+++ b/build/config/BUILD.gn
@@ -21,7 +21,6 @@
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//build/toolchain/goma.gni")
-
declare_args() {
# When set (the default) enables C++ iterator debugging in debug builds.
# Iterator debugging is always off in release builds (technically, this flag
@@ -348,9 +347,6 @@
if (is_win) {
configs += _windows_linker_configs
-
- # Currently only turn on linker CFI for executables.
- configs += [ "//build/config/win:cfi_linker" ]
} else if (is_mac) {
configs += [ "//build/config/mac:mac_dynamic_flags" ]
} else if (is_ios) {
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index 9fea836a..7175865b 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -516,6 +516,13 @@
"//build/config:default_libs",
"//build/config:executable_config",
] + _linker_configs
+
+if (is_win) {
+ # Currently only turn on linker CFI for executables, and position it so it can
+ # be removed when needed.
+ default_executable_configs += [ "//build/config/win:cfi_linker" ]
+}
+
set_defaults("executable") {
configs = default_executable_configs
}
diff --git a/testing/test.gni b/testing/test.gni
index eac0fdd..929418c 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -369,6 +369,12 @@
deps = []
}
+ if (is_win) {
+ # Initializing CFG data during process creation is a significant
+ # bottleneck for large test binaries, and CFG is not needed for tests,
+ # so disable it. See https://crbug.com/950923 for details.
+ configs -= [ "//build/config/win:cfi_linker" ]
+ }
testonly = true
deps += [
# Give tests the default manifest on Windows (a no-op elsewhere).