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