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 28 matching lines...) Expand all Loading... |
39 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 39 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
40 root_build_dir) | 40 root_build_dir) |
41 | 41 |
42 # Compile in such a way as to make it possible for the profiler to unwind full | 42 # Compile in such a way as to make it possible for the profiler to unwind full |
43 # stack frames. Setting this flag has a large effect on the performance of the | 43 # stack frames. Setting this flag has a large effect on the performance of the |
44 # generated code than just setting profiling, but gives the profiler more | 44 # generated code than just setting profiling, but gives the profiler more |
45 # information to analyze. | 45 # information to analyze. |
46 # Requires profiling to be set to true. | 46 # Requires profiling to be set to true. |
47 enable_full_stack_frames_for_profiling = false | 47 enable_full_stack_frames_for_profiling = false |
48 | 48 |
49 # Whether to use the gold linker from binutils instead of lld or bfd. | |
50 use_gold = | |
51 !use_lld && is_linux && | |
52 (current_cpu == "x64" || current_cpu == "x86" || current_cpu == "arm") | |
53 | |
54 # When we are going to use gold we need to find it. | 49 # When we are going to use gold we need to find it. |
55 # This is initialized below, after use_gold might have been overridden. | 50 # This is initialized below, after use_gold might have been overridden. |
56 gold_path = false | 51 gold_path = false |
57 | 52 |
58 # use_debug_fission: whether to use split DWARF debug info | 53 # use_debug_fission: whether to use split DWARF debug info |
59 # files. This can reduce link time significantly, but is incompatible | 54 # files. This can reduce link time significantly, but is incompatible |
60 # with some utilities such as icecc and ccache. Requires gold and | 55 # with some utilities such as icecc and ccache. Requires gold and |
61 # gcc >= 4.8 or clang. | 56 # gcc >= 4.8 or clang. |
62 # http://gcc.gnu.org/wiki/DebugFission | 57 # http://gcc.gnu.org/wiki/DebugFission |
63 # | 58 # |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 if (!using_sanitizer && !use_cfi_diag) { | 291 if (!using_sanitizer && !use_cfi_diag) { |
297 ldflags += [ "-Wl,-z,defs" ] | 292 ldflags += [ "-Wl,-z,defs" ] |
298 } | 293 } |
299 } | 294 } |
300 | 295 |
301 # Linux-specific compiler flags setup. | 296 # Linux-specific compiler flags setup. |
302 # ------------------------------------ | 297 # ------------------------------------ |
303 if (is_posix && use_lld && !is_nacl) { | 298 if (is_posix && use_lld && !is_nacl) { |
304 ldflags += [ "-fuse-ld=lld" ] | 299 ldflags += [ "-fuse-ld=lld" ] |
305 } else if (use_gold) { | 300 } else if (use_gold) { |
306 ldflags += [ | 301 ldflags += [ "-fuse-ld=gold" ] |
307 "-B$gold_path", | 302 if (is_android) { |
| 303 if (is_clang) { |
| 304 _rebased_android_toolchain_root = |
| 305 rebase_path(android_toolchain_root, root_build_dir) |
308 | 306 |
309 # Newer gccs and clangs support -fuse-ld, use the flag to force gold | 307 # Let clang find the ld.gold in the NDK. |
310 # selection. | 308 ldflags += [ "--gcc-toolchain=$_rebased_android_toolchain_root" ] |
311 # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html | 309 } |
312 "-fuse-ld=gold", | |
313 | 310 |
314 # Experimentation found that using four linking threads | 311 # Use -mstackrealign due to a bug on ia32 Jelly Bean. |
315 # saved ~20% of link time. | 312 # See crbug.com/521527 |
316 # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_threa
d/thread/281527606915bb36 | 313 if (current_cpu == "x86") { |
317 # Only apply this to the target linker, since the host | 314 cflags += [ "-mstackrealign" ] |
318 # linker might not be gold, but isn't used much anyway. | 315 } |
319 # TODO(raymes): Disable threading because gold is frequently | 316 } else { |
320 # crashing on the bots: crbug.com/161942. | 317 ldflags += [ |
321 #"-Wl,--threads", | 318 "-B$gold_path", |
322 #"-Wl,--thread-count=4", | 319 # Experimentation found that using four linking threads |
323 ] | 320 # saved ~20% of link time. |
| 321 # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thr
ead/thread/281527606915bb36 |
| 322 # Only apply this to the target linker, since the host |
| 323 # linker might not be gold, but isn't used much anyway. |
| 324 # TODO(raymes): Disable threading because gold is frequently |
| 325 # crashing on the bots: crbug.com/161942. |
| 326 #"-Wl,--threads", |
| 327 #"-Wl,--thread-count=4", |
| 328 ] |
| 329 } |
324 | 330 |
325 if (gdb_index) { | 331 if (gdb_index) { |
326 ldflags += [ "-Wl,--gdb-index" ] | 332 ldflags += [ "-Wl,--gdb-index" ] |
327 } | 333 } |
328 | 334 |
329 # TODO(thestig): Make this flag work with GN. | 335 # TODO(thestig): Make this flag work with GN. |
330 #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan |
| is_msan)) { | 336 #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan |
| is_msan)) { |
331 # ldflags += [ | 337 # ldflags += [ |
332 # "-Wl,--detect-odr-violations", | 338 # "-Wl,--detect-odr-violations", |
333 # ] | 339 # ] |
334 #} | 340 #} |
335 } else if (linux_use_bundled_binutils) { | 341 } else if (linux_use_bundled_binutils) { |
336 # Gold is the default linker for the bundled binutils so we explicitly | 342 # Gold is the default linker for the bundled binutils so we explicitly |
337 # enable the bfd linker when use_gold is not set. | 343 # enable the bfd linker when use_gold is not set. |
338 ldflags += [ "-fuse-ld=bfd" ] | 344 ldflags += [ "-fuse-ld=bfd" ] |
| 345 } else if (is_android && current_cpu == "mipsel" && is_clang) { |
| 346 # Let clang find the ld.bfd in the NDK. |
| 347 _rebased_android_toolchain_root = |
| 348 rebase_path(android_toolchain_root, root_build_dir) |
| 349 ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ] |
339 } | 350 } |
340 | 351 |
341 if (is_posix && (use_gold || (use_lld && !is_nacl)) && !using_sanitizer && | 352 if (is_posix && (use_gold || (use_lld && !is_nacl)) && !using_sanitizer && |
342 !(is_android && use_order_profiling)) { | 353 !(is_android && use_order_profiling)) { |
343 # TODO(crbug.com/576197) - gcc on x86 platforms + gold + icf=all | 354 # TODO(crbug.com/576197) - gcc on x86 platforms + gold + icf=all |
344 # doesn't currently work. Once it does, use icf=all everywhere. | 355 # doesn't currently work. Once it does, use icf=all everywhere. |
| 356 # Additionally, on Android x86 --icf=safe seems to cause issues as well. |
345 if (is_clang || (target_cpu != "x86" && target_cpu != "x64")) { | 357 if (is_clang || (target_cpu != "x86" && target_cpu != "x64")) { |
346 ldflags += [ "-Wl,--icf=all" ] | 358 ldflags += [ "-Wl,--icf=all" ] |
347 } else { | 359 } else if (!is_android) { |
348 ldflags += [ "-Wl,--icf=safe" ] | 360 ldflags += [ "-Wl,--icf=safe" ] |
349 } | 361 } |
350 } | 362 } |
351 | 363 |
352 if (linux_use_bundled_binutils) { | 364 if (linux_use_bundled_binutils) { |
353 cflags += [ "-B$binutils_path" ] | 365 cflags += [ "-B$binutils_path" ] |
354 } | 366 } |
355 | 367 |
356 # Clang-specific compiler flags setup. | 368 # Clang-specific compiler flags setup. |
357 # ------------------------------------ | 369 # ------------------------------------ |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1447 |
1436 if (is_ios || is_mac) { | 1448 if (is_ios || is_mac) { |
1437 # On Mac and iOS, this enables support for ARC (automatic ref-counting). | 1449 # On Mac and iOS, this enables support for ARC (automatic ref-counting). |
1438 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. | 1450 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. |
1439 config("enable_arc") { | 1451 config("enable_arc") { |
1440 common_flags = [ "-fobjc-arc" ] | 1452 common_flags = [ "-fobjc-arc" ] |
1441 cflags_objc = common_flags | 1453 cflags_objc = common_flags |
1442 cflags_objcc = common_flags | 1454 cflags_objcc = common_flags |
1443 } | 1455 } |
1444 } | 1456 } |
OLD | NEW |