Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
| 7 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 # GCC flags, and then we handle the other non-Windows platforms specifically | 95 # GCC flags, and then we handle the other non-Windows platforms specifically |
| 96 # below. | 96 # below. |
| 97 if (is_win) { | 97 if (is_win) { |
| 98 # Windows compiler flags setup. | 98 # Windows compiler flags setup. |
| 99 # ----------------------------- | 99 # ----------------------------- |
| 100 cflags += [ | 100 cflags += [ |
| 101 "/Gy", # Enable function-level linking. | 101 "/Gy", # Enable function-level linking. |
| 102 "/GS", # Enable buffer security checking. | 102 "/GS", # Enable buffer security checking. |
| 103 "/FS", # Preserve previous PDB behavior. | 103 "/FS", # Preserve previous PDB behavior. |
| 104 ] | 104 ] |
| 105 | |
| 106 # Building with Clang on Windows is a work in progress and very | |
| 107 # experimental. See crbug.com/82385. | |
| 108 # Keep this in sync with the similar block in build/common.gypi | |
| 109 if (is_clang) { | |
| 110 cflags += [ | |
| 111 "-fmsc-version=1800", | |
| 112 | |
| 113 # Many files use intrinsics without including this header. | |
| 114 # TODO(hans): Fix those files, or move this to sub-GYPs. | |
| 115 "/FIIntrin.h", | |
| 116 ] | |
| 117 if (current_cpu == "x32") { | |
| 118 cflags += [ "/fallback" ] | |
| 119 } | |
| 120 } | |
| 105 } else { | 121 } else { |
| 106 # Common GCC compiler flags setup. | 122 # Common GCC compiler flags setup. |
| 107 # -------------------------------- | 123 # -------------------------------- |
| 108 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 | 124 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 |
| 109 cflags_cc += [ | 125 cflags_cc += [ |
| 110 "-fno-threadsafe-statics", | 126 "-fno-threadsafe-statics", |
| 111 | 127 |
| 112 # Not exporting C++ inline functions can generally be applied anywhere | 128 # Not exporting C++ inline functions can generally be applied anywhere |
| 113 # so we do so here. Normal function visibility is controlled by | 129 # so we do so here. Normal function visibility is controlled by |
| 114 # //build/config/gcc:symbol_visibility_hidden. | 130 # //build/config/gcc:symbol_visibility_hidden. |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 } | 782 } |
| 767 } | 783 } |
| 768 | 784 |
| 769 # Warnings --------------------------------------------------------------------- | 785 # Warnings --------------------------------------------------------------------- |
| 770 # | 786 # |
| 771 # This is where we disable various warnings that we've decided aren't | 787 # This is where we disable various warnings that we've decided aren't |
| 772 # worthwhile, and enable special warnings. | 788 # worthwhile, and enable special warnings. |
| 773 | 789 |
| 774 config("default_warnings") { | 790 config("default_warnings") { |
| 775 if (is_win) { | 791 if (is_win) { |
| 776 cflags = [ | 792 cflags = [] |
| 777 "/WX", # Treat warnings as errors. | |
| 778 | 793 |
| 794 if (!is_clang || current_cpu != "x32") { | |
| 795 cflags += [ "/WX" ] # Treat warnings as errors. | |
| 796 } | |
| 797 | |
| 798 cflags += [ | |
| 779 # Warnings permanently disabled: | 799 # Warnings permanently disabled: |
| 780 | 800 |
| 781 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled | 801 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled |
| 782 # for a bunch of individual targets. Re-enable this globally when those | 802 # for a bunch of individual targets. Re-enable this globally when those |
| 783 # targets are fixed. | 803 # targets are fixed. |
| 784 "/wd4018", # Comparing signed and unsigned values. | 804 "/wd4018", # Comparing signed and unsigned values. |
| 785 | 805 |
| 786 # C4127: conditional expression is constant | 806 # C4127: conditional expression is constant |
| 787 # This warning can in theory catch dead code and other problems, but | 807 # This warning can in theory catch dead code and other problems, but |
| 788 # triggers in far too many desirable cases where the conditional | 808 # triggers in far too many desirable cases where the conditional |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 "/wd4996", # Deprecated function warning. | 864 "/wd4996", # Deprecated function warning. |
| 845 ] | 865 ] |
| 846 | 866 |
| 847 # VS xtree header file needs to be patched or 4702 (unreachable code | 867 # VS xtree header file needs to be patched or 4702 (unreachable code |
| 848 # warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is | 868 # warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is |
| 849 # not patched. | 869 # not patched. |
| 850 if (!msvs_xtree_patched && | 870 if (!msvs_xtree_patched && |
| 851 exec_script("../../win_is_xtree_patched.py", [], "value") == 0) { | 871 exec_script("../../win_is_xtree_patched.py", [], "value") == 0) { |
| 852 cflags += [ "/wd4702" ] # Unreachable code. | 872 cflags += [ "/wd4702" ] # Unreachable code. |
| 853 } | 873 } |
| 874 | |
| 875 # Building with Clang on Windows is a work in progress and very | |
| 876 # experimental. See crbug.com/82385. | |
| 877 # Keep this in sync with the similar block in build/common.gypi | |
| 878 if (is_clang) { | |
| 879 cflags += [ | |
| 880 # TODO(hans): Make this list shorter eventually. | |
| 881 "-Qunused-arguments", | |
| 882 "-Wno-c++11-compat-deprecated-writable-strings", | |
| 883 "-Wno-deprecated-declarations", | |
| 884 "-Wno-empty-body", | |
| 885 "-Wno-enum-conversion", | |
| 886 "-Wno-extra-tokens", | |
| 887 "-Wno-ignored-attributes", | |
| 888 "-Wno-incompatible-pointer-types", | |
| 889 "-Wno-int-to-void-pointer-cast", | |
| 890 "-Wno-invalid-noreturn", | |
| 891 "-Wno-logical-op-parentheses", | |
| 892 "-Wno-microsoft", | |
| 893 "-Wno-missing-braces", | |
| 894 "-Wno-missing-declarations", | |
| 895 "-Wno-msvc-include", | |
| 896 "-Wno-null-dereference", | |
| 897 "-Wno-overloaded-virtual", | |
| 898 "-Wno-parentheses", | |
| 899 "-Wno-pointer-sign", | |
| 900 "-Wno-reorder", | |
| 901 "-Wno-return-type-c-linkage", | |
| 902 "-Wno-self-assign", | |
| 903 "-Wno-sometimes-uninitialized", | |
| 904 "-Wno-switch", | |
| 905 "-Wno-tautological-compare", | |
| 906 "-Wno-unknown-pragmas", | |
| 907 "-Wno-unsequenced", | |
| 908 "-Wno-unused-function", | |
| 909 "-Wno-unused-private-field", | |
| 910 "-Wno-unused-value", | |
| 911 "-Wno-unused-variable", | |
| 912 "-Wno-unused-local-typedef", # http://crbug.com/411648 | |
| 913 "-Wno-inconsistent-missing-override", #http://crbug.com/428099 | |
|
Nico
2015/06/02 22:52:58
`gn format` insisted that I don't put a space afte
scottmg
2015/06/02 23:02:21
o_O sorry, not sure why https://code.google.com/p/
| |
| 914 ] | |
| 915 } | |
| 854 } else { | 916 } else { |
| 855 # Common GCC warning setup. | 917 # Common GCC warning setup. |
| 856 cflags = [ | 918 cflags = [ |
| 857 # Enables. | 919 # Enables. |
| 858 "-Wendif-labels", # Weird old-style text after an #endif. | 920 "-Wendif-labels", # Weird old-style text after an #endif. |
| 859 "-Werror", # Warnings as errors. | 921 "-Werror", # Warnings as errors. |
| 860 | 922 |
| 861 # Disables. | 923 # Disables. |
| 862 "-Wno-missing-field-initializers", # "struct foo f = {0};" | 924 "-Wno-missing-field-initializers", # "struct foo f = {0};" |
| 863 "-Wno-unused-parameter", # Unused function parameters. | 925 "-Wno-unused-parameter", # Unused function parameters. |
| 864 ] | 926 ] |
| 865 cflags_cc = [] | 927 cflags_cc = [] |
| 866 | 928 |
| 867 if (is_mac) { | 929 if (is_mac) { |
| 868 cflags += [ "-Wnewline-eof" ] | 930 cflags += [ "-Wnewline-eof" ] |
| 869 if (!is_nacl) { | 931 if (!is_nacl) { |
| 870 # When compiling Objective-C, warns if a method is used whose | 932 # When compiling Objective-C, warns if a method is used whose |
| 871 # availability is newer than the deployment target. This is not | 933 # availability is newer than the deployment target. This is not |
| 872 # required when compiling Chrome for iOS. | 934 # required when compiling Chrome for iOS. |
| 873 cflags += [ "-Wpartial-availability" ] | 935 cflags += [ "-Wpartial-availability" ] |
| 874 } | 936 } |
| 875 } | 937 } |
| 876 | 938 |
| 877 if (is_clang) { | |
| 878 cflags += [ | |
| 879 # This warns on using ints as initializers for floats in | |
| 880 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), | |
| 881 # which happens in several places in chrome code. Not sure if | |
| 882 # this is worth fixing. | |
| 883 "-Wno-c++11-narrowing", | |
| 884 | |
| 885 # Don't die on dtoa code that uses a char as an array index. | |
| 886 # This is required solely for base/third_party/dmg_fp/dtoa.cc. | |
| 887 # TODO(brettw) move this to that project then! | |
| 888 "-Wno-char-subscripts", | |
| 889 | |
| 890 # Warns on switches on enums that cover all enum values but | |
| 891 # also contain a default: branch. Chrome is full of that. | |
| 892 "-Wno-covered-switch-default", | |
| 893 | |
| 894 # Clang considers the `register` keyword as deprecated, but e.g. | |
| 895 # code generated by flex (used in angle) contains that keyword. | |
| 896 # http://crbug.com/255186 | |
| 897 "-Wno-deprecated-register", | |
| 898 | |
| 899 # TODO(thakis): This used to be implied by -Wno-unused-function, | |
| 900 # which we no longer use. Check if it makes sense to remove | |
| 901 # this as well. http://crbug.com/316352 | |
| 902 "-Wno-unneeded-internal-declaration", | |
| 903 | |
| 904 # TODO(thakis): Remove, http://crbug.com/263960 | |
| 905 "-Wno-reserved-user-defined-literal", | |
| 906 ] | |
| 907 | |
| 908 # NaCl's Clang compiler and Chrome's hermetic Clang compiler will almost | |
| 909 # always have different versions. Certain flags may not be recognized by | |
| 910 # one version or the other. | |
| 911 if (!is_nacl) { | |
| 912 # Flags NaCl does not recognize. | |
| 913 cflags += [ | |
| 914 # TODO(hans): Get this cleaned up. | |
| 915 "-Wno-inconsistent-missing-override", | |
| 916 ] | |
| 917 } | |
| 918 } | |
| 919 if (gcc_version >= 48) { | 939 if (gcc_version >= 48) { |
| 920 cflags_cc += [ | 940 cflags_cc += [ |
| 921 # See comment for -Wno-c++11-narrowing. | 941 # See comment for -Wno-c++11-narrowing. |
| 922 "-Wno-narrowing", | 942 "-Wno-narrowing", |
| 923 | 943 |
| 924 # TODO(thakis): Remove, http://crbug.com/263960 | 944 # TODO(thakis): Remove, http://crbug.com/263960 |
| 925 "-Wno-literal-suffix", | 945 "-Wno-literal-suffix", |
| 926 ] | 946 ] |
| 927 } | 947 } |
| 928 | 948 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 954 ] | 974 ] |
| 955 } | 975 } |
| 956 | 976 |
| 957 if (gcc_version >= 48) { | 977 if (gcc_version >= 48) { |
| 958 # Don't warn about the "typedef 'foo' locally defined but not used" | 978 # Don't warn about the "typedef 'foo' locally defined but not used" |
| 959 # for gcc 4.8. | 979 # for gcc 4.8. |
| 960 # TODO: remove this flag once all builds work. See crbug.com/227506 | 980 # TODO: remove this flag once all builds work. See crbug.com/227506 |
| 961 cflags += [ "-Wno-unused-local-typedefs" ] | 981 cflags += [ "-Wno-unused-local-typedefs" ] |
| 962 } | 982 } |
| 963 } | 983 } |
| 984 | |
| 985 if (is_clang) { | |
| 986 cflags += [ | |
| 987 # This warns on using ints as initializers for floats in | |
| 988 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), | |
| 989 # which happens in several places in chrome code. Not sure if | |
| 990 # this is worth fixing. | |
| 991 "-Wno-c++11-narrowing", | |
| 992 | |
| 993 # Don't die on dtoa code that uses a char as an array index. | |
| 994 # This is required solely for base/third_party/dmg_fp/dtoa.cc. | |
| 995 # TODO(brettw) move this to that project then! | |
| 996 "-Wno-char-subscripts", | |
| 997 | |
| 998 # Warns on switches on enums that cover all enum values but | |
| 999 # also contain a default: branch. Chrome is full of that. | |
| 1000 "-Wno-covered-switch-default", | |
| 1001 | |
| 1002 # Clang considers the `register` keyword as deprecated, but e.g. | |
| 1003 # code generated by flex (used in angle) contains that keyword. | |
| 1004 # http://crbug.com/255186 | |
| 1005 "-Wno-deprecated-register", | |
| 1006 | |
| 1007 # TODO(thakis): This used to be implied by -Wno-unused-function, | |
| 1008 # which we no longer use. Check if it makes sense to remove | |
| 1009 # this as well. http://crbug.com/316352 | |
| 1010 "-Wno-unneeded-internal-declaration", | |
| 1011 | |
| 1012 # TODO(thakis): Remove, http://crbug.com/263960 | |
| 1013 "-Wno-reserved-user-defined-literal", | |
| 1014 ] | |
| 1015 | |
| 1016 # NaCl's Clang compiler and Chrome's hermetic Clang compiler will almost | |
| 1017 # always have different versions. Certain flags may not be recognized by | |
| 1018 # one version or the other. | |
| 1019 if (!is_nacl) { | |
| 1020 # Flags NaCl does not recognize. | |
| 1021 cflags += [ | |
| 1022 # TODO(hans): Get this cleaned up. | |
| 1023 "-Wno-inconsistent-missing-override", | |
| 1024 ] | |
| 1025 } | |
| 1026 } | |
| 964 } | 1027 } |
| 965 | 1028 |
| 966 # This will generate warnings when using Clang if code generates exit-time | 1029 # This will generate warnings when using Clang if code generates exit-time |
| 967 # destructors, which will slow down closing the program. | 1030 # destructors, which will slow down closing the program. |
| 968 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 | 1031 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 |
| 969 config("wexit_time_destructors") { | 1032 config("wexit_time_destructors") { |
| 970 if (is_clang) { | 1033 # TODO: Enable on Windows too, http://crbug.com/404525 |
| 1034 if (is_clang && !is_win) { | |
| 971 cflags = [ "-Wexit-time-destructors" ] | 1035 cflags = [ "-Wexit-time-destructors" ] |
| 972 } | 1036 } |
| 973 } | 1037 } |
| 974 | 1038 |
| 975 # On Windows compiling on x64, VC will issue a warning when converting | 1039 # On Windows compiling on x64, VC will issue a warning when converting |
| 976 # size_t to int because it will truncate the value. Our code should not have | 1040 # size_t to int because it will truncate the value. Our code should not have |
| 977 # these warnings and one should use a static_cast or a checked_cast for the | 1041 # these warnings and one should use a static_cast or a checked_cast for the |
| 978 # conversion depending on the case. However, a lot of code still needs to be | 1042 # conversion depending on the case. However, a lot of code still needs to be |
| 979 # fixed. Apply this config to such targets to disable the warning. | 1043 # fixed. Apply this config to such targets to disable the warning. |
| 980 # | 1044 # |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 cflags += [ "-gsplit-dwarf" ] | 1229 cflags += [ "-gsplit-dwarf" ] |
| 1166 } | 1230 } |
| 1167 } | 1231 } |
| 1168 } | 1232 } |
| 1169 | 1233 |
| 1170 config("no_symbols") { | 1234 config("no_symbols") { |
| 1171 if (!is_win) { | 1235 if (!is_win) { |
| 1172 cflags = [ "-g0" ] | 1236 cflags = [ "-g0" ] |
| 1173 } | 1237 } |
| 1174 } | 1238 } |
| OLD | NEW |