| 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") |  | 
| 7 if (current_cpu == "arm") { | 6 if (current_cpu == "arm") { | 
| 8   import("//build/config/arm.gni") | 7   import("//build/config/arm.gni") | 
| 9 } | 8 } | 
| 10 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | 9 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | 
| 11   import("//build/config/mips.gni") | 10   import("//build/config/mips.gni") | 
| 12 } | 11 } | 
| 13 if (is_posix) { | 12 if (is_posix) { | 
| 14   import("//build/config/gcc/gcc_version.gni") | 13   import("//build/config/gcc/gcc_version.gni") | 
| 15 } | 14 } | 
| 16 if (is_win) { | 15 if (is_win) { | 
| 17   import("//build/config/win/visual_studio_version.gni") | 16   import("//build/config/win/visual_studio_version.gni") | 
| 18 } | 17 } | 
| 19 | 18 | 
| 20 import("//build/toolchain/ccache.gni") | 19 import("//build/toolchain/ccache.gni") | 
| 21 import("//build/config/sanitizers/sanitizers.gni") | 20 import("//build/config/sanitizers/sanitizers.gni") | 
| 22 | 21 | 
| 23 declare_args() { | 22 declare_args() { | 
| 24   # Normally, Android builds are lightly optimized, even for debug builds, to |  | 
| 25   # keep binary size down. Setting this flag to true disables such optimization |  | 
| 26   android_full_debug = false |  | 
| 27 |  | 
| 28   # Whether to use the binary binutils checked into third_party/binutils. |  | 
| 29   # These are not multi-arch so cannot be used except on x86 and x86-64 (the |  | 
| 30   # only two architectures that are currently checked in). Turn this off when |  | 
| 31   # you are using a custom toolchain and need to control -B in cflags. |  | 
| 32   linux_use_bundled_binutils = is_linux && current_cpu == "x64" |  | 
| 33 |  | 
| 34   # Compile in such a way as to enable profiling of the generated code. For |  | 
| 35   # example, don't omit the frame pointer and leave in symbols. |  | 
| 36   enable_profiling = false |  | 
| 37 |  | 
| 38   # Compile in such a way as to make it possible for the profiler to unwind full |  | 
| 39   # stack frames. Setting this flag has a large effect on the performance of the |  | 
| 40   # generated code than just setting profiling, but gives the profiler more |  | 
| 41   # information to analyze. |  | 
| 42   # Requires profiling to be set to true. |  | 
| 43   enable_full_stack_frames_for_profiling = false |  | 
| 44 |  | 
| 45   # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of |  | 
| 46   # address space, and it doesn't support cross-compiling). |  | 
| 47   use_gold = is_linux && current_cpu == "x64" |  | 
| 48 |  | 
| 49   # use_debug_fission: whether to use split DWARF debug info |  | 
| 50   # files. This can reduce link time significantly, but is incompatible |  | 
| 51   # with some utilities such as icecc and ccache. Requires gold and |  | 
| 52   # gcc >= 4.8 or clang. |  | 
| 53   # http://gcc.gnu.org/wiki/DebugFission |  | 
| 54   use_debug_fission = is_debug && !is_win && use_gold && |  | 
| 55                       linux_use_bundled_binutils && !use_ccache |  | 
| 56 |  | 
| 57   if (is_win) { | 23   if (is_win) { | 
| 58     # Whether the VS xtree header has been patched to disable warning 4702. If | 24     # Whether the VS xtree header has been patched to disable warning 4702. If | 
| 59     # it has, then we don't need to disable 4702 (unreachable code warning). | 25     # it has, then we don't need to disable 4702 (unreachable code warning). | 
| 60     # The patch is preapplied to the internal toolchain and hence all bots. | 26     # The patch is preapplied to the internal toolchain and hence all bots. | 
| 61     msvs_xtree_patched = false | 27     msvs_xtree_patched = false | 
| 62   } | 28   } | 
| 63 } | 29 } | 
| 64 | 30 | 
| 65 # default_include_dirs --------------------------------------------------------- | 31 # default_include_dirs --------------------------------------------------------- | 
| 66 # | 32 # | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 136         cflags += [ | 102         cflags += [ | 
| 137           # cmd.exe doesn't understand ANSI escape codes by default, | 103           # cmd.exe doesn't understand ANSI escape codes by default, | 
| 138           # so only enable them if something emulating them is around. | 104           # so only enable them if something emulating them is around. | 
| 139           "-fansi-escape-codes", | 105           "-fansi-escape-codes", | 
| 140         ] | 106         ] | 
| 141       } | 107       } | 
| 142     } | 108     } | 
| 143   } else { | 109   } else { | 
| 144     # Common GCC compiler flags setup. | 110     # Common GCC compiler flags setup. | 
| 145     # -------------------------------- | 111     # -------------------------------- | 
| 146     cflags += [ "-fno-strict-aliasing" ]  # See http://crbug.com/32204 |  | 
| 147     common_flags = [ | 112     common_flags = [ | 
| 148       # Not exporting C++ inline functions can generally be applied anywhere | 113       # Not exporting C++ inline functions can generally be applied anywhere | 
| 149       # so we do so here. Normal function visibility is controlled by | 114       # so we do so here. Normal function visibility is controlled by | 
| 150       # //build/config/gcc:symbol_visibility_hidden. | 115       # //build/config/gcc:symbol_visibility_hidden. | 
| 151       "-fvisibility-inlines-hidden", | 116       "-fvisibility-inlines-hidden", | 
| 152     ] | 117     ] | 
| 153     cflags_cc += common_flags | 118     cflags_cc += common_flags | 
| 154     cflags_objcc += common_flags | 119     cflags_objcc += common_flags | 
| 155 | 120 | 
| 156     # Stack protection. |  | 
| 157     if (is_mac) { |  | 
| 158       cflags += [ "-fstack-protector-all" ] |  | 
| 159     } else if (is_linux) { |  | 
| 160       cflags += [ |  | 
| 161         "-fstack-protector", |  | 
| 162         "--param=ssp-buffer-size=4", |  | 
| 163       ] |  | 
| 164     } |  | 
| 165 |  | 
| 166     # Linker warnings. | 121     # Linker warnings. | 
| 167     if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) { | 122     if ((current_cpu != "arm") && !is_mac) { | 
| 168       # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 | 123       # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 | 
| 169       ldflags += [ "-Wl,--fatal-warnings" ] | 124       ldflags += [ "-Wl,--fatal-warnings" ] | 
| 170     } | 125     } | 
| 171 | 126 | 
| 172     # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and | 127     # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and | 
| 173     # MemorySanitizer | 128     # MemorySanitizer | 
| 174     if (using_sanitizer) { | 129     if (using_sanitizer) { | 
| 175       cflags += [ | 130       cflags += [ | 
| 176         "-fno-omit-frame-pointer", | 131         "-fno-omit-frame-pointer", | 
| 177         "-gline-tables-only", | 132         "-gline-tables-only", | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 210       ] | 165       ] | 
| 211     } | 166     } | 
| 212 | 167 | 
| 213     if (use_custom_libcxx) { | 168     if (use_custom_libcxx) { | 
| 214       cflags_cc += [ "-nostdinc++" ] | 169       cflags_cc += [ "-nostdinc++" ] | 
| 215       include_dirs = [ | 170       include_dirs = [ | 
| 216         "//buildtools/third_party/libc++/trunk/include", | 171         "//buildtools/third_party/libc++/trunk/include", | 
| 217         "//buildtools/third_party/libc++abi/trunk/include", | 172         "//buildtools/third_party/libc++abi/trunk/include", | 
| 218       ] | 173       ] | 
| 219     } | 174     } | 
| 220 |  | 
| 221     if (is_fnl) { |  | 
| 222       # TODO(kulakowski) remove when fnl no longer uses gcc |  | 
| 223       cflags += [ "-Wno-maybe-uninitialized" ] |  | 
| 224     } |  | 
| 225   } | 175   } | 
| 226 | 176 | 
| 227   if (is_clang && is_debug) { | 177   if (is_clang && is_debug) { | 
| 228     # Allow comparing the address of references and 'this' against 0 | 178     # Allow comparing the address of references and 'this' against 0 | 
| 229     # in debug builds. Technically, these can never be null in | 179     # in debug builds. Technically, these can never be null in | 
| 230     # well-defined C/C++ and Clang can optimize such checks away in | 180     # well-defined C/C++ and Clang can optimize such checks away in | 
| 231     # release builds, but they may be used in asserts in debug builds. | 181     # release builds, but they may be used in asserts in debug builds. | 
| 232     extra_flags = [ | 182     extra_flags = [ | 
| 233       "-Wno-undefined-bool-conversion", | 183       "-Wno-undefined-bool-conversion", | 
| 234       "-Wno-tautological-undefined-compare", | 184       "-Wno-tautological-undefined-compare", | 
| 235     ] | 185     ] | 
| 236     cflags_cc += extra_flags | 186     cflags_cc += extra_flags | 
| 237     cflags_objcc += extra_flags | 187     cflags_objcc += extra_flags | 
| 238   } | 188   } | 
| 239 | 189 | 
| 240   if (is_clang && !is_nacl) { | 190   if (is_clang) { | 
| 241     # This is here so that all files get recompiled after a clang roll and | 191     # This is here so that all files get recompiled after a clang roll and | 
| 242     # when turning clang on or off. (defines are passed via the command line, | 192     # when turning clang on or off. (defines are passed via the command line, | 
| 243     # and build system rebuild things when their commandline changes). Nothing | 193     # and build system rebuild things when their commandline changes). Nothing | 
| 244     # should ever read this define. | 194     # should ever read this define. | 
| 245     defines += | 195     defines += | 
| 246         [ "CR_CLANG_REVISION=" + exec_script("//tools/clang/scripts/update.py", | 196         [ "CR_CLANG_REVISION=" + exec_script("//tools/clang/scripts/update.py", | 
| 247                                              [ "--print-revision" ], | 197                                              [ "--print-revision" ], | 
| 248                                              "trim string") ] | 198                                              "trim string") ] | 
| 249   } | 199   } | 
| 250 | 200 | 
| 251   # Mac-specific compiler flags setup. | 201   # Mac-specific compiler flags setup. | 
| 252   # ---------------------------------- | 202   # ---------------------------------- | 
| 253   if (is_mac || is_ios) { | 203   if (is_mac) { | 
| 254     # These flags are shared between the C compiler and linker. | 204     # These flags are shared between the C compiler and linker. | 
| 255     common_mac_flags = [] | 205     common_mac_flags = [] | 
| 256 | 206 | 
| 257     # CPU architecture. | 207     # CPU architecture. | 
| 258     if (current_cpu == "x64") { | 208     if (current_cpu == "x64") { | 
| 259       common_mac_flags += [ | 209       common_mac_flags += [ | 
| 260         "-arch", | 210         "-arch", | 
| 261         "x86_64", | 211         "x86_64", | 
| 262       ] | 212       ] | 
| 263     } else if (current_cpu == "x86") { | 213     } else if (current_cpu == "x86") { | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 303           # Else building libyuv gives clang's register allocator issues, | 253           # Else building libyuv gives clang's register allocator issues, | 
| 304           # see llvm.org/PR15798 / crbug.com/233709 | 254           # see llvm.org/PR15798 / crbug.com/233709 | 
| 305           "-momit-leaf-frame-pointer", | 255           "-momit-leaf-frame-pointer", | 
| 306 | 256 | 
| 307           # Align the stack on 16-byte boundaries, http://crbug.com/418554. | 257           # Align the stack on 16-byte boundaries, http://crbug.com/418554. | 
| 308           "-mstack-alignment=16", | 258           "-mstack-alignment=16", | 
| 309           "-mstackrealign", | 259           "-mstackrealign", | 
| 310         ] | 260         ] | 
| 311       } | 261       } | 
| 312     } else if (current_cpu == "arm") { | 262     } else if (current_cpu == "arm") { | 
|  | 263 | 
| 313       cflags += [ | 264       cflags += [ | 
| 314         "-march=$arm_arch", | 265         "-march=$arm_arch", | 
| 315         "-mfloat-abi=$arm_float_abi", | 266         "-mfloat-abi=$arm_float_abi", | 
| 316       ] | 267       ] | 
| 317       if (arm_tune != "") { | 268       if (arm_tune != "") { | 
| 318         cflags += [ "-mtune=$arm_tune" ] | 269         cflags += [ "-mtune=$arm_tune" ] | 
| 319       } | 270       } | 
| 320       if (arm_use_thumb) { | 271       if (arm_use_thumb) { | 
| 321         cflags += [ "-mthumb" ] | 272         cflags += [ "-mthumb" ] | 
| 322         if (is_android && !is_clang) {  # Clang doesn't support this option. | 273         if (is_android && !is_clang) {  # Clang doesn't support this option. | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 381         ldflags += [ "-mips64r6" ] | 332         ldflags += [ "-mips64r6" ] | 
| 382       } else if (mips_arch_variant == "r2") { | 333       } else if (mips_arch_variant == "r2") { | 
| 383         cflags += [ | 334         cflags += [ | 
| 384           "-mips64r2", | 335           "-mips64r2", | 
| 385           "-Wa,-mips64r2", | 336           "-Wa,-mips64r2", | 
| 386         ] | 337         ] | 
| 387         ldflags += [ "-mips64r2" ] | 338         ldflags += [ "-mips64r2" ] | 
| 388       } | 339       } | 
| 389     } | 340     } | 
| 390 | 341 | 
| 391     defines += [ "_FILE_OFFSET_BITS=64" ] | 342     cflags += [ "-funwind-tables" ] | 
| 392 |  | 
| 393     if (!is_android) { |  | 
| 394       defines += [ |  | 
| 395         "_LARGEFILE_SOURCE", |  | 
| 396         "_LARGEFILE64_SOURCE", |  | 
| 397       ] |  | 
| 398     } |  | 
| 399 |  | 
| 400     # Omit unwind support in official builds to save space. We can use breakpad |  | 
| 401     # for these builds. |  | 
| 402     if (is_chrome_branded && is_official_build) { |  | 
| 403       cflags += [ |  | 
| 404         "-fno-unwind-tables", |  | 
| 405         "-fno-asynchronous-unwind-tables", |  | 
| 406       ] |  | 
| 407       defines += [ "NO_UNWIND_TABLES" ] |  | 
| 408     } else { |  | 
| 409       cflags += [ "-funwind-tables" ] |  | 
| 410     } |  | 
| 411   } |  | 
| 412 |  | 
| 413   if (enable_profiling && !is_debug) { |  | 
| 414     # The GYP build spams this define into every compilation unit, as we do |  | 
| 415     # here, but it only appears to be used in base and a couple other places. |  | 
| 416     # TODO(abarth): Should we move this define closer to where it's used? |  | 
| 417     defines += [ "ENABLE_PROFILING" ] |  | 
| 418 |  | 
| 419     cflags += [ |  | 
| 420       "-fno-omit-frame-pointer", |  | 
| 421       "-g", |  | 
| 422     ] |  | 
| 423 |  | 
| 424     if (enable_full_stack_frames_for_profiling) { |  | 
| 425       cflags += [ |  | 
| 426         "-fno-inline", |  | 
| 427         "-fno-optimize-sibling-calls", |  | 
| 428       ] |  | 
| 429     } |  | 
| 430   } | 343   } | 
| 431 | 344 | 
| 432   # Linux/Android common flags setup. | 345   # Linux/Android common flags setup. | 
| 433   # --------------------------------- | 346   # --------------------------------- | 
| 434   if (is_linux || is_android) { | 347   if (is_linux || is_android) { | 
| 435     cflags += [ | 348     cflags += [ | 
| 436       "-fPIC", | 349       "-fPIC", | 
| 437       "-pipe",  # Use pipes for communicating between sub-processes. Faster. |  | 
| 438     ] | 350     ] | 
| 439 | 351 | 
| 440     ldflags += [ | 352     ldflags += [ | 
| 441       "-fPIC", | 353       "-fPIC", | 
| 442       "-Wl,-z,noexecstack", | 354       "-Wl,-z,noexecstack", | 
| 443       "-Wl,-z,now", | 355       "-Wl,-z,now", | 
| 444       "-Wl,-z,relro", | 356       "-Wl,-z,relro", | 
| 445     ] | 357     ] | 
| 446     if (!using_sanitizer) { |  | 
| 447       ldflags += [ "-Wl,-z,defs" ] |  | 
| 448     } |  | 
| 449   } | 358   } | 
| 450 | 359 | 
| 451   # Linux-specific compiler flags setup. | 360   # Linux-specific compiler flags setup. | 
| 452   # ------------------------------------ | 361   # ------------------------------------ | 
| 453   if (is_linux) { | 362   if (is_linux) { | 
| 454     cflags += [ "-pthread" ] | 363     cflags += [ "-pthread" ] | 
| 455     ldflags += [ "-pthread" ] | 364     ldflags += [ "-pthread" ] | 
| 456   } | 365   } | 
| 457   if (use_gold) { |  | 
| 458     gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |  | 
| 459                             root_build_dir) |  | 
| 460     ldflags += [ |  | 
| 461       "-B$gold_path", |  | 
| 462 |  | 
| 463       # Newer gccs and clangs support -fuse-ld, use the flag to force gold |  | 
| 464       # selection. |  | 
| 465       # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html |  | 
| 466       "-fuse-ld=gold", |  | 
| 467 |  | 
| 468       # Experimentation found that using four linking threads |  | 
| 469       # saved ~20% of link time. |  | 
| 470       # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_threa
      d/thread/281527606915bb36 |  | 
| 471       # Only apply this to the target linker, since the host |  | 
| 472       # linker might not be gold, but isn't used much anyway. |  | 
| 473       # TODO(raymes): Disable threading because gold is frequently |  | 
| 474       # crashing on the bots: crbug.com/161942. |  | 
| 475       #"-Wl,--threads", |  | 
| 476       #"-Wl,--thread-count=4", |  | 
| 477     ] |  | 
| 478 |  | 
| 479     if (!is_asan && !is_msan && !is_lsan && !is_tsan) { |  | 
| 480       # TODO(brettw) common.gypi has this only for target toolset. |  | 
| 481       ldflags += [ "-Wl,--icf=all" ] |  | 
| 482     } |  | 
| 483 |  | 
| 484     # TODO(thestig): Make this flag work with GN. |  | 
| 485     #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan |
      | is_msan)) { |  | 
| 486     #  ldflags += [ |  | 
| 487     #    "-Wl,--detect-odr-violations", |  | 
| 488     #  ] |  | 
| 489     #} |  | 
| 490   } |  | 
| 491 |  | 
| 492   if (linux_use_bundled_binutils) { |  | 
| 493     binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |  | 
| 494                                 root_build_dir) |  | 
| 495     cflags += [ "-B$binutils_path" ] |  | 
| 496   } |  | 
| 497 | 366 | 
| 498   # Clang-specific compiler flags setup. | 367   # Clang-specific compiler flags setup. | 
| 499   # ------------------------------------ | 368   # ------------------------------------ | 
| 500   if (is_clang) { | 369   if (is_clang) { | 
| 501     cflags += [ "-fcolor-diagnostics" ] | 370     cflags += [ "-fcolor-diagnostics" ] | 
| 502   } | 371   } | 
| 503 | 372 | 
| 504   # C++11 compiler flags setup. |  | 
| 505   # --------------------------- |  | 
| 506   if (is_linux || is_android || is_nacl) { |  | 
| 507     # gnu++11 instead of c++11 is needed because some code uses typeof() (a |  | 
| 508     # GNU extension). |  | 
| 509     # TODO(thakis): Eventually switch this to c++11 instead, |  | 
| 510     # http://crbug.com/427584 |  | 
| 511     cflags_cc += [ "-std=gnu++11" ] |  | 
| 512   } else if (!is_win) { |  | 
| 513     cc_std = [ "-std=c++11" ] |  | 
| 514     cflags_cc += cc_std |  | 
| 515     cflags_objcc += cc_std |  | 
| 516   } |  | 
| 517 |  | 
| 518   # Android-specific flags setup. | 373   # Android-specific flags setup. | 
| 519   # ----------------------------- | 374   # ----------------------------- | 
| 520   if (is_android) { | 375   if (is_android) { | 
| 521     cflags += [ | 376     cflags += [ | 
| 522       "-ffunction-sections", | 377       "-ffunction-sections", | 
| 523       "-funwind-tables", | 378       "-funwind-tables", | 
| 524       "-fno-short-enums", | 379       "-fno-short-enums", | 
| 525     ] | 380     ] | 
| 526     if (!is_clang) { | 381     if (!is_clang) { | 
| 527       # Clang doesn't support these flags. | 382       # Clang doesn't support these flags. | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 545     if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { | 400     if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { | 
| 546       ldflags += [ "-fuse-ld=gold" ] | 401       ldflags += [ "-fuse-ld=gold" ] | 
| 547       if (is_clang) { | 402       if (is_clang) { | 
| 548         # Let clang find the ld.gold in the NDK. | 403         # Let clang find the ld.gold in the NDK. | 
| 549         ldflags += [ "--gcc-toolchain=" + | 404         ldflags += [ "--gcc-toolchain=" + | 
| 550                      rebase_path(android_toolchain_root, root_build_dir) ] | 405                      rebase_path(android_toolchain_root, root_build_dir) ] | 
| 551       } | 406       } | 
| 552     } | 407     } | 
| 553 | 408 | 
| 554     ldflags += [ | 409     ldflags += [ | 
| 555       "-Wl,--no-undefined", |  | 
| 556 |  | 
| 557       # Don't allow visible symbols from libgcc or libc++ to be | 410       # Don't allow visible symbols from libgcc or libc++ to be | 
| 558       # re-exported. | 411       # re-exported. | 
| 559       "-Wl,--exclude-libs=libgcc.a", | 412       "-Wl,--exclude-libs=libgcc.a", | 
| 560       "-Wl,--exclude-libs=libc++_static.a", | 413       "-Wl,--exclude-libs=libc++_static.a", | 
| 561 |  | 
| 562       # Don't allow visible symbols from libraries that contain |  | 
| 563       # assembly code with symbols that aren't hidden properly. |  | 
| 564       # http://crbug.com/448386 |  | 
| 565       "-Wl,--exclude-libs=libvpx_assembly_arm.a", |  | 
| 566     ] | 414     ] | 
| 567     if (current_cpu == "arm") { | 415     if (current_cpu == "arm") { | 
| 568       ldflags += [ | 416       ldflags += [ | 
| 569         # Enable identical code folding to reduce size. | 417         # Enable identical code folding to reduce size. | 
| 570         "-Wl,--icf=safe", | 418         "-Wl,--icf=safe", | 
| 571       ] | 419       ] | 
| 572     } | 420     } | 
| 573 | 421 | 
| 574     if (is_clang) { | 422     if (is_clang) { | 
| 575       if (current_cpu == "arm") { | 423       if (current_cpu == "arm") { | 
| 576         cflags += [ "--target=arm-linux-androideabi" ] | 424         cflags += [ "--target=arm-linux-androideabi" ] | 
| 577         ldflags += [ "--target=arm-linux-androideabi" ] | 425         ldflags += [ "--target=arm-linux-androideabi" ] | 
| 578       } else if (current_cpu == "x86") { | 426       } else if (current_cpu == "x86") { | 
| 579         cflags += [ "--target=x86-linux-androideabi" ] | 427         cflags += [ "--target=x86-linux-androideabi" ] | 
| 580         ldflags += [ "--target=x86-linux-androideabi" ] | 428         ldflags += [ "--target=x86-linux-androideabi" ] | 
| 581       } | 429       } | 
| 582     } | 430     } | 
| 583   } | 431   } | 
| 584 } | 432 } | 
| 585 | 433 | 
| 586 config("compiler_arm_fpu") { | 434 config("compiler_arm_fpu") { | 
| 587   if (current_cpu == "arm" && !is_ios) { | 435   if (current_cpu == "arm") { | 
| 588     cflags = [ "-mfpu=$arm_fpu" ] | 436     cflags = [ "-mfpu=$arm_fpu" ] | 
| 589   } | 437   } | 
| 590 } | 438 } | 
| 591 | 439 | 
| 592 # runtime_library ------------------------------------------------------------- | 440 # runtime_library ------------------------------------------------------------- | 
| 593 # | 441 # | 
| 594 # Sets the runtime library and associated options. | 442 # Sets the runtime library and associated options. | 
| 595 # | 443 # | 
| 596 # How do you determine what should go in here vs. "compiler" above? Consider if | 444 # How do you determine what should go in here vs. "compiler" above? Consider if | 
| 597 # a target might choose to use a different runtime library (ignore for a moment | 445 # a target might choose to use a different runtime library (ignore for a moment | 
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 826 | 674 | 
| 827     # Disables. | 675     # Disables. | 
| 828     "-Wno-missing-field-initializers",  # "struct foo f = {0};" | 676     "-Wno-missing-field-initializers",  # "struct foo f = {0};" | 
| 829     "-Wno-unused-parameter",  # Unused function parameters. | 677     "-Wno-unused-parameter",  # Unused function parameters. | 
| 830   ] | 678   ] | 
| 831 | 679 | 
| 832   if (is_mac) { | 680   if (is_mac) { | 
| 833     # TODO(abarth): Re-enable once https://github.com/domokit/mojo/issues/728 | 681     # TODO(abarth): Re-enable once https://github.com/domokit/mojo/issues/728 | 
| 834     #               is fixed. | 682     #               is fixed. | 
| 835     # default_warning_flags += [ "-Wnewline-eof" ] | 683     # default_warning_flags += [ "-Wnewline-eof" ] | 
| 836     if (!is_nacl) { |  | 
| 837       # When compiling Objective-C, warns if a method is used whose |  | 
| 838       # availability is newer than the deployment target. This is not |  | 
| 839       # required when compiling Chrome for iOS. |  | 
| 840       default_warning_flags += [ "-Wpartial-availability" ] |  | 
| 841     } |  | 
| 842   } |  | 
| 843 | 684 | 
| 844   if (gcc_version >= 48) { | 685     # When compiling Objective-C, warns if a method is used whose | 
| 845     default_warning_flags_cc += [ | 686     # availability is newer than the deployment target. This is not | 
| 846       # See comment for -Wno-c++11-narrowing. | 687     # required when compiling Chrome for iOS. | 
| 847       "-Wno-narrowing", | 688     default_warning_flags += [ "-Wpartial-availability" ] | 
| 848     ] |  | 
| 849   } | 689   } | 
| 850 | 690 | 
| 851   # Suppress warnings about ABI changes on ARM (Clang doesn't give this | 691   # Suppress warnings about ABI changes on ARM (Clang doesn't give this | 
| 852   # warning). | 692   # warning). | 
| 853   if (current_cpu == "arm" && !is_clang) { | 693   if (current_cpu == "arm" && !is_clang) { | 
| 854     default_warning_flags += [ "-Wno-psabi" ] | 694     default_warning_flags += [ "-Wno-psabi" ] | 
| 855   } | 695   } | 
| 856 | 696 | 
| 857   if (is_android) { | 697   if (is_android) { | 
| 858     # Disable any additional warnings enabled by the Android build system but | 698     # Disable any additional warnings enabled by the Android build system but | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 876     ] | 716     ] | 
| 877   } | 717   } | 
| 878 | 718 | 
| 879   if (gcc_version >= 48) { | 719   if (gcc_version >= 48) { | 
| 880     # Don't warn about the "typedef 'foo' locally defined but not used" | 720     # Don't warn about the "typedef 'foo' locally defined but not used" | 
| 881     # for gcc 4.8. | 721     # for gcc 4.8. | 
| 882     # TODO: remove this flag once all builds work. See crbug.com/227506 | 722     # TODO: remove this flag once all builds work. See crbug.com/227506 | 
| 883     default_warning_flags += [ "-Wno-unused-local-typedefs" ] | 723     default_warning_flags += [ "-Wno-unused-local-typedefs" ] | 
| 884   } | 724   } | 
| 885 } | 725 } | 
| 886 if (is_clang) { |  | 
| 887   default_warning_flags += [ |  | 
| 888     # This warns on using ints as initializers for floats in |  | 
| 889     # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), |  | 
| 890     # which happens in several places in chrome code. Not sure if |  | 
| 891     # this is worth fixing. |  | 
| 892     "-Wno-c++11-narrowing", |  | 
| 893 |  | 
| 894     # Don't die on dtoa code that uses a char as an array index. |  | 
| 895     # This is required solely for base/third_party/dmg_fp/dtoa.cc. |  | 
| 896     # TODO(brettw) move this to that project then! |  | 
| 897     "-Wno-char-subscripts", |  | 
| 898 |  | 
| 899     # Warns on switches on enums that cover all enum values but |  | 
| 900     # also contain a default: branch. Chrome is full of that. |  | 
| 901     "-Wno-covered-switch-default", |  | 
| 902 |  | 
| 903     # Clang considers the `register` keyword as deprecated, but e.g. |  | 
| 904     # code generated by flex (used in angle) contains that keyword. |  | 
| 905     # http://crbug.com/255186 |  | 
| 906     "-Wno-deprecated-register", |  | 
| 907   ] |  | 
| 908 |  | 
| 909   # NaCl's Clang compiler and Chrome's hermetic Clang compiler will almost |  | 
| 910   # always have different versions. Certain flags may not be recognized by |  | 
| 911   # one version or the other. |  | 
| 912   if (!is_nacl) { |  | 
| 913     # Flags NaCl does not recognize. |  | 
| 914     default_warning_flags += [ |  | 
| 915       # TODO(hans): Get this cleaned up, http://crbug.com/428099 |  | 
| 916       "-Wno-inconsistent-missing-override", |  | 
| 917 |  | 
| 918       # TODO(thakis): Enable this, crbug.com/507717 |  | 
| 919       "-Wno-shift-negative-value", |  | 
| 920     ] |  | 
| 921   } |  | 
| 922 } |  | 
| 923 | 726 | 
| 924 # chromium_code --------------------------------------------------------------- | 727 # chromium_code --------------------------------------------------------------- | 
| 925 # | 728 # | 
| 926 # Toggles between higher and lower warnings for code that is (or isn't) | 729 # Toggles between higher and lower warnings for code that is (or isn't) | 
| 927 # part of Chromium. | 730 # part of Chromium. | 
| 928 | 731 | 
| 929 config("chromium_code") { | 732 config("chromium_code") { | 
| 930   if (is_win) { | 733   if (is_win) { | 
| 931     cflags = [ "/W4" ]  # Warning level 4. | 734     cflags = [ "/W4" ]  # Warning level 4. | 
| 932   } else { | 735   } else { | 
| 933     cflags = [ | 736     cflags = [ | 
| 934       "-Wall", | 737       "-Wall", | 
| 935       "-Wextra", | 738       "-Wextra", | 
| 936     ] | 739     ] | 
| 937 | 740 | 
| 938     # In Chromium code, we define __STDC_foo_MACROS in order to get the | 741     defines = [] | 
| 939     # C99 macros on Mac and Linux. | 742     if (!using_sanitizer && (!is_linux || !is_clang)) { | 
| 940     defines = [ |  | 
| 941       "__STDC_CONSTANT_MACROS", |  | 
| 942       "__STDC_FORMAT_MACROS", |  | 
| 943     ] |  | 
| 944 |  | 
| 945     if (!using_sanitizer && (!is_linux || !is_clang || is_official_build)) { |  | 
| 946       # _FORTIFY_SOURCE isn't really supported by Clang now, see | 743       # _FORTIFY_SOURCE isn't really supported by Clang now, see | 
| 947       # http://llvm.org/bugs/show_bug.cgi?id=16821. | 744       # http://llvm.org/bugs/show_bug.cgi?id=16821. | 
| 948       # It seems to work fine with Ubuntu 12 headers though, so use it in | 745       # It seems to work fine with Ubuntu 12 headers though, so use it in | 
| 949       # official builds. | 746       # official builds. | 
| 950       # | 747       # | 
| 951       # Non-chromium code is not guaranteed to compile cleanly with | 748       # Non-chromium code is not guaranteed to compile cleanly with | 
| 952       # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are | 749       # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are | 
| 953       # disabled, so only do that for Release build. | 750       # disabled, so only do that for Release build. | 
| 954       defines += [ "_FORTIFY_SOURCE=2" ] | 751       defines += [ "_FORTIFY_SOURCE=2" ] | 
| 955     } | 752     } | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 968       "/wd4800",  # Disable warning when forcing value to bool. | 765       "/wd4800",  # Disable warning when forcing value to bool. | 
| 969       "/wd4267",  # TODO(jschuh): size_t to int. | 766       "/wd4267",  # TODO(jschuh): size_t to int. | 
| 970       "/wd4996",  # Deprecated function warning. | 767       "/wd4996",  # Deprecated function warning. | 
| 971     ] | 768     ] | 
| 972     defines += [ | 769     defines += [ | 
| 973       "_CRT_NONSTDC_NO_WARNINGS", | 770       "_CRT_NONSTDC_NO_WARNINGS", | 
| 974       "_CRT_NONSTDC_NO_DEPRECATE", | 771       "_CRT_NONSTDC_NO_DEPRECATE", | 
| 975     ] | 772     ] | 
| 976   } | 773   } | 
| 977 | 774 | 
| 978   if (is_linux) { |  | 
| 979     # Don't warn about ignoring the return value from e.g. close(). This is |  | 
| 980     # off by default in some gccs but on by default in others. BSD systems do |  | 
| 981     # not support this option, since they are usually using gcc 4.2.1, which |  | 
| 982     # does not have this flag yet. |  | 
| 983     cflags += [ "-Wno-unused-result" ] |  | 
| 984   } |  | 
| 985 |  | 
| 986   if (is_clang) { |  | 
| 987     cflags += [ |  | 
| 988       # TODO(mgiuca): Move this suppression into individual third-party |  | 
| 989       # libraries as required. http://crbug.com/505301. |  | 
| 990       "-Wno-overloaded-virtual", |  | 
| 991 |  | 
| 992       # Lots of third-party libraries have unused variables. Instead of |  | 
| 993       # suppressing them individually, we just blanket suppress them here. |  | 
| 994       "-Wno-unused-variable", |  | 
| 995     ] |  | 
| 996   } |  | 
| 997 |  | 
| 998   if (is_linux || is_android) { |  | 
| 999     cflags += [ |  | 
| 1000       # Don't warn about printf format problems. This is off by default in gcc |  | 
| 1001       # but on in Ubuntu's gcc(!). |  | 
| 1002       "-Wno-format", |  | 
| 1003     ] |  | 
| 1004     cflags_cc += [ |  | 
| 1005       # Don't warn about hash_map in third-party code. |  | 
| 1006       "-Wno-deprecated", |  | 
| 1007     ] |  | 
| 1008   } |  | 
| 1009   cflags += default_warning_flags | 775   cflags += default_warning_flags | 
| 1010   cflags_cc += default_warning_flags_cc | 776   cflags_cc += default_warning_flags_cc | 
| 1011 } | 777 } | 
| 1012 | 778 | 
| 1013 # rtti ------------------------------------------------------------------------ | 779 # rtti ------------------------------------------------------------------------ | 
| 1014 # | 780 # | 
| 1015 # Allows turning Run-Time Type Identification on or off. | 781 # Allows turning Run-Time Type Identification on or off. | 
| 1016 | 782 | 
| 1017 config("rtti") { | 783 config("rtti") { | 
| 1018   if (is_win) { | 784   if (is_win) { | 
| 1019     cflags_cc = [ "/GR" ] | 785     cflags_cc = [ "/GR" ] | 
| 1020   } | 786   } | 
| 1021 } | 787 } | 
| 1022 config("no_rtti") { | 788 config("no_rtti") { | 
| 1023   if (is_win) { | 789   if (is_win) { | 
| 1024     cflags_cc = [ "/GR-" ] | 790     cflags_cc = [ "/GR-" ] | 
| 1025   } else { | 791   } else { | 
| 1026     rtti_flags = [ "-fno-rtti" ] | 792     rtti_flags = [ "-fno-rtti" ] | 
| 1027     cflags_cc = rtti_flags | 793     cflags_cc = rtti_flags | 
| 1028     cflags_objcc = rtti_flags | 794     cflags_objcc = rtti_flags | 
| 1029   } | 795   } | 
| 1030 } | 796 } | 
| 1031 | 797 | 
| 1032 # Warnings --------------------------------------------------------------------- |  | 
| 1033 |  | 
| 1034 # This will generate warnings when using Clang if code generates exit-time |  | 
| 1035 # destructors, which will slow down closing the program. |  | 
| 1036 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 |  | 
| 1037 config("wexit_time_destructors") { |  | 
| 1038   # TODO: Enable on Windows too, http://crbug.com/404525 |  | 
| 1039   if (is_clang && !is_win) { |  | 
| 1040     cflags = [ "-Wexit-time-destructors" ] |  | 
| 1041   } |  | 
| 1042 } |  | 
| 1043 |  | 
| 1044 # On Windows compiling on x64, VC will issue a warning when converting |  | 
| 1045 # size_t to int because it will truncate the value. Our code should not have |  | 
| 1046 # these warnings and one should use a static_cast or a checked_cast for the |  | 
| 1047 # conversion depending on the case. However, a lot of code still needs to be |  | 
| 1048 # fixed. Apply this config to such targets to disable the warning. |  | 
| 1049 # |  | 
| 1050 # Note that this can be applied regardless of platform and architecture to |  | 
| 1051 # clean up the call sites. This will only apply the flag when necessary. |  | 
| 1052 # |  | 
| 1053 # TODO(jschuh): crbug.com/167187 fix this and delete this config. |  | 
| 1054 config("no_size_t_to_int_warning") { |  | 
| 1055   if (is_win && current_cpu == "x64") { |  | 
| 1056     cflags = [ "/wd4267" ] |  | 
| 1057   } |  | 
| 1058 } |  | 
| 1059 |  | 
| 1060 # Optimization ----------------------------------------------------------------- | 798 # Optimization ----------------------------------------------------------------- | 
| 1061 # | 799 # | 
| 1062 # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config" | 800 # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config" | 
| 1063 # which it will assign to the config it implicitly applies to every target. If | 801 # which it will assign to the config it implicitly applies to every target. If | 
| 1064 # you want to override the optimization level for your target, remove this | 802 # you want to override the optimization level for your target, remove this | 
| 1065 # config (which will expand differently for debug or release builds), and then | 803 # config (which will expand differently for debug or release builds), and then | 
| 1066 # add back the one you want to override it with: | 804 # add back the one you want to override it with: | 
| 1067 # | 805 # | 
| 1068 #   configs -= default_optimization_config | 806 #   configs -= default_optimization_config | 
| 1069 #   configs += [ "//build/config/compiler/optimize_max" ] | 807 #   configs += [ ":optimize_max" ] | 
| 1070 | 808 | 
| 1071 # Shared settings for both "optimize" and "optimize_max" configs. | 809 # Shared settings. | 
| 1072 # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags. | 810 # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags. | 
| 1073 if (is_win) { | 811 if (is_win) { | 
| 1074   common_optimize_on_cflags = [ | 812   common_optimize_on_cflags = [ | 
| 1075     "/Ob2",  # Both explicit and auto inlining. | 813     "/Ob2",  # Both explicit and auto inlining. | 
| 1076     "/Oy-",  # Disable omitting frame pointers, must be after /O2. | 814     "/Oy-",  # Disable omitting frame pointers, must be after /O2. | 
| 1077   ] | 815   ] | 
| 1078   if (!is_asan) { | 816   if (!is_asan) { | 
| 1079     common_optimize_on_cflags += [ | 817     common_optimize_on_cflags += [ | 
| 1080       # Put data in separate COMDATs. This allows the linker | 818       # Put data in separate COMDATs. This allows the linker | 
| 1081       # to put bit-identical constants at the same address even if | 819       # to put bit-identical constants at the same address even if | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 1093     "-fno-ident", | 831     "-fno-ident", | 
| 1094 | 832 | 
| 1095     # Put data and code in their own sections, so that unused symbols | 833     # Put data and code in their own sections, so that unused symbols | 
| 1096     # can be removed at link time with --gc-sections. | 834     # can be removed at link time with --gc-sections. | 
| 1097     "-fdata-sections", | 835     "-fdata-sections", | 
| 1098     "-ffunction-sections", | 836     "-ffunction-sections", | 
| 1099   ] | 837   ] | 
| 1100   common_optimize_on_ldflags = [] | 838   common_optimize_on_ldflags = [] | 
| 1101 | 839 | 
| 1102   if (is_android) { | 840   if (is_android) { | 
| 1103     if (!using_sanitizer) { | 841     common_optimize_on_ldflags += [ | 
| 1104       common_optimize_on_cflags += [ "-fomit-frame-pointer" ] | 842       # Warn in case of text relocations. | 
| 1105     } | 843       "-Wl,--warn-shared-textrel", | 
| 1106 | 844     ] | 
| 1107     # TODO(jdduke) Re-enable on mips after resolving linking |  | 
| 1108     # issues with libc++ (crbug.com/456380). |  | 
| 1109     if (current_cpu != "mipsel" && current_cpu != "mips64el") { |  | 
| 1110       common_optimize_on_ldflags += [ |  | 
| 1111         # Warn in case of text relocations. |  | 
| 1112         "-Wl,--warn-shared-textrel", |  | 
| 1113       ] |  | 
| 1114     } |  | 
| 1115   } | 845   } | 
| 1116 | 846 | 
| 1117   if (is_mac || is_ios) { | 847   if (is_mac) { | 
| 1118     if (symbol_level == 2) { | 848     # Mac dead code stripping requires symbols. | 
| 1119       # Mac dead code stripping requires symbols. | 849     common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] | 
| 1120       common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] |  | 
| 1121     } |  | 
| 1122   } else { | 850   } else { | 
| 1123     # Non-Mac Posix linker flags. | 851     # Non-Mac Posix linker flags. | 
| 1124     common_optimize_on_ldflags += [ | 852     common_optimize_on_ldflags += [ | 
| 1125       # Specifically tell the linker to perform optimizations. | 853       # Specifically tell the linker to perform optimizations. | 
| 1126       # See http://lwn.net/Articles/192624/ . | 854       # See http://lwn.net/Articles/192624/ . | 
| 1127       "-Wl,-O1", | 855       "-Wl,-O1", | 
| 1128       "-Wl,--gc-sections", | 856       "-Wl,--gc-sections", | 
| 1129     ] | 857     ] | 
| 1130 | 858 | 
| 1131     if (!using_sanitizer) { | 859     if (!using_sanitizer) { | 
| 1132       # Functions interposed by the sanitizers can make ld think | 860       # Functions interposed by the sanitizers can make ld think | 
| 1133       # that some libraries aren't needed when they actually are, | 861       # that some libraries aren't needed when they actually are, | 
| 1134       # http://crbug.com/234010. As workaround, disable --as-needed. | 862       # http://crbug.com/234010. As workaround, disable --as-needed. | 
| 1135       common_optimize_on_ldflags += [ "-Wl,--as-needed" ] | 863       common_optimize_on_ldflags += [ "-Wl,--as-needed" ] | 
| 1136     } | 864     } | 
| 1137   } | 865   } | 
| 1138 } | 866 } | 
| 1139 | 867 | 
| 1140 # Default "optimization on" config. On Windows, this favors size over speed. | 868 # Default "optimization on" config. On Windows, this favors size over speed. | 
| 1141 config("optimize") { | 869 config("optimize") { | 
| 1142   if (is_win) { | 870   if (is_win) { | 
| 1143     # Favor size over speed, /O1 must be before the common flags. The GYP | 871     # Favor size over speed, /O1 must be before the common flags. The GYP | 
| 1144     # build also specifies /Os and /GF but these are implied by /O1. | 872     # build also specifies /Os and /GF but these are implied by /O1. | 
| 1145     cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ] | 873     cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ] | 
| 1146   } else if (is_android || is_ios) { | 874   } else if (is_android) { | 
| 1147     cflags = [ "-Os" ] + common_optimize_on_cflags  # Favor size over speed. | 875     cflags = [ "-Os" ] + common_optimize_on_cflags  # Favor size over speed. | 
| 1148   } else { | 876   } else { | 
| 1149     cflags = [ "-O2" ] + common_optimize_on_cflags | 877     cflags = [ "-O3" ] + common_optimize_on_cflags | 
| 1150   } | 878   } | 
| 1151   ldflags = common_optimize_on_ldflags | 879   ldflags = common_optimize_on_ldflags | 
| 1152 } | 880 } | 
| 1153 | 881 | 
| 1154 # Turn off optimizations. | 882 # Turn off optimizations. | 
| 1155 config("no_optimize") { | 883 config("no_optimize") { | 
| 1156   if (is_win) { | 884   if (is_win) { | 
| 1157     cflags = [ | 885     cflags = [ | 
| 1158       "/Od",  # Disable optimization. | 886       "/Od",  # Disable optimization. | 
| 1159       "/Ob0",  # Disable all inlining (on by default). | 887       "/Ob0",  # Disable all inlining (on by default). | 
| 1160       "/RTC1",  # Runtime checks for stack frame and uninitialized variables. | 888       "/RTC1",  # Runtime checks for stack frame and uninitialized variables. | 
| 1161     ] | 889     ] | 
| 1162   } else if (is_android && !android_full_debug) { | 890   } else if (is_android) { | 
| 1163     # On Android we kind of optimize some things that don't affect debugging | 891     # On Android we kind of optimize some things that don't affect debugging | 
| 1164     # much even when optimization is disabled to get the binary size down. | 892     # much even when optimization is disabled to get the binary size down. | 
| 1165     cflags = [ | 893     cflags = [ | 
| 1166       "-Os", | 894       "-Os", | 
| 1167       "-fdata-sections", | 895       "-fdata-sections", | 
| 1168       "-ffunction-sections", | 896       "-ffunction-sections", | 
| 1169     ] | 897     ] | 
| 1170     if (!using_sanitizer) { |  | 
| 1171       cflags += [ "-fomit-frame-pointer" ] |  | 
| 1172     } |  | 
| 1173     ldflags = common_optimize_on_ldflags | 898     ldflags = common_optimize_on_ldflags | 
| 1174   } else { | 899   } else { | 
| 1175     cflags = [ "-O0" ] | 900     cflags = [ "-O1" ] | 
| 1176   } | 901   } | 
| 1177 } | 902 } | 
| 1178 | 903 | 
| 1179 # Turns up the optimization level. On Windows, this implies whole program |  | 
| 1180 # optimization and link-time code generation which is very expensive and should |  | 
| 1181 # be used sparingly. |  | 
| 1182 config("optimize_max") { |  | 
| 1183   ldflags = common_optimize_on_ldflags |  | 
| 1184   if (is_win) { |  | 
| 1185     # Favor speed over size, /O2 must be before the common flags. The GYP |  | 
| 1186     # build also specifies /Ot, /Oi, and /GF, but these are implied by /O2. |  | 
| 1187     cflags = [ "/O2" ] + common_optimize_on_cflags |  | 
| 1188     if (is_official_build) { |  | 
| 1189       # TODO(GYP): TODO(dpranke): Should these only be on in an official |  | 
| 1190       # build, or on all the time? For now we'll require official build so |  | 
| 1191       # that the compile is clean. |  | 
| 1192       cflags += [ |  | 
| 1193         "/GL",  # Whole program optimization. |  | 
| 1194 |  | 
| 1195         # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds. |  | 
| 1196         # Probably anything that this would catch that wouldn't be caught in a |  | 
| 1197         # normal build isn't going to actually be a bug, so the incremental |  | 
| 1198         # value of C4702 for PGO builds is likely very small. |  | 
| 1199         "/wd4702", |  | 
| 1200       ] |  | 
| 1201       ldflags += [ "/LTCG" ] |  | 
| 1202     } |  | 
| 1203   } else { |  | 
| 1204     cflags = [ "-O2" ] + common_optimize_on_cflags |  | 
| 1205   } |  | 
| 1206 } |  | 
| 1207 |  | 
| 1208 # Symbols ---------------------------------------------------------------------- | 904 # Symbols ---------------------------------------------------------------------- | 
| 1209 | 905 | 
| 1210 config("symbols") { | 906 config("symbols") { | 
| 1211   if (is_win) { | 907   if (is_win) { | 
| 1212     import("//build/toolchain/goma.gni") | 908     import("//build/toolchain/goma.gni") | 
| 1213     if (use_goma) { | 909     if (use_goma) { | 
| 1214       cflags = [ "/Z7" ]  # No PDB file | 910       cflags = [ "/Z7" ]  # No PDB file | 
| 1215     } else { | 911     } else { | 
| 1216       cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue. | 912       cflags = [ "/Zi" ]  # Produce PDB file, no edit and continue. | 
| 1217     } | 913     } | 
| 1218     ldflags = [ "/DEBUG" ] | 914     ldflags = [ "/DEBUG" ] | 
| 1219   } else { | 915   } else { | 
| 1220     cflags = [ "-g2" ] | 916     cflags = [ | 
| 1221     if (use_debug_fission) { | 917       "-g3", | 
| 1222       cflags += [ "-gsplit-dwarf" ] | 918       "-ggdb3", | 
| 1223     } | 919     ] | 
| 1224   } | 920   } | 
| 1225 } | 921 } | 
| 1226 |  | 
| 1227 config("minimal_symbols") { |  | 
| 1228   if (is_win) { |  | 
| 1229     # Linker symbols for backtraces only. |  | 
| 1230     ldflags = [ "/DEBUG" ] |  | 
| 1231   } else { |  | 
| 1232     cflags = [ "-g1" ] |  | 
| 1233     if (use_debug_fission) { |  | 
| 1234       cflags += [ "-gsplit-dwarf" ] |  | 
| 1235     } |  | 
| 1236   } |  | 
| 1237 } |  | 
| 1238 |  | 
| 1239 config("no_symbols") { |  | 
| 1240   if (!is_win) { |  | 
| 1241     cflags = [ "-g0" ] |  | 
| 1242   } |  | 
| 1243 } |  | 
| OLD | NEW | 
|---|