Chromium Code Reviews| 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/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 27 matching lines...) Expand all Loading... | |
| 38 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 38 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
| 39 root_build_dir) | 39 root_build_dir) |
| 40 | 40 |
| 41 # Compile in such a way as to make it possible for the profiler to unwind full | 41 # Compile in such a way as to make it possible for the profiler to unwind full |
| 42 # stack frames. Setting this flag has a large effect on the performance of the | 42 # stack frames. Setting this flag has a large effect on the performance of the |
| 43 # generated code than just setting profiling, but gives the profiler more | 43 # generated code than just setting profiling, but gives the profiler more |
| 44 # information to analyze. | 44 # information to analyze. |
| 45 # Requires profiling to be set to true. | 45 # Requires profiling to be set to true. |
| 46 enable_full_stack_frames_for_profiling = false | 46 enable_full_stack_frames_for_profiling = false |
| 47 | 47 |
| 48 # Set to true to use lld, the LLVM linker. | |
|
brettw
2016/04/27 22:55:46
It seems this is Posixonly. If so, can you wrap th
pcc1
2016/04/27 23:21:05
It's also available on Windows. I've added more in
| |
| 49 use_lld = false | |
| 50 | |
| 48 # TODO(GYP): We should be using 64-bit gold for linking on both 64-bit Linux | 51 # TODO(GYP): We should be using 64-bit gold for linking on both 64-bit Linux |
| 49 # and 32-bit linux; 32-bit Gold runs out of address-space on 32-bit builds. | 52 # and 32-bit linux; 32-bit Gold runs out of address-space on 32-bit builds. |
| 50 # However, something isn't quite working right on the 32-bit builds. | 53 # However, something isn't quite working right on the 32-bit builds. |
| 51 use_gold = is_linux && (current_cpu == "x64" || current_cpu == "arm") | 54 use_gold = |
| 55 is_linux && (current_cpu == "x64" || current_cpu == "arm") && !use_lld | |
|
brettw
2016/04/27 22:55:46
This won't actually do what you want. The build ov
pcc1
2016/04/27 23:21:05
Done.
| |
| 52 | 56 |
| 53 # When we are going to use gold we need to find it. | 57 # When we are going to use gold we need to find it. |
| 54 # This is initialized below, after use_gold might have been overridden. | 58 # This is initialized below, after use_gold might have been overridden. |
| 55 gold_path = false | 59 gold_path = false |
| 56 | 60 |
| 57 # use_debug_fission: whether to use split DWARF debug info | 61 # use_debug_fission: whether to use split DWARF debug info |
| 58 # files. This can reduce link time significantly, but is incompatible | 62 # files. This can reduce link time significantly, but is incompatible |
| 59 # with some utilities such as icecc and ccache. Requires gold and | 63 # with some utilities such as icecc and ccache. Requires gold and |
| 60 # gcc >= 4.8 or clang. | 64 # gcc >= 4.8 or clang. |
| 61 # http://gcc.gnu.org/wiki/DebugFission | 65 # http://gcc.gnu.org/wiki/DebugFission |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 "-Wl,-z,now", | 289 "-Wl,-z,now", |
| 286 "-Wl,-z,relro", | 290 "-Wl,-z,relro", |
| 287 ] | 291 ] |
| 288 if (!using_sanitizer && !use_cfi_diag) { | 292 if (!using_sanitizer && !use_cfi_diag) { |
| 289 ldflags += [ "-Wl,-z,defs" ] | 293 ldflags += [ "-Wl,-z,defs" ] |
| 290 } | 294 } |
| 291 } | 295 } |
| 292 | 296 |
| 293 # Linux-specific compiler flags setup. | 297 # Linux-specific compiler flags setup. |
| 294 # ------------------------------------ | 298 # ------------------------------------ |
| 295 if (use_gold) { | 299 if (is_posix && use_lld) { |
| 300 ldflags += [ "-fuse-ld=lld" ] | |
| 301 } else if (use_gold) { | |
| 296 ldflags += [ | 302 ldflags += [ |
| 297 "-B$gold_path", | 303 "-B$gold_path", |
| 298 | 304 |
| 299 # Newer gccs and clangs support -fuse-ld, use the flag to force gold | 305 # Newer gccs and clangs support -fuse-ld, use the flag to force gold |
| 300 # selection. | 306 # selection. |
| 301 # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html | 307 # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html |
| 302 "-fuse-ld=gold", | 308 "-fuse-ld=gold", |
| 303 | 309 |
| 304 # Experimentation found that using four linking threads | 310 # Experimentation found that using four linking threads |
| 305 # saved ~20% of link time. | 311 # saved ~20% of link time. |
| 306 # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_threa d/thread/281527606915bb36 | 312 # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_threa d/thread/281527606915bb36 |
| 307 # Only apply this to the target linker, since the host | 313 # Only apply this to the target linker, since the host |
| 308 # linker might not be gold, but isn't used much anyway. | 314 # linker might not be gold, but isn't used much anyway. |
| 309 # TODO(raymes): Disable threading because gold is frequently | 315 # TODO(raymes): Disable threading because gold is frequently |
| 310 # crashing on the bots: crbug.com/161942. | 316 # crashing on the bots: crbug.com/161942. |
| 311 #"-Wl,--threads", | 317 #"-Wl,--threads", |
| 312 #"-Wl,--thread-count=4", | 318 #"-Wl,--thread-count=4", |
| 313 ] | 319 ] |
| 314 | 320 |
| 315 if (gdb_index) { | 321 if (gdb_index) { |
| 316 ldflags += [ "-Wl,--gdb-index" ] | 322 ldflags += [ "-Wl,--gdb-index" ] |
| 317 } | 323 } |
| 318 | 324 |
| 319 if (!using_sanitizer && !(is_android && use_order_profiling)) { | |
| 320 # TODO(brettw) common.gypi has this only for target toolset. | |
| 321 ldflags += [ "-Wl,--icf=all" ] | |
| 322 } | |
| 323 | |
| 324 # TODO(thestig): Make this flag work with GN. | 325 # TODO(thestig): Make this flag work with GN. |
| 325 #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan | | is_msan)) { | 326 #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan | | is_msan)) { |
| 326 # ldflags += [ | 327 # ldflags += [ |
| 327 # "-Wl,--detect-odr-violations", | 328 # "-Wl,--detect-odr-violations", |
| 328 # ] | 329 # ] |
| 329 #} | 330 #} |
| 330 } else if (linux_use_bundled_binutils) { | 331 } else if (linux_use_bundled_binutils) { |
| 331 # Gold is the default linker for the bundled binutils so we explicitly | 332 # Gold is the default linker for the bundled binutils so we explicitly |
| 332 # enable the bfd linker when use_gold is not set. | 333 # enable the bfd linker when use_gold is not set. |
| 333 ldflags += [ "-fuse-ld=bfd" ] | 334 ldflags += [ "-fuse-ld=bfd" ] |
| 334 } | 335 } |
| 335 | 336 |
| 337 if (is_posix && (use_gold || use_lld) && !using_sanitizer && | |
| 338 !(is_android && use_order_profiling)) { | |
| 339 # TODO(brettw) common.gypi has this only for target toolset. | |
|
brettw
2016/04/27 22:55:46
I think you can delete this comment.
pcc1
2016/04/27 23:21:05
Done.
| |
| 340 ldflags += [ "-Wl,--icf=all" ] | |
| 341 } | |
| 342 | |
| 336 if (linux_use_bundled_binutils) { | 343 if (linux_use_bundled_binutils) { |
| 337 cflags += [ "-B$binutils_path" ] | 344 cflags += [ "-B$binutils_path" ] |
| 338 } | 345 } |
| 339 | 346 |
| 340 # Clang-specific compiler flags setup. | 347 # Clang-specific compiler flags setup. |
| 341 # ------------------------------------ | 348 # ------------------------------------ |
| 342 if (is_clang) { | 349 if (is_clang) { |
| 343 cflags += [ "-fcolor-diagnostics" ] | 350 cflags += [ "-fcolor-diagnostics" ] |
| 344 } | 351 } |
| 345 | 352 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 # that reason, we cannot allow targets to enable or disable these flags, for | 413 # that reason, we cannot allow targets to enable or disable these flags, for |
| 407 # example by disabling the optimize configuration. | 414 # example by disabling the optimize configuration. |
| 408 # TODO(pcc): Make this conditional on is_official_build rather than on gn | 415 # TODO(pcc): Make this conditional on is_official_build rather than on gn |
| 409 # flags for specific features. | 416 # flags for specific features. |
| 410 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) { | 417 if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) { |
| 411 cflags += [ "-flto" ] | 418 cflags += [ "-flto" ] |
| 412 ldflags += [ "-flto" ] | 419 ldflags += [ "-flto" ] |
| 413 | 420 |
| 414 # Apply a lower LTO optimization level as the default is too slow. | 421 # Apply a lower LTO optimization level as the default is too slow. |
| 415 if (is_linux) { | 422 if (is_linux) { |
| 416 ldflags += [ "-Wl,-plugin-opt,O1" ] | 423 if (use_lld) { |
| 424 ldflags += [ "-Wl,--lto-O1" ] | |
| 425 } else { | |
| 426 ldflags += [ "-Wl,-plugin-opt,O1" ] | |
| 427 } | |
| 417 } else if (is_mac) { | 428 } else if (is_mac) { |
| 418 ldflags += [ "-Wl,-mllvm,-O1" ] | 429 ldflags += [ "-Wl,-mllvm,-O1" ] |
| 419 } | 430 } |
| 420 | 431 |
| 421 # Work-around for http://openradar.appspot.com/20356002 | 432 # Work-around for http://openradar.appspot.com/20356002 |
| 422 if (is_mac) { | 433 if (is_mac) { |
| 423 ldflags += [ "-Wl,-all_load" ] | 434 ldflags += [ "-Wl,-all_load" ] |
| 424 } | 435 } |
| 425 | 436 |
| 426 # Allows the linker to apply ICF to the LTO object file. Also, when | 437 # Allows the linker to apply ICF to the LTO object file. Also, when |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 | 1454 |
| 1444 if (is_ios || is_mac) { | 1455 if (is_ios || is_mac) { |
| 1445 # On Mac and iOS, this enables support for ARC (automatic ref-counting). | 1456 # On Mac and iOS, this enables support for ARC (automatic ref-counting). |
| 1446 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. | 1457 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. |
| 1447 config("enable_arc") { | 1458 config("enable_arc") { |
| 1448 common_flags = [ "-fobjc-arc" ] | 1459 common_flags = [ "-fobjc-arc" ] |
| 1449 cflags_objc = common_flags | 1460 cflags_objc = common_flags |
| 1450 cflags_objcc = common_flags | 1461 cflags_objcc = common_flags |
| 1451 } | 1462 } |
| 1452 } | 1463 } |
| OLD | NEW |