| Index: build/config/compiler/BUILD.gn
|
| diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
|
| index 0da129f5ae5df9ee78557ac8b31537bd4bec8547..a59907bc8ddeaeeaf1918bc2512127074eb2464e 100644
|
| --- a/build/config/compiler/BUILD.gn
|
| +++ b/build/config/compiler/BUILD.gn
|
| @@ -7,6 +7,7 @@ import("//build/config/chrome_build.gni")
|
| import("//build/config/compiler/compiler.gni")
|
| import("//build/config/nacl/config.gni")
|
| import("//build/toolchain/cc_wrapper.gni")
|
| +import("//build/toolchain/toolchain.gni")
|
|
|
| if (current_cpu == "arm") {
|
| import("//build/config/arm.gni")
|
| @@ -378,6 +379,52 @@ config("compiler") {
|
| }
|
| }
|
|
|
| + # Add flags for link-time optimization. These flags enable
|
| + # optimizations/transformations that require whole-program visibility at link
|
| + # time, so they need to be applied to all translation units, and we may end up
|
| + # with miscompiles if only part of the program is compiled with LTO flags. For
|
| + # that reason, we cannot allow targets to enable or disable these flags, for
|
| + # example by disabling the optimize configuration.
|
| + # TODO(pcc): Make this conditional on is_official_build rather than on gn
|
| + # flags for specific features.
|
| + if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) {
|
| + cflags += [ "-flto" ]
|
| + ldflags += [ "-flto" ]
|
| +
|
| + # Apply a lower LTO optimization level as the default is too slow.
|
| + if (is_linux) {
|
| + ldflags += [ "-Wl,-plugin-opt,O1" ]
|
| + } else if (is_mac) {
|
| + ldflags += [ "-Wl,-mllvm,-O1" ]
|
| + }
|
| +
|
| + # Work-around for http://openradar.appspot.com/20356002
|
| + if (is_mac) {
|
| + ldflags += [ "-Wl,-all_load" ]
|
| + }
|
| +
|
| + # Allows the linker to apply ICF to the LTO object file. Also, when
|
| + # targeting ARM, without this flag, LTO produces a .text section that is
|
| + # larger than the maximum call displacement, preventing the linker from
|
| + # relocating calls (http://llvm.org/PR22999).
|
| + if (is_linux) {
|
| + ldflags += [ "-Wl,-plugin-opt,-function-sections" ]
|
| + }
|
| +
|
| + # TODO(pcc): Make these flags work correctly with CFI.
|
| + if (!is_cfi) {
|
| + cflags += [
|
| + "-fwhole-program-vtables",
|
| +
|
| + # TODO(pcc): Remove this flag once the upstream interface change
|
| + # (http://reviews.llvm.org/D18635) lands.
|
| + "-fwhole-program-vtables-blacklist=" +
|
| + rebase_path("//tools/cfi/blacklist.txt", root_build_dir),
|
| + ]
|
| + ldflags += [ "-fwhole-program-vtables" ]
|
| + }
|
| + }
|
| +
|
| # Pass the same C/C++ flags to the objective C/C++ compiler.
|
| cflags_objc += cflags_c
|
| cflags_objcc += cflags_cc
|
|
|