Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
| 7 import("//build/config/compiler/compiler.gni") | 7 import("//build/config/compiler/compiler.gni") |
| 8 import("//build/config/nacl/config.gni") | 8 import("//build/config/nacl/config.gni") |
| 9 import("//build/toolchain/cc_wrapper.gni") | 9 import("//build/toolchain/cc_wrapper.gni") |
| 10 import("//build/toolchain/toolchain.gni") | 10 import("//build/toolchain/toolchain.gni") |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 | 436 |
| 437 # Add flags for link-time optimization. These flags enable | 437 # Add flags for link-time optimization. These flags enable |
| 438 # optimizations/transformations that require whole-program visibility at link | 438 # optimizations/transformations that require whole-program visibility at link |
| 439 # time, so they need to be applied to all translation units, and we may end up | 439 # time, so they need to be applied to all translation units, and we may end up |
| 440 # with miscompiles if only part of the program is compiled with LTO flags. For | 440 # with miscompiles if only part of the program is compiled with LTO flags. For |
| 441 # that reason, we cannot allow targets to enable or disable these flags, for | 441 # that reason, we cannot allow targets to enable or disable these flags, for |
| 442 # example by disabling the optimize configuration. | 442 # example by disabling the optimize configuration. |
| 443 # TODO(pcc): Make this conditional on is_official_build rather than on gn | 443 # TODO(pcc): Make this conditional on is_official_build rather than on gn |
| 444 # flags for specific features. | 444 # flags for specific features. |
| 445 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) { | 445 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) { |
| 446 cflags += [ "-flto" ] | 446 if (use_thin_lto) { |
| 447 ldflags += [ "-flto" ] | 447 cflags += [ "-flto=thin" ] |
| 448 ldflags += [ "-flto=thin" ] | |
| 449 } else { | |
| 450 cflags += [ "-flto" ] | |
| 451 ldflags += [ "-flto" ] | |
| 448 | 452 |
| 449 # Apply a lower LTO optimization level as the default is too slow. | 453 # Apply a lower LTO optimization level as the default is too slow. |
| 450 if (is_linux) { | 454 if (is_linux) { |
| 451 if (use_lld) { | 455 if (use_lld) { |
| 452 ldflags += [ "-Wl,--lto-O1" ] | 456 ldflags += [ "-Wl,--lto-O1" ] |
| 453 } else { | 457 } else { |
| 454 ldflags += [ "-Wl,-plugin-opt,O1" ] | 458 ldflags += [ "-Wl,-plugin-opt,O1" ] |
| 459 } | |
| 460 } else if (is_mac) { | |
| 461 ldflags += [ "-Wl,-mllvm,-O1" ] | |
| 455 } | 462 } |
| 456 } else if (is_mac) { | 463 |
| 457 ldflags += [ "-Wl,-mllvm,-O1" ] | 464 # Note: ThinLTO does not currently have this feature implemented |
| 465 # For Full LTO, it provides a measurable runtime speedup of Chrome. | |
| 466 cflags += [ "-fwhole-program-vtables" ] | |
| 467 ldflags += [ "-fwhole-program-vtables" ] | |
|
Dirk Pranke
2016/09/12 21:15:38
Can you move these four lines up next to lines 450
krasin1
2016/09/12 21:35:06
Done. Good idea.
| |
| 458 } | 468 } |
| 459 | 469 |
| 460 # Work-around for http://openradar.appspot.com/20356002 | 470 # Work-around for http://openradar.appspot.com/20356002 |
| 461 if (is_mac) { | 471 if (is_mac) { |
| 462 ldflags += [ "-Wl,-all_load" ] | 472 ldflags += [ "-Wl,-all_load" ] |
| 463 } | 473 } |
| 464 | 474 |
| 465 # Allows the linker to apply ICF to the LTO object file. Also, when | 475 # Allows the linker to apply ICF to the LTO object file. Also, when |
| 466 # targeting ARM, without this flag, LTO produces a .text section that is | 476 # targeting ARM, without this flag, LTO produces a .text section that is |
| 467 # larger than the maximum call displacement, preventing the linker from | 477 # larger than the maximum call displacement, preventing the linker from |
| 468 # relocating calls (http://llvm.org/PR22999). | 478 # relocating calls (http://llvm.org/PR22999). |
| 469 if (is_linux) { | 479 if (is_linux) { |
| 470 ldflags += [ "-Wl,-plugin-opt,-function-sections" ] | 480 ldflags += [ "-Wl,-plugin-opt,-function-sections" ] |
| 471 } | 481 } |
| 472 | |
| 473 cflags += [ "-fwhole-program-vtables" ] | |
| 474 ldflags += [ "-fwhole-program-vtables" ] | |
| 475 } | 482 } |
| 476 | 483 |
| 477 # Pass the same C/C++ flags to the objective C/C++ compiler. | 484 # Pass the same C/C++ flags to the objective C/C++ compiler. |
| 478 cflags_objc += cflags_c | 485 cflags_objc += cflags_c |
| 479 cflags_objcc += cflags_cc | 486 cflags_objcc += cflags_cc |
| 480 | 487 |
| 481 # Assign any flags set for the C compiler to asmflags so that they are sent | 488 # Assign any flags set for the C compiler to asmflags so that they are sent |
| 482 # to the assembler. The Windows assembler takes different types of flags | 489 # to the assembler. The Windows assembler takes different types of flags |
| 483 # so only do so for posix platforms. | 490 # so only do so for posix platforms. |
| 484 if (is_posix) { | 491 if (is_posix) { |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1601 | 1608 |
| 1602 if (is_ios || is_mac) { | 1609 if (is_ios || is_mac) { |
| 1603 # On Mac and iOS, this enables support for ARC (automatic ref-counting). | 1610 # On Mac and iOS, this enables support for ARC (automatic ref-counting). |
| 1604 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. | 1611 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. |
| 1605 config("enable_arc") { | 1612 config("enable_arc") { |
| 1606 common_flags = [ "-fobjc-arc" ] | 1613 common_flags = [ "-fobjc-arc" ] |
| 1607 cflags_objc = common_flags | 1614 cflags_objc = common_flags |
| 1608 cflags_objcc = common_flags | 1615 cflags_objcc = common_flags |
| 1609 } | 1616 } |
| 1610 } | 1617 } |
| OLD | NEW |