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 cflags += [ "-flto" ] | 488 cflags += [ "-flto" ] |
491 ldflags += [ "-flto" ] | 489 ldflags += [ "-flto" ] |
492 | 490 |
493 # Apply a lower LTO optimization level as the default is too slow. | 491 # Apply a lower LTO optimization level as the default is too slow. |
494 if (is_linux) { | 492 if (is_linux) { |
495 if (use_lld) { | 493 ldflags += [ "-Wl,--lto-O1" ] |
496 ldflags += [ "-Wl,--lto-O1" ] | |
497 } else { | |
498 ldflags += [ "-Wl,-plugin-opt,O1" ] | |
499 } | |
500 } else if (is_mac) { | 494 } else if (is_mac) { |
501 ldflags += [ "-Wl,-mllvm,-O1" ] | 495 ldflags += [ "-Wl,-mllvm,-O1" ] |
502 } | 496 } |
503 } | 497 } |
504 | 498 |
505 cflags += [ "-fwhole-program-vtables" ] | 499 cflags += [ "-fwhole-program-vtables" ] |
506 ldflags += [ "-fwhole-program-vtables" ] | 500 ldflags += [ "-fwhole-program-vtables" ] |
507 | 501 |
508 # Work-around for http://openradar.appspot.com/20356002 | 502 # Work-around for http://openradar.appspot.com/20356002 |
509 if (is_mac) { | 503 if (is_mac) { |
510 ldflags += [ "-Wl,-all_load" ] | 504 ldflags += [ "-Wl,-all_load" ] |
511 } | 505 } |
512 | 506 |
513 # Allows the linker to apply --gc-sections and ICF to the LTO object file. | 507 # Allows the linker to apply --gc-sections and ICF to the LTO object file. |
514 # Also, when targeting ARM, without this flag, LTO produces a .text section | 508 # Also, when targeting ARM, without this flag, LTO produces a .text section |
515 # that is larger than the maximum call displacement, preventing the linker | 509 # that is larger than the maximum call displacement, preventing the linker |
516 # from relocating calls (http://llvm.org/PR22999). | 510 # from relocating calls (http://llvm.org/PR22999). |
517 if (is_linux) { | 511 if (is_linux) { |
518 if (use_lld) { | 512 ldflags += [ |
519 ldflags += [ | 513 "-Wl,-mllvm,-function-sections", |
520 "-Wl,-mllvm,-function-sections", | 514 "-Wl,-mllvm,-data-sections", |
521 "-Wl,-mllvm,-data-sections", | 515 ] |
522 ] | |
523 } else { | |
524 ldflags += [ | |
525 "-Wl,-plugin-opt,-function-sections", | |
526 "-Wl,-plugin-opt,-data-sections", | |
527 ] | |
528 } | |
529 } | 516 } |
530 } | 517 } |
531 | 518 |
532 # Pass the same C/C++ flags to the objective C/C++ compiler. | 519 # Pass the same C/C++ flags to the objective C/C++ compiler. |
533 cflags_objc += cflags_c | 520 cflags_objc += cflags_c |
534 cflags_objcc += cflags_cc | 521 cflags_objcc += cflags_cc |
535 | 522 |
536 # Assign any flags set for the C compiler to asmflags so that they are sent | 523 # Assign any flags set for the C compiler to asmflags so that they are sent |
537 # to the assembler. The Windows assembler takes different types of flags | 524 # to the assembler. The Windows assembler takes different types of flags |
538 # so only do so for posix platforms. | 525 # so only do so for posix platforms. |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 | 1734 |
1748 if (is_ios || is_mac) { | 1735 if (is_ios || is_mac) { |
1749 # On Mac and iOS, this enables support for ARC (automatic ref-counting). | 1736 # On Mac and iOS, this enables support for ARC (automatic ref-counting). |
1750 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. | 1737 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. |
1751 config("enable_arc") { | 1738 config("enable_arc") { |
1752 common_flags = [ "-fobjc-arc" ] | 1739 common_flags = [ "-fobjc-arc" ] |
1753 cflags_objc = common_flags | 1740 cflags_objc = common_flags |
1754 cflags_objcc = common_flags | 1741 cflags_objcc = common_flags |
1755 } | 1742 } |
1756 } | 1743 } |
OLD | NEW |