| 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/chromecast_build.gni") | 7 import("//build/config/chromecast_build.gni") |
| 8 import("//build/config/compiler/compiler.gni") | 8 import("//build/config/compiler/compiler.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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 # Add flags for link-time optimization. These flags enable | 464 # Add flags for link-time optimization. These flags enable |
| 465 # optimizations/transformations that require whole-program visibility at link | 465 # optimizations/transformations that require whole-program visibility at link |
| 466 # time, so they need to be applied to all translation units, and we may end up | 466 # time, so they need to be applied to all translation units, and we may end up |
| 467 # with miscompiles if only part of the program is compiled with LTO flags. For | 467 # with miscompiles if only part of the program is compiled with LTO flags. For |
| 468 # that reason, we cannot allow targets to enable or disable these flags, for | 468 # that reason, we cannot allow targets to enable or disable these flags, for |
| 469 # example by disabling the optimize configuration. | 469 # example by disabling the optimize configuration. |
| 470 # TODO(pcc): Make this conditional on is_official_build rather than on gn | 470 # TODO(pcc): Make this conditional on is_official_build rather than on gn |
| 471 # flags for specific features. | 471 # flags for specific features. |
| 472 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) { | 472 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) { |
| 473 assert(use_lld, "POSIX LTO requires LLD") | |
| 474 | |
| 475 if (use_thin_lto) { | 473 if (use_thin_lto) { |
| 476 cflags += [ "-flto=thin" ] | 474 cflags += [ "-flto=thin" ] |
| 477 ldflags += [ "-flto=thin" ] | 475 ldflags += [ "-flto=thin" ] |
| 478 | 476 |
| 479 # Limit the parallelism to avoid too agressive competition between | 477 # Limit the parallelism to avoid too agressive competition between |
| 480 # linker jobs. This is still suboptimal to a potential dynamic | 478 # linker jobs. This is still suboptimal to a potential dynamic |
| 481 # resource allocation scheme, but should be good enough. | 479 # resource allocation scheme, but should be good enough. |
| 482 ldflags += [ | 480 if (use_lld) { |
| 483 "-Wl,--thinlto-jobs=8", | 481 ldflags += [ |
| 484 "-Wl,--thinlto-cache-dir=" + | 482 "-Wl,--thinlto-jobs=8", |
| 485 rebase_path("$root_out_dir/thinlto-cache", root_build_dir), | 483 "-Wl,--thinlto-cache-dir=" + |
| 486 ] | 484 rebase_path("$root_out_dir/thinlto-cache", root_build_dir), |
| 485 ] |
| 486 } else { |
| 487 ldflags += [ "-Wl,-plugin-opt,jobs=8" ] |
| 488 } |
| 487 } else { | 489 } else { |
| 488 # Note: ThinLTO does not currently have this feature implemented | 490 # Note: ThinLTO does not currently have this feature implemented |
| 489 # For Full LTO, it provides a measurable runtime speedup of Chrome. | 491 # For Full LTO, it provides a measurable runtime speedup of Chrome. |
| 490 cflags += [ | 492 cflags += [ |
| 491 "-flto", | 493 "-flto", |
| 492 "-fwhole-program-vtables", | 494 "-fwhole-program-vtables", |
| 493 ] | 495 ] |
| 494 ldflags += [ | 496 ldflags += [ |
| 495 "-flto", | 497 "-flto", |
| 496 "-fwhole-program-vtables", | 498 "-fwhole-program-vtables", |
| 497 ] | 499 ] |
| 498 | 500 |
| 499 # Apply a lower LTO optimization level as the default is too slow. | 501 # Apply a lower LTO optimization level as the default is too slow. |
| 500 if (is_linux) { | 502 if (is_linux) { |
| 501 ldflags += [ "-Wl,--lto-O1" ] | 503 if (use_lld) { |
| 504 ldflags += [ "-Wl,--lto-O1" ] |
| 505 } else { |
| 506 ldflags += [ "-Wl,-plugin-opt,O1" ] |
| 507 } |
| 502 } else if (is_mac) { | 508 } else if (is_mac) { |
| 503 ldflags += [ "-Wl,-mllvm,-O1" ] | 509 ldflags += [ "-Wl,-mllvm,-O1" ] |
| 504 } | 510 } |
| 505 } | 511 } |
| 506 | 512 |
| 507 # Work-around for http://openradar.appspot.com/20356002 | 513 # Work-around for http://openradar.appspot.com/20356002 |
| 508 if (is_mac) { | 514 if (is_mac) { |
| 509 ldflags += [ "-Wl,-all_load" ] | 515 ldflags += [ "-Wl,-all_load" ] |
| 510 } | 516 } |
| 511 | 517 |
| 512 # Allows the linker to apply --gc-sections and ICF to the LTO object file. | 518 # Allows the linker to apply --gc-sections and ICF to the LTO object file. |
| 513 # Also, when targeting ARM, without this flag, LTO produces a .text section | 519 # Also, when targeting ARM, without this flag, LTO produces a .text section |
| 514 # that is larger than the maximum call displacement, preventing the linker | 520 # that is larger than the maximum call displacement, preventing the linker |
| 515 # from relocating calls (http://llvm.org/PR22999). | 521 # from relocating calls (http://llvm.org/PR22999). |
| 516 if (is_linux) { | 522 if (is_linux) { |
| 517 ldflags += [ | 523 if (use_lld) { |
| 518 "-Wl,-mllvm,-function-sections", | 524 ldflags += [ |
| 519 "-Wl,-mllvm,-data-sections", | 525 "-Wl,-mllvm,-function-sections", |
| 520 ] | 526 "-Wl,-mllvm,-data-sections", |
| 527 ] |
| 528 } else { |
| 529 ldflags += [ |
| 530 "-Wl,-plugin-opt,-function-sections", |
| 531 "-Wl,-plugin-opt,-data-sections", |
| 532 ] |
| 533 } |
| 521 } | 534 } |
| 522 } | 535 } |
| 523 | 536 |
| 524 # Pass the same C/C++ flags to the objective C/C++ compiler. | 537 # Pass the same C/C++ flags to the objective C/C++ compiler. |
| 525 cflags_objc += cflags_c | 538 cflags_objc += cflags_c |
| 526 cflags_objcc += cflags_cc | 539 cflags_objcc += cflags_cc |
| 527 | 540 |
| 528 # Assign any flags set for the C compiler to asmflags so that they are sent | 541 # Assign any flags set for the C compiler to asmflags so that they are sent |
| 529 # to the assembler. The Windows assembler takes different types of flags | 542 # to the assembler. The Windows assembler takes different types of flags |
| 530 # so only do so for posix platforms. | 543 # so only do so for posix platforms. |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 | 1752 |
| 1740 if (is_ios || is_mac) { | 1753 if (is_ios || is_mac) { |
| 1741 # On Mac and iOS, this enables support for ARC (automatic ref-counting). | 1754 # On Mac and iOS, this enables support for ARC (automatic ref-counting). |
| 1742 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. | 1755 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. |
| 1743 config("enable_arc") { | 1756 config("enable_arc") { |
| 1744 common_flags = [ "-fobjc-arc" ] | 1757 common_flags = [ "-fobjc-arc" ] |
| 1745 cflags_objc = common_flags | 1758 cflags_objc = common_flags |
| 1746 cflags_objcc = common_flags | 1759 cflags_objcc = common_flags |
| 1747 } | 1760 } |
| 1748 } | 1761 } |
| OLD | NEW |