| 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 if (current_cpu == "arm") { | 7 if (current_cpu == "arm") { |
| 8 import("//build/config/arm.gni") | 8 import("//build/config/arm.gni") |
| 9 } | 9 } |
| 10 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | 10 if (current_cpu == "mipsel" || current_cpu == "mips64el") { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of | 42 # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of |
| 43 # address space, and it doesn't support cross-compiling). | 43 # address space, and it doesn't support cross-compiling). |
| 44 use_gold = is_linux && current_cpu == "x64" | 44 use_gold = is_linux && current_cpu == "x64" |
| 45 | 45 |
| 46 # use_debug_fission: whether to use split DWARF debug info | 46 # use_debug_fission: whether to use split DWARF debug info |
| 47 # files. This can reduce link time significantly, but is incompatible | 47 # files. This can reduce link time significantly, but is incompatible |
| 48 # with some utilities such as icecc and ccache. Requires gold and | 48 # with some utilities such as icecc and ccache. Requires gold and |
| 49 # gcc >= 4.8 or clang. | 49 # gcc >= 4.8 or clang. |
| 50 # http://gcc.gnu.org/wiki/DebugFission | 50 # http://gcc.gnu.org/wiki/DebugFission |
| 51 use_debug_fission = | 51 use_debug_fission = use_gold && linux_use_bundled_binutils && !use_ccache |
| 52 !is_win && use_gold && linux_use_bundled_binutils && !use_ccache | |
| 53 | |
| 54 if (is_win) { | |
| 55 # Whether the VS xtree header has been patched to disable warning 4702. If | |
| 56 # it has, then we don't need to disable 4702 (unreachable code warning). | |
| 57 # The patch is preapplied to the internal toolchain and hence all bots. | |
| 58 msvs_xtree_patched = false | |
| 59 } | |
| 60 } | 52 } |
| 61 | 53 |
| 62 # default_include_dirs --------------------------------------------------------- | 54 # default_include_dirs --------------------------------------------------------- |
| 63 # | 55 # |
| 64 # This is a separate config so that third_party code (which would not use the | 56 # This is a separate config so that third_party code (which would not use the |
| 65 # source root and might have conflicting versions of some headers) can remove | 57 # source root and might have conflicting versions of some headers) can remove |
| 66 # this and specify their own include paths. | 58 # this and specify their own include paths. |
| 67 config("default_include_dirs") { | 59 config("default_include_dirs") { |
| 68 include_dirs = [ | 60 include_dirs = [ |
| 69 "//", | 61 "//", |
| 70 root_gen_dir, | 62 root_gen_dir, |
| 71 ] | 63 ] |
| 72 } | 64 } |
| 73 | 65 |
| 74 # TODO(GYP): is_ubsan, is_ubsan_vptr | 66 # TODO(GYP): is_ubsan, is_ubsan_vptr |
| 75 if (!is_win) { | 67 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan |
| 76 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan | |
| 77 } | |
| 78 | 68 |
| 79 # compiler --------------------------------------------------------------------- | 69 # compiler --------------------------------------------------------------------- |
| 80 # | 70 # |
| 81 # Base compiler configuration. | 71 # Base compiler configuration. |
| 82 # | 72 # |
| 83 # See also "runtime_library" below for related stuff and a discussion about | 73 # See also "runtime_library" below for related stuff and a discussion about |
| 84 # where stuff should go. Put warning related stuff in the "warnings" config. | 74 # where stuff should go. Put warning related stuff in the "warnings" config. |
| 85 | 75 |
| 86 config("compiler") { | 76 config("compiler") { |
| 87 asmflags = [] | 77 asmflags = [] |
| 88 cflags = [] | 78 cflags = [] |
| 89 cflags_c = [] | 79 cflags_c = [] |
| 90 cflags_cc = [] | 80 cflags_cc = [] |
| 91 ldflags = [] | 81 ldflags = [] |
| 92 defines = [] | 82 defines = [] |
| 93 | 83 |
| 94 # In general, Windows is totally different, but all the other builds share | 84 # Common GCC compiler flags setup. |
| 95 # some common GCC configuration. This section sets up Windows and the common | 85 # -------------------------------- |
| 96 # GCC flags, and then we handle the other non-Windows platforms specifically | 86 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 |
| 97 # below. | 87 cflags_cc += [ |
| 98 if (is_win) { | 88 "-fno-threadsafe-statics", |
| 99 # Windows compiler flags setup. | 89 |
| 100 # ----------------------------- | 90 # Not exporting C++ inline functions can generally be applied anywhere |
| 91 # so we do so here. Normal function visibility is controlled by |
| 92 # //build/config/gcc:symbol_visibility_hidden. |
| 93 "-fvisibility-inlines-hidden", |
| 94 ] |
| 95 |
| 96 # Stack protection. |
| 97 if (is_mac) { |
| 98 cflags += [ "-fstack-protector-all" ] |
| 99 } else if (is_linux) { |
| 101 cflags += [ | 100 cflags += [ |
| 102 "/Gy", # Enable function-level linking. | 101 "-fstack-protector", |
| 103 "/GS", # Enable buffer security checking. | 102 "--param=ssp-buffer-size=4", |
| 104 "/FS", # Preserve previous PDB behavior. | |
| 105 ] | 103 ] |
| 104 } |
| 106 | 105 |
| 107 # Building with Clang on Windows is a work in progress and very | 106 # Linker warnings. |
| 108 # experimental. See crbug.com/82385. | 107 if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) { |
| 109 # Keep this in sync with the similar block in build/common.gypi | 108 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 |
| 110 if (is_clang) { | 109 ldflags += [ "-Wl,--fatal-warnings" ] |
| 111 cflags += [ | 110 } |
| 112 # Many files use intrinsics without including this header. | |
| 113 # TODO(hans): Fix those files, or move this to sub-GYPs. | |
| 114 "/FIIntrin.h", | |
| 115 ] | |
| 116 | 111 |
| 117 if (visual_studio_version == "2013") { | 112 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and |
| 118 cflags += [ "-fmsc-version=1800" ] | 113 # MemorySanitizer |
| 119 } else if (visual_studio_version == "2015") { | 114 if (using_sanitizer) { |
| 120 cflags += [ "-fmsc-version=1900" ] | 115 cflags += [ |
| 121 } | 116 "-fno-omit-frame-pointer", |
| 117 "-gline-tables-only", |
| 118 ] |
| 119 } |
| 120 if (is_asan) { |
| 121 asan_blacklist_path = |
| 122 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) |
| 123 cflags += [ |
| 124 "-fsanitize=address", |
| 125 "-fsanitize-blacklist=$asan_blacklist_path", |
| 126 ] |
| 127 if (is_mac) { |
| 128 cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073 |
| 129 # TODO(GYP): deal with mac_bundles. |
| 130 } |
| 131 } |
| 132 if (is_lsan) { |
| 133 cflags += [ "-fsanitize=leak" ] |
| 134 } |
| 135 if (is_tsan) { |
| 136 tsan_blacklist_path = |
| 137 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) |
| 138 cflags += [ |
| 139 "-fsanitize=thread", |
| 140 "-fsanitize-blacklist=$tsan_blacklist_path", |
| 141 ] |
| 142 } |
| 143 if (is_msan) { |
| 144 msan_blacklist_path = |
| 145 rebase_path("//tools/msan/blacklist.txt", root_build_dir) |
| 146 cflags += [ |
| 147 "-fsanitize=memory", |
| 148 "-fsanitize-memory-track-origins=$msan_track_origins", |
| 149 "-fsanitize-blacklist=$msan_blacklist_path", |
| 150 ] |
| 151 } |
| 122 | 152 |
| 123 if (current_cpu == "x86") { | 153 if (use_custom_libcxx) { |
| 124 cflags += [ | 154 cflags_cc += [ "-nostdinc++" ] |
| 125 "/fallback", | 155 include_dirs = [ |
| 126 "-m32", | 156 "//buildtools/third_party/libc++/trunk/include", |
| 127 ] | 157 "//buildtools/third_party/libc++abi/trunk/include", |
| 128 } else { | |
| 129 cflags += [ "-m64" ] | |
| 130 } | |
| 131 } | |
| 132 } else { | |
| 133 # Common GCC compiler flags setup. | |
| 134 # -------------------------------- | |
| 135 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 | |
| 136 cflags_cc += [ | |
| 137 "-fno-threadsafe-statics", | |
| 138 | |
| 139 # Not exporting C++ inline functions can generally be applied anywhere | |
| 140 # so we do so here. Normal function visibility is controlled by | |
| 141 # //build/config/gcc:symbol_visibility_hidden. | |
| 142 "-fvisibility-inlines-hidden", | |
| 143 ] | 158 ] |
| 144 | |
| 145 # Stack protection. | |
| 146 if (is_mac) { | |
| 147 cflags += [ "-fstack-protector-all" ] | |
| 148 } else if (is_linux) { | |
| 149 cflags += [ | |
| 150 "-fstack-protector", | |
| 151 "--param=ssp-buffer-size=4", | |
| 152 ] | |
| 153 } | |
| 154 | |
| 155 # Linker warnings. | |
| 156 if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) { | |
| 157 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 | |
| 158 ldflags += [ "-Wl,--fatal-warnings" ] | |
| 159 } | |
| 160 | |
| 161 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and | |
| 162 # MemorySanitizer | |
| 163 if (using_sanitizer) { | |
| 164 cflags += [ | |
| 165 "-fno-omit-frame-pointer", | |
| 166 "-gline-tables-only", | |
| 167 ] | |
| 168 } | |
| 169 if (is_asan) { | |
| 170 asan_blacklist_path = | |
| 171 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) | |
| 172 cflags += [ | |
| 173 "-fsanitize=address", | |
| 174 "-fsanitize-blacklist=$asan_blacklist_path", | |
| 175 ] | |
| 176 if (is_mac) { | |
| 177 cflags += [ "-mllvm -asan-globals=0" ] # http://crbug.com/352073 | |
| 178 # TODO(GYP): deal with mac_bundles. | |
| 179 } | |
| 180 } | |
| 181 if (is_lsan) { | |
| 182 cflags += [ "-fsanitize=leak" ] | |
| 183 } | |
| 184 if (is_tsan) { | |
| 185 tsan_blacklist_path = | |
| 186 rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir) | |
| 187 cflags += [ | |
| 188 "-fsanitize=thread", | |
| 189 "-fsanitize-blacklist=$tsan_blacklist_path", | |
| 190 ] | |
| 191 } | |
| 192 if (is_msan) { | |
| 193 msan_blacklist_path = | |
| 194 rebase_path("//tools/msan/blacklist.txt", root_build_dir) | |
| 195 cflags += [ | |
| 196 "-fsanitize=memory", | |
| 197 "-fsanitize-memory-track-origins=$msan_track_origins", | |
| 198 "-fsanitize-blacklist=$msan_blacklist_path", | |
| 199 ] | |
| 200 } | |
| 201 | |
| 202 if (use_custom_libcxx) { | |
| 203 cflags_cc += [ "-nostdinc++" ] | |
| 204 include_dirs = [ | |
| 205 "//buildtools/third_party/libc++/trunk/include", | |
| 206 "//buildtools/third_party/libc++abi/trunk/include", | |
| 207 ] | |
| 208 } | |
| 209 } | 159 } |
| 210 | 160 |
| 211 if (is_clang && is_debug) { | 161 if (is_clang && is_debug) { |
| 212 # Allow comparing the address of references and 'this' against 0 | 162 # Allow comparing the address of references and 'this' against 0 |
| 213 # in debug builds. Technically, these can never be null in | 163 # in debug builds. Technically, these can never be null in |
| 214 # well-defined C/C++ and Clang can optimize such checks away in | 164 # well-defined C/C++ and Clang can optimize such checks away in |
| 215 # release builds, but they may be used in asserts in debug builds. | 165 # release builds, but they may be used in asserts in debug builds. |
| 216 cflags_cc += [ | 166 cflags_cc += [ |
| 217 "-Wno-undefined-bool-conversion", | 167 "-Wno-undefined-bool-conversion", |
| 218 "-Wno-tautological-undefined-compare", | 168 "-Wno-tautological-undefined-compare", |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 448 } |
| 499 | 449 |
| 500 # C++11 compiler flags setup. | 450 # C++11 compiler flags setup. |
| 501 # --------------------------- | 451 # --------------------------- |
| 502 if (is_linux || is_android || is_nacl) { | 452 if (is_linux || is_android || is_nacl) { |
| 503 # gnu++11 instead of c++11 is needed because some code uses typeof() (a | 453 # gnu++11 instead of c++11 is needed because some code uses typeof() (a |
| 504 # GNU extension). | 454 # GNU extension). |
| 505 # TODO(thakis): Eventually switch this to c++11 instead, | 455 # TODO(thakis): Eventually switch this to c++11 instead, |
| 506 # http://crbug.com/427584 | 456 # http://crbug.com/427584 |
| 507 cflags_cc += [ "-std=gnu++11" ] | 457 cflags_cc += [ "-std=gnu++11" ] |
| 508 } else if (!is_win) { | 458 } else { |
| 509 cflags_cc += [ "-std=c++11" ] | 459 cflags_cc += [ "-std=c++11" ] |
| 510 } | 460 } |
| 511 | 461 |
| 512 # Android-specific flags setup. | 462 # Android-specific flags setup. |
| 513 # ----------------------------- | 463 # ----------------------------- |
| 514 if (is_android) { | 464 if (is_android) { |
| 515 cflags += [ | 465 cflags += [ |
| 516 "-ffunction-sections", | 466 "-ffunction-sections", |
| 517 "-funwind-tables", | 467 "-funwind-tables", |
| 518 "-fno-short-enums", | 468 "-fno-short-enums", |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 config("runtime_library") { | 654 config("runtime_library") { |
| 705 cflags = [] | 655 cflags = [] |
| 706 defines = [] | 656 defines = [] |
| 707 ldflags = [] | 657 ldflags = [] |
| 708 lib_dirs = [] | 658 lib_dirs = [] |
| 709 libs = [] | 659 libs = [] |
| 710 | 660 |
| 711 if (is_component_build) { | 661 if (is_component_build) { |
| 712 # Component mode: dynamic CRT. | 662 # Component mode: dynamic CRT. |
| 713 defines += [ "COMPONENT_BUILD" ] | 663 defines += [ "COMPONENT_BUILD" ] |
| 714 if (is_win) { | |
| 715 # Since the library is shared, it requires exceptions or will give errors | |
| 716 # about things not matching, so keep exceptions on. | |
| 717 if (is_debug) { | |
| 718 cflags += [ "/MDd" ] | |
| 719 } else { | |
| 720 cflags += [ "/MD" ] | |
| 721 } | |
| 722 } | |
| 723 } else { | |
| 724 # Static CRT. | |
| 725 if (is_win) { | |
| 726 if (is_debug) { | |
| 727 cflags += [ "/MTd" ] | |
| 728 } else { | |
| 729 cflags += [ "/MT" ] | |
| 730 } | |
| 731 } | |
| 732 } | |
| 733 | |
| 734 if (is_win) { | |
| 735 defines += [ | |
| 736 "__STD_C", | |
| 737 "_CRT_RAND_S", | |
| 738 "_CRT_SECURE_NO_DEPRECATE", | |
| 739 "_HAS_EXCEPTIONS=0", | |
| 740 "_SCL_SECURE_NO_DEPRECATE", | |
| 741 ] | |
| 742 } | 664 } |
| 743 | 665 |
| 744 # Android standard library setup. | 666 # Android standard library setup. |
| 745 if (is_android) { | 667 if (is_android) { |
| 746 if (is_clang) { | 668 if (is_clang) { |
| 747 # Work around incompatibilities between bionic and clang headers. | 669 # Work around incompatibilities between bionic and clang headers. |
| 748 defines += [ | 670 defines += [ |
| 749 "__compiler_offsetof=__builtin_offsetof", | 671 "__compiler_offsetof=__builtin_offsetof", |
| 750 "nan=__builtin_nan", | 672 "nan=__builtin_nan", |
| 751 ] | 673 ] |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 740 } |
| 819 } | 741 } |
| 820 | 742 |
| 821 # default_warning_flags collects all warning flags that are used by default. | 743 # default_warning_flags collects all warning flags that are used by default. |
| 822 # This is in a variable instead of a config so that it can be used in | 744 # This is in a variable instead of a config so that it can be used in |
| 823 # both chromium_code and no_chromium_code. This way these flags are guaranteed | 745 # both chromium_code and no_chromium_code. This way these flags are guaranteed |
| 824 # to appear on the compile command line after -Wall. | 746 # to appear on the compile command line after -Wall. |
| 825 | 747 |
| 826 default_warning_flags = [] | 748 default_warning_flags = [] |
| 827 default_warning_flags_cc = [] | 749 default_warning_flags_cc = [] |
| 828 if (is_win) { | |
| 829 if (!is_clang || current_cpu != "x86") { | |
| 830 default_warning_flags += [ "/WX" ] # Treat warnings as errors. | |
| 831 } | |
| 832 | 750 |
| 833 default_warning_flags += [ | 751 # Common GCC warning setup. |
| 834 # Warnings permanently disabled: | 752 default_warning_flags += [ |
| 753 # Enables. |
| 754 "-Wendif-labels", # Weird old-style text after an #endif. |
| 755 "-Werror", # Warnings as errors. |
| 835 | 756 |
| 836 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled | 757 # Disables. |
| 837 # for a bunch of individual targets. Re-enable this globally when those | 758 "-Wno-missing-field-initializers", # "struct foo f = {0};" |
| 838 # targets are fixed. | 759 "-Wno-unused-parameter", # Unused function parameters. |
| 839 "/wd4018", # Comparing signed and unsigned values. | 760 ] |
| 840 | 761 |
| 841 # C4127: conditional expression is constant | 762 if (is_mac) { |
| 842 # This warning can in theory catch dead code and other problems, but | 763 default_warning_flags += [ "-Wnewline-eof" ] |
| 843 # triggers in far too many desirable cases where the conditional | 764 if (!is_nacl) { |
| 844 # expression is either set by macros or corresponds some legitimate | 765 # When compiling Objective-C, warns if a method is used whose |
| 845 # compile-time constant expression (due to constant template args, | 766 # availability is newer than the deployment target. This is not |
| 846 # conditionals comparing the sizes of different types, etc.). Some of | 767 # required when compiling Chrome for iOS. |
| 847 # these can be worked around, but it's not worth it. | 768 default_warning_flags += [ "-Wpartial-availability" ] |
| 848 "/wd4127", | |
| 849 | |
| 850 # C4251: 'identifier' : class 'type' needs to have dll-interface to be | |
| 851 # used by clients of class 'type2' | |
| 852 # This is necessary for the shared library build. | |
| 853 "/wd4251", | |
| 854 | |
| 855 # C4351: new behavior: elements of array 'array' will be default | |
| 856 # initialized | |
| 857 # This is a silly "warning" that basically just alerts you that the | |
| 858 # compiler is going to actually follow the language spec like it's | |
| 859 # supposed to, instead of not following it like old buggy versions did. | |
| 860 # There's absolutely no reason to turn this on. | |
| 861 "/wd4351", | |
| 862 | |
| 863 # C4355: 'this': used in base member initializer list | |
| 864 # It's commonly useful to pass |this| to objects in a class' initializer | |
| 865 # list. While this warning can catch real bugs, most of the time the | |
| 866 # constructors in question don't attempt to call methods on the passed-in | |
| 867 # pointer (until later), and annotating every legit usage of this is | |
| 868 # simply more hassle than the warning is worth. | |
| 869 "/wd4355", | |
| 870 | |
| 871 # C4503: 'identifier': decorated name length exceeded, name was | |
| 872 # truncated | |
| 873 # This only means that some long error messages might have truncated | |
| 874 # identifiers in the presence of lots of templates. It has no effect on | |
| 875 # program correctness and there's no real reason to waste time trying to | |
| 876 # prevent it. | |
| 877 "/wd4503", | |
| 878 | |
| 879 # C4611: interaction between 'function' and C++ object destruction is | |
| 880 # non-portable | |
| 881 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN | |
| 882 # suggests using exceptions instead of setjmp/longjmp for C++, but | |
| 883 # Chromium code compiles without exception support. We therefore have to | |
| 884 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we | |
| 885 # have to turn off this warning (and be careful about how object | |
| 886 # destruction happens in such cases). | |
| 887 "/wd4611", | |
| 888 | |
| 889 # Warnings to evaluate and possibly fix/reenable later: | |
| 890 | |
| 891 "/wd4100", # Unreferenced formal function parameter. | |
| 892 "/wd4121", # Alignment of a member was sensitive to packing. | |
| 893 "/wd4244", # Conversion: possible loss of data. | |
| 894 "/wd4481", # Nonstandard extension: override specifier. | |
| 895 "/wd4505", # Unreferenced local function has been removed. | |
| 896 "/wd4510", # Default constructor could not be generated. | |
| 897 "/wd4512", # Assignment operator could not be generated. | |
| 898 "/wd4610", # Class can never be instantiated, constructor required. | |
| 899 "/wd4996", # Deprecated function warning. | |
| 900 ] | |
| 901 | |
| 902 # VS xtree header file needs to be patched or 4702 (unreachable code | |
| 903 # warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is | |
| 904 # not patched. | |
| 905 if (!msvs_xtree_patched && | |
| 906 exec_script("../../win_is_xtree_patched.py", [], "value") == 0) { | |
| 907 default_warning_flags += [ "/wd4702" ] # Unreachable code. | |
| 908 } | |
| 909 | |
| 910 # Building with Clang on Windows is a work in progress and very | |
| 911 # experimental. See crbug.com/82385. | |
| 912 # Keep this in sync with the similar block in build/common.gypi | |
| 913 if (is_clang) { | |
| 914 default_warning_flags += [ | |
| 915 # TODO(hans): Make this list shorter eventually. | |
| 916 "-Qunused-arguments", | |
| 917 "-Wno-c++11-compat-deprecated-writable-strings", | |
| 918 "-Wno-deprecated-declarations", | |
| 919 "-Wno-empty-body", | |
| 920 "-Wno-enum-conversion", | |
| 921 "-Wno-extra-tokens", | |
| 922 "-Wno-ignored-attributes", | |
| 923 "-Wno-incompatible-pointer-types", | |
| 924 "-Wno-int-to-void-pointer-cast", | |
| 925 "-Wno-invalid-noreturn", | |
| 926 "-Wno-logical-op-parentheses", | |
| 927 "-Wno-microsoft", | |
| 928 "-Wno-missing-braces", | |
| 929 "-Wno-missing-declarations", | |
| 930 "-Wno-msvc-include", | |
| 931 "-Wno-null-dereference", | |
| 932 "-Wno-overloaded-virtual", | |
| 933 "-Wno-parentheses", | |
| 934 "-Wno-pointer-sign", | |
| 935 "-Wno-reorder", | |
| 936 "-Wno-return-type-c-linkage", | |
| 937 "-Wno-self-assign", | |
| 938 "-Wno-sometimes-uninitialized", | |
| 939 "-Wno-switch", | |
| 940 "-Wno-tautological-compare", | |
| 941 "-Wno-unknown-pragmas", | |
| 942 "-Wno-unsequenced", | |
| 943 "-Wno-unused-function", | |
| 944 "-Wno-unused-private-field", | |
| 945 "-Wno-unused-value", | |
| 946 "-Wno-unused-variable", | |
| 947 "-Wno-unused-local-typedef", # http://crbug.com/411648 | |
| 948 "-Wno-inconsistent-missing-override", #http://crbug.com/428099 | |
| 949 ] | |
| 950 } | |
| 951 } else { | |
| 952 # Common GCC warning setup. | |
| 953 default_warning_flags += [ | |
| 954 # Enables. | |
| 955 "-Wendif-labels", # Weird old-style text after an #endif. | |
| 956 "-Werror", # Warnings as errors. | |
| 957 | |
| 958 # Disables. | |
| 959 "-Wno-missing-field-initializers", # "struct foo f = {0};" | |
| 960 "-Wno-unused-parameter", # Unused function parameters. | |
| 961 ] | |
| 962 | |
| 963 if (is_mac) { | |
| 964 default_warning_flags += [ "-Wnewline-eof" ] | |
| 965 if (!is_nacl) { | |
| 966 # When compiling Objective-C, warns if a method is used whose | |
| 967 # availability is newer than the deployment target. This is not | |
| 968 # required when compiling Chrome for iOS. | |
| 969 default_warning_flags += [ "-Wpartial-availability" ] | |
| 970 } | |
| 971 } | |
| 972 | |
| 973 if (gcc_version >= 48) { | |
| 974 default_warning_flags_cc += [ | |
| 975 # See comment for -Wno-c++11-narrowing. | |
| 976 "-Wno-narrowing", | |
| 977 | |
| 978 # TODO(thakis): Remove, http://crbug.com/263960 | |
| 979 "-Wno-literal-suffix", | |
| 980 ] | |
| 981 } | |
| 982 | |
| 983 # Suppress warnings about ABI changes on ARM (Clang doesn't give this | |
| 984 # warning). | |
| 985 if (current_cpu == "arm" && !is_clang) { | |
| 986 default_warning_flags += [ "-Wno-psabi" ] | |
| 987 } | |
| 988 | |
| 989 if (is_android) { | |
| 990 # Disable any additional warnings enabled by the Android build system but | |
| 991 # which chromium does not build cleanly with (when treating warning as | |
| 992 # errors). | |
| 993 default_warning_flags += [ | |
| 994 "-Wno-extra", | |
| 995 "-Wno-ignored-qualifiers", | |
| 996 "-Wno-type-limits", | |
| 997 ] | |
| 998 default_warning_flags_cc += [ | |
| 999 # Disabling c++0x-compat should be handled in WebKit, but | |
| 1000 # this currently doesn't work because gcc_version is not set | |
| 1001 # correctly when building with the Android build system. | |
| 1002 # TODO(torne): Fix this in WebKit. | |
| 1003 "-Wno-error=c++0x-compat", | |
| 1004 | |
| 1005 # Other things unrelated to -Wextra: | |
| 1006 "-Wno-non-virtual-dtor", | |
| 1007 "-Wno-sign-promo", | |
| 1008 ] | |
| 1009 } | |
| 1010 | |
| 1011 if (gcc_version >= 48) { | |
| 1012 # Don't warn about the "typedef 'foo' locally defined but not used" | |
| 1013 # for gcc 4.8. | |
| 1014 # TODO: remove this flag once all builds work. See crbug.com/227506 | |
| 1015 default_warning_flags += [ "-Wno-unused-local-typedefs" ] | |
| 1016 } | 769 } |
| 1017 } | 770 } |
| 771 |
| 772 if (gcc_version >= 48) { |
| 773 default_warning_flags_cc += [ |
| 774 # See comment for -Wno-c++11-narrowing. |
| 775 "-Wno-narrowing", |
| 776 |
| 777 # TODO(thakis): Remove, http://crbug.com/263960 |
| 778 "-Wno-literal-suffix", |
| 779 ] |
| 780 } |
| 781 |
| 782 # Suppress warnings about ABI changes on ARM (Clang doesn't give this |
| 783 # warning). |
| 784 if (current_cpu == "arm" && !is_clang) { |
| 785 default_warning_flags += [ "-Wno-psabi" ] |
| 786 } |
| 787 |
| 788 if (is_android) { |
| 789 # Disable any additional warnings enabled by the Android build system but |
| 790 # which chromium does not build cleanly with (when treating warning as |
| 791 # errors). |
| 792 default_warning_flags += [ |
| 793 "-Wno-extra", |
| 794 "-Wno-ignored-qualifiers", |
| 795 "-Wno-type-limits", |
| 796 ] |
| 797 default_warning_flags_cc += [ |
| 798 # Disabling c++0x-compat should be handled in WebKit, but |
| 799 # this currently doesn't work because gcc_version is not set |
| 800 # correctly when building with the Android build system. |
| 801 # TODO(torne): Fix this in WebKit. |
| 802 "-Wno-error=c++0x-compat", |
| 803 |
| 804 # Other things unrelated to -Wextra: |
| 805 "-Wno-non-virtual-dtor", |
| 806 "-Wno-sign-promo", |
| 807 ] |
| 808 } |
| 809 |
| 810 if (gcc_version >= 48) { |
| 811 # Don't warn about the "typedef 'foo' locally defined but not used" |
| 812 # for gcc 4.8. |
| 813 # TODO: remove this flag once all builds work. See crbug.com/227506 |
| 814 default_warning_flags += [ "-Wno-unused-local-typedefs" ] |
| 815 } |
| 816 |
| 1018 if (is_clang) { | 817 if (is_clang) { |
| 1019 default_warning_flags += [ | 818 default_warning_flags += [ |
| 1020 # This warns on using ints as initializers for floats in | 819 # This warns on using ints as initializers for floats in |
| 1021 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), | 820 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), |
| 1022 # which happens in several places in chrome code. Not sure if | 821 # which happens in several places in chrome code. Not sure if |
| 1023 # this is worth fixing. | 822 # this is worth fixing. |
| 1024 "-Wno-c++11-narrowing", | 823 "-Wno-c++11-narrowing", |
| 1025 | 824 |
| 1026 # Don't die on dtoa code that uses a char as an array index. | 825 # Don't die on dtoa code that uses a char as an array index. |
| 1027 # This is required solely for base/third_party/dmg_fp/dtoa.cc. | 826 # This is required solely for base/third_party/dmg_fp/dtoa.cc. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 ] | 862 ] |
| 1064 } | 863 } |
| 1065 } | 864 } |
| 1066 | 865 |
| 1067 # chromium_code --------------------------------------------------------------- | 866 # chromium_code --------------------------------------------------------------- |
| 1068 # | 867 # |
| 1069 # Toggles between higher and lower warnings for code that is (or isn't) | 868 # Toggles between higher and lower warnings for code that is (or isn't) |
| 1070 # part of Chromium. | 869 # part of Chromium. |
| 1071 | 870 |
| 1072 config("chromium_code") { | 871 config("chromium_code") { |
| 1073 if (is_win) { | 872 cflags = [ |
| 1074 cflags = [ "/W4" ] # Warning level 4. | 873 "-Wall", |
| 1075 } else { | |
| 1076 cflags = [ | |
| 1077 "-Wall", | |
| 1078 | 874 |
| 1079 # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, | 875 # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, |
| 1080 # so we specify it explicitly. | 876 # so we specify it explicitly. |
| 1081 # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it. | 877 # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it. |
| 1082 # http://code.google.com/p/chromium/issues/detail?id=90453 | 878 # http://code.google.com/p/chromium/issues/detail?id=90453 |
| 1083 "-Wsign-compare", | 879 "-Wsign-compare", |
| 1084 ] | 880 ] |
| 1085 | 881 |
| 1086 # In Chromium code, we define __STDC_foo_MACROS in order to get the | 882 # In Chromium code, we define __STDC_foo_MACROS in order to get the |
| 1087 # C99 macros on Mac and Linux. | 883 # C99 macros on Mac and Linux. |
| 1088 defines = [ | 884 defines = [ |
| 1089 "__STDC_CONSTANT_MACROS", | 885 "__STDC_CONSTANT_MACROS", |
| 1090 "__STDC_FORMAT_MACROS", | 886 "__STDC_FORMAT_MACROS", |
| 1091 ] | 887 ] |
| 1092 | 888 |
| 1093 if (!is_debug && !using_sanitizer && | 889 if (!is_debug && !using_sanitizer && |
| 1094 (!is_linux || !is_clang || is_official_build)) { | 890 (!is_linux || !is_clang || is_official_build)) { |
| 1095 # _FORTIFY_SOURCE isn't really supported by Clang now, see | 891 # _FORTIFY_SOURCE isn't really supported by Clang now, see |
| 1096 # http://llvm.org/bugs/show_bug.cgi?id=16821. | 892 # http://llvm.org/bugs/show_bug.cgi?id=16821. |
| 1097 # It seems to work fine with Ubuntu 12 headers though, so use it in | 893 # It seems to work fine with Ubuntu 12 headers though, so use it in |
| 1098 # official builds. | 894 # official builds. |
| 1099 # | 895 # |
| 1100 # Non-chromium code is not guaranteed to compile cleanly with | 896 # Non-chromium code is not guaranteed to compile cleanly with |
| 1101 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are | 897 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are |
| 1102 # disabled, so only do that for Release build. | 898 # disabled, so only do that for Release build. |
| 1103 defines += [ "_FORTIFY_SOURCE=2" ] | 899 defines += [ "_FORTIFY_SOURCE=2" ] |
| 1104 } | |
| 1105 } | 900 } |
| 901 |
| 1106 cflags += default_warning_flags | 902 cflags += default_warning_flags |
| 1107 cflags_cc = default_warning_flags_cc | 903 cflags_cc = default_warning_flags_cc |
| 1108 } | 904 } |
| 1109 config("no_chromium_code") { | 905 config("no_chromium_code") { |
| 1110 cflags = [] | 906 cflags = [] |
| 1111 cflags_cc = [] | 907 cflags_cc = [] |
| 1112 defines = [] | 908 defines = [] |
| 1113 | 909 |
| 1114 if (is_win) { | |
| 1115 cflags += [ | |
| 1116 "/W3", # Warning level 3. | |
| 1117 "/wd4800", # Disable warning when forcing value to bool. | |
| 1118 "/wd4267", # TODO(jschuh): size_t to int. | |
| 1119 "/wd4996", # Deprecated function warning. | |
| 1120 ] | |
| 1121 defines += [ | |
| 1122 "_CRT_NONSTDC_NO_WARNINGS", | |
| 1123 "_CRT_NONSTDC_NO_DEPRECATE", | |
| 1124 ] | |
| 1125 } | |
| 1126 | |
| 1127 if (is_linux) { | 910 if (is_linux) { |
| 1128 # Don't warn about ignoring the return value from e.g. close(). This is | 911 # Don't warn about ignoring the return value from e.g. close(). This is |
| 1129 # off by default in some gccs but on by default in others. BSD systems do | 912 # off by default in some gccs but on by default in others. BSD systems do |
| 1130 # not support this option, since they are usually using gcc 4.2.1, which | 913 # not support this option, since they are usually using gcc 4.2.1, which |
| 1131 # does not have this flag yet. | 914 # does not have this flag yet. |
| 1132 cflags += [ | 915 cflags += [ |
| 1133 "-Wno-logical-not-parentheses", | 916 "-Wno-logical-not-parentheses", |
| 1134 "-Wno-unused-result", | 917 "-Wno-unused-result", |
| 1135 ] | 918 ] |
| 1136 } | 919 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1148 } | 931 } |
| 1149 cflags += default_warning_flags | 932 cflags += default_warning_flags |
| 1150 cflags_cc += default_warning_flags_cc | 933 cflags_cc += default_warning_flags_cc |
| 1151 } | 934 } |
| 1152 | 935 |
| 1153 # rtti ------------------------------------------------------------------------ | 936 # rtti ------------------------------------------------------------------------ |
| 1154 # | 937 # |
| 1155 # Allows turning Run-Time Type Identification on or off. | 938 # Allows turning Run-Time Type Identification on or off. |
| 1156 | 939 |
| 1157 config("rtti") { | 940 config("rtti") { |
| 1158 if (is_win) { | |
| 1159 cflags_cc = [ "/GR" ] | |
| 1160 } | |
| 1161 } | 941 } |
| 1162 config("no_rtti") { | 942 config("no_rtti") { |
| 1163 if (is_win) { | 943 cflags_cc = [ "-fno-rtti" ] |
| 1164 cflags_cc = [ "/GR-" ] | |
| 1165 } else { | |
| 1166 cflags_cc = [ "-fno-rtti" ] | |
| 1167 } | |
| 1168 } | 944 } |
| 1169 | 945 |
| 1170 # Warnings --------------------------------------------------------------------- | 946 # Warnings --------------------------------------------------------------------- |
| 1171 | 947 |
| 1172 # This will generate warnings when using Clang if code generates exit-time | 948 # This will generate warnings when using Clang if code generates exit-time |
| 1173 # destructors, which will slow down closing the program. | 949 # destructors, which will slow down closing the program. |
| 1174 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 | 950 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 |
| 1175 config("wexit_time_destructors") { | 951 config("wexit_time_destructors") { |
| 1176 # TODO: Enable on Windows too, http://crbug.com/404525 | 952 if (is_clang) { |
| 1177 if (is_clang && !is_win) { | |
| 1178 cflags = [ "-Wexit-time-destructors" ] | 953 cflags = [ "-Wexit-time-destructors" ] |
| 1179 } | 954 } |
| 1180 } | 955 } |
| 1181 | 956 |
| 1182 # On Windows compiling on x64, VC will issue a warning when converting | 957 # On Windows compiling on x64, VC will issue a warning when converting |
| 1183 # size_t to int because it will truncate the value. Our code should not have | 958 # size_t to int because it will truncate the value. Our code should not have |
| 1184 # these warnings and one should use a static_cast or a checked_cast for the | 959 # these warnings and one should use a static_cast or a checked_cast for the |
| 1185 # conversion depending on the case. However, a lot of code still needs to be | 960 # conversion depending on the case. However, a lot of code still needs to be |
| 1186 # fixed. Apply this config to such targets to disable the warning. | 961 # fixed. Apply this config to such targets to disable the warning. |
| 1187 # | 962 # |
| 1188 # Note that this can be applied regardless of platform and architecture to | 963 # Note that this can be applied regardless of platform and architecture to |
| 1189 # clean up the call sites. This will only apply the flag when necessary. | 964 # clean up the call sites. This will only apply the flag when necessary. |
| 1190 # | 965 # |
| 1191 # TODO(jschuh): crbug.com/167187 fix this and delete this config. | 966 # TODO(jschuh): crbug.com/167187 fix this and delete this config. |
| 1192 config("no_size_t_to_int_warning") { | 967 config("no_size_t_to_int_warning") { |
| 1193 if (is_win && current_cpu == "x64") { | |
| 1194 cflags = [ "/wd4267" ] | |
| 1195 } | |
| 1196 } | 968 } |
| 1197 | 969 |
| 1198 # Some code presumes that pointers to structures/objects are compatible | 970 # Some code presumes that pointers to structures/objects are compatible |
| 1199 # regardless of whether what they point to is already known to be valid. | 971 # regardless of whether what they point to is already known to be valid. |
| 1200 config("no_incompatible_pointer_warnings") { | 972 config("no_incompatible_pointer_warnings") { |
| 1201 cflags = [] | 973 cflags = [] |
| 1202 if (is_clang) { | 974 if (is_clang) { |
| 1203 cflags += [ "-Wno-incompatible-pointer-types" ] | 975 cflags += [ "-Wno-incompatible-pointer-types" ] |
| 1204 } | 976 } |
| 1205 } | 977 } |
| 1206 | 978 |
| 1207 # Optimization ----------------------------------------------------------------- | 979 # Optimization ----------------------------------------------------------------- |
| 1208 # | 980 # |
| 1209 # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config" | 981 # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config" |
| 1210 # which it will assign to the config it implicitly applies to every target. If | 982 # which it will assign to the config it implicitly applies to every target. If |
| 1211 # you want to override the optimization level for your target, remove this | 983 # you want to override the optimization level for your target, remove this |
| 1212 # config (which will expand differently for debug or release builds), and then | 984 # config (which will expand differently for debug or release builds), and then |
| 1213 # add back the one you want to override it with: | 985 # add back the one you want to override it with: |
| 1214 # | 986 # |
| 1215 # configs -= default_optimization_config | 987 # configs -= default_optimization_config |
| 1216 # configs += [ "//build/config/compiler/optimize_max" ] | 988 # configs += [ "//build/config/compiler/optimize_max" ] |
| 1217 | 989 |
| 1218 # Shared settings for both "optimize" and "optimize_max" configs. | 990 # Shared settings for both "optimize" and "optimize_max" configs. |
| 1219 if (is_win) { | 991 common_optimize_on_cflags = [ |
| 1220 common_optimize_on_cflags = [ | 992 # Don't emit the GCC version ident directives, they just end up in the |
| 1221 "/O2", | 993 # .comment section taking up binary size. |
| 1222 "/Ob2", # both explicit and auto inlining. | 994 "-fno-ident", |
| 1223 "/Oy-", # disable omitting frame pointers, must be after /o2. | |
| 1224 "/Os", # favor size over speed. | |
| 1225 ] | |
| 1226 if (!is_asan) { | |
| 1227 common_optimize_on_cflags += [ | |
| 1228 # Put data in separate COMDATs. This allows the linker | |
| 1229 # to put bit-identical constants at the same address even if | |
| 1230 # they're unrelated constants, which saves binary size. | |
| 1231 # This optimization can't be used when ASan is enabled because | |
| 1232 # it is not compatible with the ASan ODR checker. | |
| 1233 "/Gw", | |
| 1234 ] | |
| 1235 } | |
| 1236 common_optimize_on_ldflags = [ "/OPT:REF" ] | |
| 1237 } else { | |
| 1238 common_optimize_on_cflags = [ | |
| 1239 # Don't emit the GCC version ident directives, they just end up in the | |
| 1240 # .comment section taking up binary size. | |
| 1241 "-fno-ident", | |
| 1242 | 995 |
| 1243 # Put data and code in their own sections, so that unused symbols | 996 # Put data and code in their own sections, so that unused symbols |
| 1244 # can be removed at link time with --gc-sections. | 997 # can be removed at link time with --gc-sections. |
| 1245 "-fdata-sections", | 998 "-fdata-sections", |
| 1246 "-ffunction-sections", | 999 "-ffunction-sections", |
| 1247 ] | 1000 ] |
| 1248 common_optimize_on_ldflags = [] | 1001 common_optimize_on_ldflags = [] |
| 1249 | 1002 |
| 1250 if (is_android) { | 1003 if (is_android) { |
| 1251 if (!using_sanitizer) { | 1004 if (!using_sanitizer) { |
| 1252 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] | 1005 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] |
| 1253 } | |
| 1254 | |
| 1255 # TODO(jdduke) Re-enable on mips after resolving linking | |
| 1256 # issues with libc++ (crbug.com/456380). | |
| 1257 if (current_cpu != "mipsel" && current_cpu != "mips64el") { | |
| 1258 common_optimize_on_ldflags += [ | |
| 1259 # Warn in case of text relocations. | |
| 1260 "-Wl,--warn-shared-textrel", | |
| 1261 ] | |
| 1262 } | |
| 1263 } | 1006 } |
| 1264 | 1007 |
| 1265 if (is_mac) { | 1008 # TODO(jdduke) Re-enable on mips after resolving linking |
| 1266 if (symbol_level == 2) { | 1009 # issues with libc++ (crbug.com/456380). |
| 1267 # Mac dead code stripping requires symbols. | 1010 if (current_cpu != "mipsel" && current_cpu != "mips64el") { |
| 1268 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] | |
| 1269 } | |
| 1270 } else { | |
| 1271 # Non-Mac Posix linker flags. | |
| 1272 common_optimize_on_ldflags += [ | 1011 common_optimize_on_ldflags += [ |
| 1273 # Specifically tell the linker to perform optimizations. | 1012 # Warn in case of text relocations. |
| 1274 # See http://lwn.net/Articles/192624/ . | 1013 "-Wl,--warn-shared-textrel", |
| 1275 "-Wl,-O1", | |
| 1276 "-Wl,--gc-sections", | |
| 1277 ] | 1014 ] |
| 1278 | |
| 1279 if (!using_sanitizer) { | |
| 1280 # Functions interposed by the sanitizers can make ld think | |
| 1281 # that some libraries aren't needed when they actually are, | |
| 1282 # http://crbug.com/234010. As workaround, disable --as-needed. | |
| 1283 common_optimize_on_ldflags += [ "-Wl,--as-needed" ] | |
| 1284 } | |
| 1285 } | 1015 } |
| 1286 } | 1016 } |
| 1287 | 1017 |
| 1018 if (is_mac) { |
| 1019 if (symbol_level == 2) { |
| 1020 # Mac dead code stripping requires symbols. |
| 1021 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] |
| 1022 } |
| 1023 } else { |
| 1024 # Non-Mac Posix linker flags. |
| 1025 common_optimize_on_ldflags += [ |
| 1026 # Specifically tell the linker to perform optimizations. |
| 1027 # See http://lwn.net/Articles/192624/ . |
| 1028 "-Wl,-O1", |
| 1029 "-Wl,--gc-sections", |
| 1030 ] |
| 1031 |
| 1032 if (!using_sanitizer) { |
| 1033 # Functions interposed by the sanitizers can make ld think |
| 1034 # that some libraries aren't needed when they actually are, |
| 1035 # http://crbug.com/234010. As workaround, disable --as-needed. |
| 1036 common_optimize_on_ldflags += [ "-Wl,--as-needed" ] |
| 1037 } |
| 1038 } |
| 1039 |
| 1288 # Default "optimization on" config. On Windows, this favors size over speed. | 1040 # Default "optimization on" config. On Windows, this favors size over speed. |
| 1289 config("optimize") { | 1041 config("optimize") { |
| 1290 cflags = common_optimize_on_cflags | 1042 cflags = common_optimize_on_cflags |
| 1291 ldflags = common_optimize_on_ldflags | 1043 ldflags = common_optimize_on_ldflags |
| 1292 if (is_win) { | 1044 if (is_android || is_ios) { |
| 1293 cflags += [ "/Os" ] # favor size over speed. | |
| 1294 } else if (is_android || is_ios) { | |
| 1295 cflags += [ "-Os" ] # Favor size over speed. | 1045 cflags += [ "-Os" ] # Favor size over speed. |
| 1296 } else { | 1046 } else { |
| 1297 cflags += [ "-O2" ] | 1047 cflags += [ "-O2" ] |
| 1298 } | 1048 } |
| 1299 } | 1049 } |
| 1300 | 1050 |
| 1301 # Turn off optimizations. | 1051 # Turn off optimizations. |
| 1302 config("no_optimize") { | 1052 config("no_optimize") { |
| 1303 if (is_win) { | 1053 if (is_android && !android_full_debug) { |
| 1304 cflags = [ | |
| 1305 "/Od", # Disable optimization. | |
| 1306 "/Ob0", # Disable all inlining (on by default). | |
| 1307 "/RTC1", # Runtime checks for stack frame and uninitialized variables. | |
| 1308 ] | |
| 1309 } else if (is_android && !android_full_debug) { | |
| 1310 # On Android we kind of optimize some things that don't affect debugging | 1054 # On Android we kind of optimize some things that don't affect debugging |
| 1311 # much even when optimization is disabled to get the binary size down. | 1055 # much even when optimization is disabled to get the binary size down. |
| 1312 cflags = [ | 1056 cflags = [ |
| 1313 "-Os", | 1057 "-Os", |
| 1314 "-fdata-sections", | 1058 "-fdata-sections", |
| 1315 "-ffunction-sections", | 1059 "-ffunction-sections", |
| 1316 ] | 1060 ] |
| 1317 if (!using_sanitizer) { | 1061 if (!using_sanitizer) { |
| 1318 cflags += [ "-fomit-frame-pointer" ] | 1062 cflags += [ "-fomit-frame-pointer" ] |
| 1319 } | 1063 } |
| 1320 ldflags = common_optimize_on_ldflags | 1064 ldflags = common_optimize_on_ldflags |
| 1321 } else { | 1065 } else { |
| 1322 cflags = [ "-O0" ] | 1066 cflags = [ "-O0" ] |
| 1323 } | 1067 } |
| 1324 } | 1068 } |
| 1325 | 1069 |
| 1326 # Turns up the optimization level. On Windows, this implies whole program | 1070 # Turns up the optimization level. On Windows, this implies whole program |
| 1327 # optimization and link-time code generation which is very expensive and should | 1071 # optimization and link-time code generation which is very expensive and should |
| 1328 # be used sparingly. | 1072 # be used sparingly. |
| 1329 config("optimize_max") { | 1073 config("optimize_max") { |
| 1330 cflags = common_optimize_on_cflags | 1074 cflags = common_optimize_on_cflags |
| 1331 ldflags = common_optimize_on_ldflags | 1075 ldflags = common_optimize_on_ldflags |
| 1332 if (is_win) { | |
| 1333 cflags -= [ "/Os" ] | |
| 1334 cflags += [ "/Ot" ] # Favor speed over size. | |
| 1335 if (is_official_build) { | |
| 1336 # TODO(GYP): TODO(dpranke): Should these only be on in an official | |
| 1337 # build, or on all the time? For now we'll require official build so | |
| 1338 # that the compile is clean. | |
| 1339 cflags += [ | |
| 1340 "/GL", # Whole program optimization. | |
| 1341 | 1076 |
| 1342 # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds. | 1077 cflags += [ "-O2" ] |
| 1343 # Probably anything that this would catch that wouldn't be caught in a | |
| 1344 # normal build isn't going to actually be a bug, so the incremental | |
| 1345 # value of C4702 for PGO builds is likely very small. | |
| 1346 "/wd4702", | |
| 1347 ] | |
| 1348 ldflags += [ "/LTCG" ] | |
| 1349 } | |
| 1350 } else { | |
| 1351 cflags += [ "-O2" ] | |
| 1352 } | |
| 1353 } | 1078 } |
| 1354 | 1079 |
| 1355 # The default optimization applied to all targets. This will be equivalent to | 1080 # The default optimization applied to all targets. This will be equivalent to |
| 1356 # either "optimize" or "no_optimize", depending on the build flags. | 1081 # either "optimize" or "no_optimize", depending on the build flags. |
| 1357 config("default_optimization") { | 1082 config("default_optimization") { |
| 1358 if (is_nacl_irt) { | 1083 if (is_nacl_irt) { |
| 1359 # The NaCl IRT is a special case and always wants its own config. | 1084 # The NaCl IRT is a special case and always wants its own config. |
| 1360 # It gets optimized the same way regardless of the type of build. | 1085 # It gets optimized the same way regardless of the type of build. |
| 1361 configs = [ "//build/config/nacl:irt_optimize" ] | 1086 configs = [ "//build/config/nacl:irt_optimize" ] |
| 1362 } else if (is_debug) { | 1087 } else if (is_debug) { |
| 1363 configs = [ ":no_optimize" ] | 1088 configs = [ ":no_optimize" ] |
| 1364 } else { | 1089 } else { |
| 1365 configs = [ ":optimize" ] | 1090 configs = [ ":optimize" ] |
| 1366 } | 1091 } |
| 1367 } | 1092 } |
| 1368 | 1093 |
| 1369 # Symbols ---------------------------------------------------------------------- | 1094 # Symbols ---------------------------------------------------------------------- |
| 1370 | 1095 |
| 1371 config("symbols") { | 1096 config("symbols") { |
| 1372 if (is_win) { | 1097 cflags = [ "-g2" ] |
| 1373 import("//build/toolchain/goma.gni") | 1098 if (use_debug_fission) { |
| 1374 if (use_goma) { | 1099 cflags += [ "-gsplit-dwarf" ] |
| 1375 cflags = [ "/Z7" ] # No PDB file | |
| 1376 } else { | |
| 1377 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | |
| 1378 } | |
| 1379 ldflags = [ "/DEBUG" ] | |
| 1380 } else { | |
| 1381 cflags = [ "-g2" ] | |
| 1382 if (use_debug_fission) { | |
| 1383 cflags += [ "-gsplit-dwarf" ] | |
| 1384 } | |
| 1385 asmflags = cflags | |
| 1386 ldflags = [] | |
| 1387 } | 1100 } |
| 1101 asmflags = cflags |
| 1102 ldflags = [] |
| 1388 } | 1103 } |
| 1389 | 1104 |
| 1390 config("minimal_symbols") { | 1105 config("minimal_symbols") { |
| 1391 if (is_win) { | 1106 cflags = [ "-g1" ] |
| 1392 # Linker symbols for backtraces only. | 1107 if (use_debug_fission) { |
| 1393 ldflags = [ "/DEBUG" ] | 1108 cflags += [ "-gsplit-dwarf" ] |
| 1394 } else { | |
| 1395 cflags = [ "-g1" ] | |
| 1396 if (use_debug_fission) { | |
| 1397 cflags += [ "-gsplit-dwarf" ] | |
| 1398 } | |
| 1399 asmflags = cflags | |
| 1400 ldflags = [] | |
| 1401 } | 1109 } |
| 1110 asmflags = cflags |
| 1111 ldflags = [] |
| 1402 } | 1112 } |
| 1403 | 1113 |
| 1404 config("no_symbols") { | 1114 config("no_symbols") { |
| 1405 if (!is_win) { | 1115 cflags = [ "-g0" ] |
| 1406 cflags = [ "-g0" ] | 1116 asmflags = cflags |
| 1407 asmflags = cflags | |
| 1408 } | |
| 1409 } | 1117 } |
| 1410 | 1118 |
| 1411 # Default symbols. | 1119 # Default symbols. |
| 1412 config("default_symbols") { | 1120 config("default_symbols") { |
| 1413 if (symbol_level == 0) { | 1121 if (symbol_level == 0) { |
| 1414 configs = [ ":no_symbols" ] | 1122 configs = [ ":no_symbols" ] |
| 1415 } else if (symbol_level == 1) { | 1123 } else if (symbol_level == 1) { |
| 1416 configs = [ ":minimal_symbols" ] | 1124 configs = [ ":minimal_symbols" ] |
| 1417 } else if (symbol_level == 2) { | 1125 } else if (symbol_level == 2) { |
| 1418 configs = [ ":symbols" ] | 1126 configs = [ ":symbols" ] |
| 1419 } else { | 1127 } else { |
| 1420 assert(false) | 1128 assert(false) |
| 1421 } | 1129 } |
| 1422 } | 1130 } |
| OLD | NEW |