Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Side by Side Diff: build/config/compiler/BUILD.gn

Issue 2333843002: Add use_thin_lto switch to start evaluating ThinLTO. (Closed)
Patch Set: merge -flto and -whole-program-vtables flags Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/toolchain/toolchain.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 # Note: ThinLTO does not currently have this feature implemented
451 # For Full LTO, it provides a measurable runtime speedup of Chrome.
452 cflags += [
453 "-flto",
454 "-fwhole-program-vtables",
455 ]
456 ldflags += [
457 "-flto",
458 "-fwhole-program-vtables",
459 ]
448 460
449 # Apply a lower LTO optimization level as the default is too slow. 461 # Apply a lower LTO optimization level as the default is too slow.
450 if (is_linux) { 462 if (is_linux) {
451 if (use_lld) { 463 if (use_lld) {
452 ldflags += [ "-Wl,--lto-O1" ] 464 ldflags += [ "-Wl,--lto-O1" ]
453 } else { 465 } else {
454 ldflags += [ "-Wl,-plugin-opt,O1" ] 466 ldflags += [ "-Wl,-plugin-opt,O1" ]
467 }
468 } else if (is_mac) {
469 ldflags += [ "-Wl,-mllvm,-O1" ]
455 } 470 }
456 } else if (is_mac) {
457 ldflags += [ "-Wl,-mllvm,-O1" ]
458 } 471 }
459 472
460 # Work-around for http://openradar.appspot.com/20356002 473 # Work-around for http://openradar.appspot.com/20356002
461 if (is_mac) { 474 if (is_mac) {
462 ldflags += [ "-Wl,-all_load" ] 475 ldflags += [ "-Wl,-all_load" ]
463 } 476 }
464 477
465 # Allows the linker to apply ICF to the LTO object file. Also, when 478 # 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 479 # targeting ARM, without this flag, LTO produces a .text section that is
467 # larger than the maximum call displacement, preventing the linker from 480 # larger than the maximum call displacement, preventing the linker from
468 # relocating calls (http://llvm.org/PR22999). 481 # relocating calls (http://llvm.org/PR22999).
469 if (is_linux) { 482 if (is_linux) {
470 ldflags += [ "-Wl,-plugin-opt,-function-sections" ] 483 ldflags += [ "-Wl,-plugin-opt,-function-sections" ]
471 } 484 }
472
473 cflags += [ "-fwhole-program-vtables" ]
474 ldflags += [ "-fwhole-program-vtables" ]
475 } 485 }
476 486
477 # Pass the same C/C++ flags to the objective C/C++ compiler. 487 # Pass the same C/C++ flags to the objective C/C++ compiler.
478 cflags_objc += cflags_c 488 cflags_objc += cflags_c
479 cflags_objcc += cflags_cc 489 cflags_objcc += cflags_cc
480 490
481 # Assign any flags set for the C compiler to asmflags so that they are sent 491 # 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 492 # to the assembler. The Windows assembler takes different types of flags
483 # so only do so for posix platforms. 493 # so only do so for posix platforms.
484 if (is_posix) { 494 if (is_posix) {
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 1611
1602 if (is_ios || is_mac) { 1612 if (is_ios || is_mac) {
1603 # On Mac and iOS, this enables support for ARC (automatic ref-counting). 1613 # On Mac and iOS, this enables support for ARC (automatic ref-counting).
1604 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. 1614 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
1605 config("enable_arc") { 1615 config("enable_arc") {
1606 common_flags = [ "-fobjc-arc" ] 1616 common_flags = [ "-fobjc-arc" ]
1607 cflags_objc = common_flags 1617 cflags_objc = common_flags
1608 cflags_objcc = common_flags 1618 cflags_objcc = common_flags
1609 } 1619 }
1610 } 1620 }
OLDNEW
« no previous file with comments | « no previous file | build/toolchain/toolchain.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698