summaryrefslogtreecommitdiff
blob: be0649b825e0d2125276fcb2457e1c34130fc1c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Index: build/config/compiler/BUILD.gn
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 4d3c6ba0c09093bd5137cd32c4d37cdee1db6d40..71d9dc345f89f0f86e0e4e079f3124b682f558c1 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -22,6 +22,11 @@ if (is_win) {
 }
 
 declare_args() {
+  # Default to warnings as errors for default workflow, where we catch
+  # warnings with known toolchains. Allow overriding this e.g. for Chromium
+  # builds on Linux that could use a different version of the compiler.
+  treat_warnings_as_errors = true
+
   # Normally, Android builds are lightly optimized, even for debug builds, to
   # keep binary size down. Setting this flag to true disables such optimization
   android_full_debug = false
@@ -601,10 +606,11 @@ config("default_warnings") {
   cflags_cc = []
 
   if (is_win) {
-    cflags += [
-      # Treat warnings as errors.
-      "/WX",
+    if (treat_warnings_as_errors) {
+      cflags += [ "/WX" ]
+    }
 
+    cflags += [
       # Warnings permanently disabled:
 
       # C4127: conditional expression is constant
@@ -704,13 +710,16 @@ config("default_warnings") {
     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.
     ]
 
+    if (treat_warnings_as_errors) {
+      cflags += [ "-Werror" ]
+    }
+
     if (is_mac) {
       cflags += [ "-Wnewline-eof" ]
       if (!is_nacl) {