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

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

Issue 1809273002: Enable whole-program virtual function optimization in LTO mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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 | « build/common.gypi ('k') | build/config/sanitizers/BUILD.gn » ('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 11
11 if (current_cpu == "arm") { 12 if (current_cpu == "arm") {
12 import("//build/config/arm.gni") 13 import("//build/config/arm.gni")
13 } 14 }
14 if (current_cpu == "mipsel" || current_cpu == "mips64el") { 15 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
15 import("//build/config/mips.gni") 16 import("//build/config/mips.gni")
16 } 17 }
17 if (is_win) { 18 if (is_win) {
18 import("//build/config/win/visual_studio_version.gni") 19 import("//build/config/win/visual_studio_version.gni")
19 } 20 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 cflags_cc += [ "-stdlib=libc++" ] 372 cflags_cc += [ "-stdlib=libc++" ]
372 ldflags += [ "-stdlib=libc++" ] 373 ldflags += [ "-stdlib=libc++" ]
373 if (!is_component_build && !is_asan) { 374 if (!is_component_build && !is_asan) {
374 ldflags += [ 375 ldflags += [
375 "-L", 376 "-L",
376 rebase_path("//third_party/libc++-static", root_build_dir), 377 rebase_path("//third_party/libc++-static", root_build_dir),
377 ] 378 ]
378 } 379 }
379 } 380 }
380 381
382 # Add flags for link-time optimization. These flags enable
383 # optimizations/transformations that require whole-program visibility at link
384 # time, so they need to be applied to all translation units, and we may end up
385 # with miscompiles if only part of the program is compiled with LTO flags. For
386 # that reason, we cannot allow targets to enable or disable these flags, for
387 # example by disabling the optimize configuration.
388 # TODO(pcc): Make this conditional on is_official_build rather than on gn
389 # flags for specific features.
390 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) {
391 cflags += [ "-flto" ]
392 ldflags += [ "-flto" ]
393
394 # Apply a lower LTO optimization level as the default is too slow.
395 if (is_linux) {
396 ldflags += [ "-Wl,-plugin-opt,O1" ]
397 } else if (is_mac) {
398 ldflags += [ "-Wl,-mllvm,-O1" ]
399 }
400
401 # Work-around for http://openradar.appspot.com/20356002
402 if (is_mac) {
403 ldflags += [ "-Wl,-all_load" ]
404 }
405
406 # Allows the linker to apply ICF to the LTO object file. Also, when
407 # targeting ARM, without this flag, LTO produces a .text section that is
408 # larger than the maximum call displacement, preventing the linker from
409 # relocating calls (http://llvm.org/PR22999).
410 if (is_linux) {
411 ldflags += [ "-Wl,-plugin-opt,-function-sections" ]
412 }
413
414 # TODO(pcc): Make these flags work correctly with CFI.
415 if (!is_cfi) {
416 cflags += [
417 "-fwhole-program-vtables",
418
419 # TODO(pcc): Remove this flag once the upstream interface change
420 # (http://reviews.llvm.org/D18635) lands.
421 "-fwhole-program-vtables-blacklist=" +
422 rebase_path("//tools/cfi/blacklist.txt", root_build_dir),
423 ]
424 ldflags += [ "-fwhole-program-vtables" ]
425 }
426 }
427
381 # Pass the same C/C++ flags to the objective C/C++ compiler. 428 # Pass the same C/C++ flags to the objective C/C++ compiler.
382 cflags_objc += cflags_c 429 cflags_objc += cflags_c
383 cflags_objcc += cflags_cc 430 cflags_objcc += cflags_cc
384 431
385 # Assign any flags set for the C compiler to asmflags so that they are sent 432 # Assign any flags set for the C compiler to asmflags so that they are sent
386 # to the assembler. The Windows assembler takes different types of flags 433 # to the assembler. The Windows assembler takes different types of flags
387 # so only do so for posix platforms. 434 # so only do so for posix platforms.
388 if (is_posix) { 435 if (is_posix) {
389 asmflags += cflags 436 asmflags += cflags
390 asmflags += cflags_c 437 asmflags += cflags_c
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 1393
1347 if (is_ios || is_mac) { 1394 if (is_ios || is_mac) {
1348 # On Mac and iOS, this enables support for ARC (automatic ref-counting). 1395 # On Mac and iOS, this enables support for ARC (automatic ref-counting).
1349 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. 1396 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
1350 config("enable_arc") { 1397 config("enable_arc") {
1351 common_flags = [ "-fobjc-arc" ] 1398 common_flags = [ "-fobjc-arc" ]
1352 cflags_objc = common_flags 1399 cflags_objc = common_flags
1353 cflags_objcc = common_flags 1400 cflags_objcc = common_flags
1354 } 1401 }
1355 } 1402 }
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | build/config/sanitizers/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698