clang/win: Make everything work in a GN build.

Do this by removing the default_warnings config, moving the flags in there to a
variable, and use it in both the chromium_code and no_chromium_code configs.

If a target does

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]

this would add no_chromium_code to the end of configs previously, and the
-Wno-foo flags in default_warnings would be passed before the /W3 flag in
no_chromium_code (and /W3 would then override some of the -Wno-foo flags).
By moving the flags into no_chromium_code, they're guaranteed to appear
after /W3 (and after -Wall on POSIX).

See also thread "configs and warning cflag ordering" on gn-dev:
https://groups.google.com/a/chromium.org/forum/#!topic/gn-dev/qkqdlwtcQW4

In a similar vein, move a -Wno-foo flag in skia/BUILD.gn into a config, to make sure
it appears at the end of the compile command.

While here, also remove /wd4267 from skia's BUILD.gn, it's already passed globally
(this part doesn't change behavior).

(clang-cl working with gn also needs an ffmpeg roll to pick up
5eb7926d25
This is blocked on http://crbug.com/496975)

BUG=491209
CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:android_chromium_gn_compile_dbg,android_chromium_gn_compile_rel;tryserver.chromium.win:win8_chromium_gn_rel,win8_chromium_gn_dbg;tryserver.chromium.mac:mac_chromium_gn_rel,mac_chromium_gn_dbg

Review URL: https://codereview.chromium.org/1151303006

Cr-Original-Commit-Position: refs/heads/master@{#333380}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0bfa8a8a759697b140ef2a18f058513ec8485a57
This commit is contained in:
thakis 2015-06-08 16:14:21 -07:00 коммит произвёл Commit bot
Родитель e2b7294dbe
Коммит 2e4c8015ad
2 изменённых файлов: 244 добавлений и 243 удалений

Просмотреть файл

@ -361,7 +361,6 @@ _native_compiler_configs = [
"//build/config/compiler:compiler_arm_fpu",
"//build/config/compiler:chromium_code",
"//build/config/compiler:default_include_dirs",
"//build/config/compiler:default_warnings",
"//build/config/compiler:no_rtti",
"//build/config/compiler:runtime_library",
]

Просмотреть файл

@ -704,6 +704,246 @@ config("runtime_library") {
}
}
# default_warning_flags collects all warning flags that are used by default.
# This is in a variable instead of a config so that it can be used in
# both chromium_code and no_chromium_code. This way these flags are guaranteed
# to appear on the compile command line after -Wall.
default_warning_flags = []
default_warning_flags_cc = []
if (is_win) {
if (!is_clang || current_cpu != "x86") {
default_warning_flags += [ "/WX" ] # Treat warnings as errors.
}
default_warning_flags += [
# Warnings permanently disabled:
# TODO(GYP) The GYP build doesn't have this globally enabled but disabled
# for a bunch of individual targets. Re-enable this globally when those
# targets are fixed.
"/wd4018", # Comparing signed and unsigned values.
# C4127: conditional expression is constant
# This warning can in theory catch dead code and other problems, but
# triggers in far too many desirable cases where the conditional
# expression is either set by macros or corresponds some legitimate
# compile-time constant expression (due to constant template args,
# conditionals comparing the sizes of different types, etc.). Some of
# these can be worked around, but it's not worth it.
"/wd4127",
# C4251: 'identifier' : class 'type' needs to have dll-interface to be
# used by clients of class 'type2'
# This is necessary for the shared library build.
"/wd4251",
# C4351: new behavior: elements of array 'array' will be default
# initialized
# This is a silly "warning" that basically just alerts you that the
# compiler is going to actually follow the language spec like it's
# supposed to, instead of not following it like old buggy versions did.
# There's absolutely no reason to turn this on.
"/wd4351",
# C4355: 'this': used in base member initializer list
# It's commonly useful to pass |this| to objects in a class' initializer
# list. While this warning can catch real bugs, most of the time the
# constructors in question don't attempt to call methods on the passed-in
# pointer (until later), and annotating every legit usage of this is
# simply more hassle than the warning is worth.
"/wd4355",
# C4503: 'identifier': decorated name length exceeded, name was
# truncated
# This only means that some long error messages might have truncated
# identifiers in the presence of lots of templates. It has no effect on
# program correctness and there's no real reason to waste time trying to
# prevent it.
"/wd4503",
# C4611: interaction between 'function' and C++ object destruction is
# non-portable
# This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
# suggests using exceptions instead of setjmp/longjmp for C++, but
# Chromium code compiles without exception support. We therefore have to
# use setjmp/longjmp for e.g. JPEG decode error handling, which means we
# have to turn off this warning (and be careful about how object
# destruction happens in such cases).
"/wd4611",
# Warnings to evaluate and possibly fix/reenable later:
"/wd4100", # Unreferenced formal function parameter.
"/wd4121", # Alignment of a member was sensitive to packing.
"/wd4244", # Conversion: possible loss of data.
"/wd4481", # Nonstandard extension: override specifier.
"/wd4505", # Unreferenced local function has been removed.
"/wd4510", # Default constructor could not be generated.
"/wd4512", # Assignment operator could not be generated.
"/wd4610", # Class can never be instantiated, constructor required.
"/wd4996", # Deprecated function warning.
]
# VS xtree header file needs to be patched or 4702 (unreachable code
# warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is
# not patched.
if (!msvs_xtree_patched &&
exec_script("../../win_is_xtree_patched.py", [], "value") == 0) {
default_warning_flags += [ "/wd4702" ] # Unreachable code.
}
# Building with Clang on Windows is a work in progress and very
# experimental. See crbug.com/82385.
# Keep this in sync with the similar block in build/common.gypi
if (is_clang) {
default_warning_flags += [
# TODO(hans): Make this list shorter eventually.
"-Qunused-arguments",
"-Wno-c++11-compat-deprecated-writable-strings",
"-Wno-deprecated-declarations",
"-Wno-empty-body",
"-Wno-enum-conversion",
"-Wno-extra-tokens",
"-Wno-ignored-attributes",
"-Wno-incompatible-pointer-types",
"-Wno-int-to-void-pointer-cast",
"-Wno-invalid-noreturn",
"-Wno-logical-op-parentheses",
"-Wno-microsoft",
"-Wno-missing-braces",
"-Wno-missing-declarations",
"-Wno-msvc-include",
"-Wno-null-dereference",
"-Wno-overloaded-virtual",
"-Wno-parentheses",
"-Wno-pointer-sign",
"-Wno-reorder",
"-Wno-return-type-c-linkage",
"-Wno-self-assign",
"-Wno-sometimes-uninitialized",
"-Wno-switch",
"-Wno-tautological-compare",
"-Wno-unknown-pragmas",
"-Wno-unsequenced",
"-Wno-unused-function",
"-Wno-unused-private-field",
"-Wno-unused-value",
"-Wno-unused-variable",
"-Wno-unused-local-typedef", # http://crbug.com/411648
"-Wno-inconsistent-missing-override", #http://crbug.com/428099
]
}
} else {
# Common GCC warning setup.
default_warning_flags += [
# Enables.
"-Wendif-labels", # Weird old-style text after an #endif.
"-Werror", # Warnings as errors.
# Disables.
"-Wno-missing-field-initializers", # "struct foo f = {0};"
"-Wno-unused-parameter", # Unused function parameters.
]
if (is_mac) {
default_warning_flags += [ "-Wnewline-eof" ]
if (!is_nacl) {
# When compiling Objective-C, warns if a method is used whose
# availability is newer than the deployment target. This is not
# required when compiling Chrome for iOS.
default_warning_flags += [ "-Wpartial-availability" ]
}
}
if (gcc_version >= 48) {
default_warning_flags_cc += [
# See comment for -Wno-c++11-narrowing.
"-Wno-narrowing",
# TODO(thakis): Remove, http://crbug.com/263960
"-Wno-literal-suffix",
]
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
# warning).
if (current_cpu == "arm" && !is_clang) {
default_warning_flags += [ "-Wno-psabi" ]
}
if (is_android) {
# Disable any additional warnings enabled by the Android build system but
# which chromium does not build cleanly with (when treating warning as
# errors).
default_warning_flags += [
"-Wno-extra",
"-Wno-ignored-qualifiers",
"-Wno-type-limits",
]
default_warning_flags_cc += [
# Disabling c++0x-compat should be handled in WebKit, but
# this currently doesn't work because gcc_version is not set
# correctly when building with the Android build system.
# TODO(torne): Fix this in WebKit.
"-Wno-error=c++0x-compat",
# Other things unrelated to -Wextra:
"-Wno-non-virtual-dtor",
"-Wno-sign-promo",
]
}
if (gcc_version >= 48) {
# Don't warn about the "typedef 'foo' locally defined but not used"
# for gcc 4.8.
# TODO: remove this flag once all builds work. See crbug.com/227506
default_warning_flags += [ "-Wno-unused-local-typedefs" ]
}
}
if (is_clang) {
default_warning_flags += [
# This warns on using ints as initializers for floats in
# initializer lists (e.g. |int a = f(); CGSize s = { a, a };|),
# which happens in several places in chrome code. Not sure if
# this is worth fixing.
"-Wno-c++11-narrowing",
# Don't die on dtoa code that uses a char as an array index.
# This is required solely for base/third_party/dmg_fp/dtoa.cc.
# TODO(brettw) move this to that project then!
"-Wno-char-subscripts",
# Warns on switches on enums that cover all enum values but
# also contain a default: branch. Chrome is full of that.
"-Wno-covered-switch-default",
# Clang considers the `register` keyword as deprecated, but e.g.
# code generated by flex (used in angle) contains that keyword.
# http://crbug.com/255186
"-Wno-deprecated-register",
# TODO(thakis): This used to be implied by -Wno-unused-function,
# which we no longer use. Check if it makes sense to remove
# this as well. http://crbug.com/316352
"-Wno-unneeded-internal-declaration",
# TODO(thakis): Remove, http://crbug.com/263960
"-Wno-reserved-user-defined-literal",
]
# NaCl's Clang compiler and Chrome's hermetic Clang compiler will almost
# always have different versions. Certain flags may not be recognized by
# one version or the other.
if (!is_nacl) {
# Flags NaCl does not recognize.
default_warning_flags += [
# TODO(hans): Get this cleaned up.
"-Wno-inconsistent-missing-override",
]
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -742,6 +982,8 @@ config("chromium_code") {
defines += [ "_FORTIFY_SOURCE=2" ]
}
}
cflags += default_warning_flags
cflags_cc = default_warning_flags_cc
}
config("no_chromium_code") {
cflags = []
@ -780,6 +1022,8 @@ config("no_chromium_code") {
"-Wno-deprecated",
]
}
cflags += default_warning_flags
cflags_cc += default_warning_flags_cc
}
# rtti ------------------------------------------------------------------------
@ -800,248 +1044,6 @@ config("no_rtti") {
}
# Warnings ---------------------------------------------------------------------
#
# This is where we disable various warnings that we've decided aren't
# worthwhile, and enable special warnings.
config("default_warnings") {
if (is_win) {
cflags = []
if (!is_clang || current_cpu != "x86") {
cflags += [ "/WX" ] # Treat warnings as errors.
}
cflags += [
# Warnings permanently disabled:
# TODO(GYP) The GYP build doesn't have this globally enabled but disabled
# for a bunch of individual targets. Re-enable this globally when those
# targets are fixed.
"/wd4018", # Comparing signed and unsigned values.
# C4127: conditional expression is constant
# This warning can in theory catch dead code and other problems, but
# triggers in far too many desirable cases where the conditional
# expression is either set by macros or corresponds some legitimate
# compile-time constant expression (due to constant template args,
# conditionals comparing the sizes of different types, etc.). Some of
# these can be worked around, but it's not worth it.
"/wd4127",
# C4251: 'identifier' : class 'type' needs to have dll-interface to be
# used by clients of class 'type2'
# This is necessary for the shared library build.
"/wd4251",
# C4351: new behavior: elements of array 'array' will be default
# initialized
# This is a silly "warning" that basically just alerts you that the
# compiler is going to actually follow the language spec like it's
# supposed to, instead of not following it like old buggy versions did.
# There's absolutely no reason to turn this on.
"/wd4351",
# C4355: 'this': used in base member initializer list
# It's commonly useful to pass |this| to objects in a class' initializer
# list. While this warning can catch real bugs, most of the time the
# constructors in question don't attempt to call methods on the passed-in
# pointer (until later), and annotating every legit usage of this is
# simply more hassle than the warning is worth.
"/wd4355",
# C4503: 'identifier': decorated name length exceeded, name was
# truncated
# This only means that some long error messages might have truncated
# identifiers in the presence of lots of templates. It has no effect on
# program correctness and there's no real reason to waste time trying to
# prevent it.
"/wd4503",
# C4611: interaction between 'function' and C++ object destruction is
# non-portable
# This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
# suggests using exceptions instead of setjmp/longjmp for C++, but
# Chromium code compiles without exception support. We therefore have to
# use setjmp/longjmp for e.g. JPEG decode error handling, which means we
# have to turn off this warning (and be careful about how object
# destruction happens in such cases).
"/wd4611",
# Warnings to evaluate and possibly fix/reenable later:
"/wd4100", # Unreferenced formal function parameter.
"/wd4121", # Alignment of a member was sensitive to packing.
"/wd4244", # Conversion: possible loss of data.
"/wd4481", # Nonstandard extension: override specifier.
"/wd4505", # Unreferenced local function has been removed.
"/wd4510", # Default constructor could not be generated.
"/wd4512", # Assignment operator could not be generated.
"/wd4610", # Class can never be instantiated, constructor required.
"/wd4996", # Deprecated function warning.
]
# VS xtree header file needs to be patched or 4702 (unreachable code
# warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is
# not patched.
if (!msvs_xtree_patched &&
exec_script("../../win_is_xtree_patched.py", [], "value") == 0) {
cflags += [ "/wd4702" ] # Unreachable code.
}
# Building with Clang on Windows is a work in progress and very
# experimental. See crbug.com/82385.
# Keep this in sync with the similar block in build/common.gypi
if (is_clang) {
cflags += [
# TODO(hans): Make this list shorter eventually.
"-Qunused-arguments",
"-Wno-c++11-compat-deprecated-writable-strings",
"-Wno-deprecated-declarations",
"-Wno-empty-body",
"-Wno-enum-conversion",
"-Wno-extra-tokens",
"-Wno-ignored-attributes",
"-Wno-incompatible-pointer-types",
"-Wno-int-to-void-pointer-cast",
"-Wno-invalid-noreturn",
"-Wno-logical-op-parentheses",
"-Wno-microsoft",
"-Wno-missing-braces",
"-Wno-missing-declarations",
"-Wno-msvc-include",
"-Wno-null-dereference",
"-Wno-overloaded-virtual",
"-Wno-parentheses",
"-Wno-pointer-sign",
"-Wno-reorder",
"-Wno-return-type-c-linkage",
"-Wno-self-assign",
"-Wno-sometimes-uninitialized",
"-Wno-switch",
"-Wno-tautological-compare",
"-Wno-unknown-pragmas",
"-Wno-unsequenced",
"-Wno-unused-function",
"-Wno-unused-private-field",
"-Wno-unused-value",
"-Wno-unused-variable",
"-Wno-unused-local-typedef", # http://crbug.com/411648
"-Wno-inconsistent-missing-override", #http://crbug.com/428099
]
}
} else {
# Common GCC warning setup.
cflags = [
# Enables.
"-Wendif-labels", # Weird old-style text after an #endif.
"-Werror", # Warnings as errors.
# Disables.
"-Wno-missing-field-initializers", # "struct foo f = {0};"
"-Wno-unused-parameter", # Unused function parameters.
]
cflags_cc = []
if (is_mac) {
cflags += [ "-Wnewline-eof" ]
if (!is_nacl) {
# When compiling Objective-C, warns if a method is used whose
# availability is newer than the deployment target. This is not
# required when compiling Chrome for iOS.
cflags += [ "-Wpartial-availability" ]
}
}
if (gcc_version >= 48) {
cflags_cc += [
# See comment for -Wno-c++11-narrowing.
"-Wno-narrowing",
# TODO(thakis): Remove, http://crbug.com/263960
"-Wno-literal-suffix",
]
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
# warning).
if (current_cpu == "arm" && !is_clang) {
cflags += [ "-Wno-psabi" ]
}
if (is_android) {
# Disable any additional warnings enabled by the Android build system but
# which chromium does not build cleanly with (when treating warning as
# errors).
cflags += [
"-Wno-extra",
"-Wno-ignored-qualifiers",
"-Wno-type-limits",
]
cflags_cc += [
# Disabling c++0x-compat should be handled in WebKit, but
# this currently doesn't work because gcc_version is not set
# correctly when building with the Android build system.
# TODO(torne): Fix this in WebKit.
"-Wno-error=c++0x-compat",
# Other things unrelated to -Wextra:
"-Wno-non-virtual-dtor",
"-Wno-sign-promo",
]
}
if (gcc_version >= 48) {
# Don't warn about the "typedef 'foo' locally defined but not used"
# for gcc 4.8.
# TODO: remove this flag once all builds work. See crbug.com/227506
cflags += [ "-Wno-unused-local-typedefs" ]
}
}
if (is_clang) {
cflags += [
# This warns on using ints as initializers for floats in
# initializer lists (e.g. |int a = f(); CGSize s = { a, a };|),
# which happens in several places in chrome code. Not sure if
# this is worth fixing.
"-Wno-c++11-narrowing",
# Don't die on dtoa code that uses a char as an array index.
# This is required solely for base/third_party/dmg_fp/dtoa.cc.
# TODO(brettw) move this to that project then!
"-Wno-char-subscripts",
# Warns on switches on enums that cover all enum values but
# also contain a default: branch. Chrome is full of that.
"-Wno-covered-switch-default",
# Clang considers the `register` keyword as deprecated, but e.g.
# code generated by flex (used in angle) contains that keyword.
# http://crbug.com/255186
"-Wno-deprecated-register",
# TODO(thakis): This used to be implied by -Wno-unused-function,
# which we no longer use. Check if it makes sense to remove
# this as well. http://crbug.com/316352
"-Wno-unneeded-internal-declaration",
# TODO(thakis): Remove, http://crbug.com/263960
"-Wno-reserved-user-defined-literal",
]
# NaCl's Clang compiler and Chrome's hermetic Clang compiler will almost
# always have different versions. Certain flags may not be recognized by
# one version or the other.
if (!is_nacl) {
# Flags NaCl does not recognize.
cflags += [
# TODO(hans): Get this cleaned up.
"-Wno-inconsistent-missing-override",
]
}
}
}
# This will generate warnings when using Clang if code generates exit-time
# destructors, which will slow down closing the program.