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 if (cpu_arch == "arm") { | 6 if (cpu_arch == "arm") { |
7 import("//build/config/arm.gni") | 7 import("//build/config/arm.gni") |
8 } | 8 } |
9 if (is_posix) { | 9 if (is_posix) { |
10 import("//build/config/gcc/gcc_version.gni") | 10 import("//build/config/gcc/gcc_version.gni") |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 # below. | 70 # below. |
71 if (is_win) { | 71 if (is_win) { |
72 # Windows compiler flags setup. | 72 # Windows compiler flags setup. |
73 # ----------------------------- | 73 # ----------------------------- |
74 cflags += [ | 74 cflags += [ |
75 "/Gy", # Enable function-level linking. | 75 "/Gy", # Enable function-level linking. |
76 "/GS", # Enable buffer security checking. | 76 "/GS", # Enable buffer security checking. |
77 "/FS", # Preserve previous PDB behavior. | 77 "/FS", # Preserve previous PDB behavior. |
78 ] | 78 ] |
79 if (is_component_build) { | 79 if (is_component_build) { |
80 cflags += [ | 80 cflags += [ "/EHsc" ] # Assume C functions can't throw exceptions and don
't catch |
81 "/EHsc", # Assume C functions can't throw exceptions and don't catch | 81 # structured exceptions (only C++ ones). |
82 # structured exceptions (only C++ ones). | |
83 ] | |
84 } | 82 } |
85 } else { | 83 } else { |
86 # Common GCC compiler flags setup. | 84 # Common GCC compiler flags setup. |
87 # -------------------------------- | 85 # -------------------------------- |
88 cflags += [ | 86 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 |
89 "-fno-strict-aliasing", # See http://crbug.com/32204 | |
90 ] | |
91 cflags_cc += [ | 87 cflags_cc += [ |
92 "-fno-threadsafe-statics", | 88 "-fno-threadsafe-statics", |
| 89 |
93 # Not exporting C++ inline functions can generally be applied anywhere | 90 # Not exporting C++ inline functions can generally be applied anywhere |
94 # so we do so here. Normal function visibility is controlled by | 91 # so we do so here. Normal function visibility is controlled by |
95 # //build/config/gcc:symbol_visibility_hidden. | 92 # //build/config/gcc:symbol_visibility_hidden. |
96 "-fvisibility-inlines-hidden", | 93 "-fvisibility-inlines-hidden", |
97 ] | 94 ] |
98 | 95 |
99 # Stack protection. | 96 # Stack protection. |
100 if (is_mac) { | 97 if (is_mac) { |
101 cflags += [ "-fstack-protector-all" ] | 98 cflags += [ "-fstack-protector-all" ] |
102 } else if (is_linux) { | 99 } else if (is_linux) { |
103 cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ] | 100 cflags += [ |
| 101 "-fstack-protector", |
| 102 "--param=ssp-buffer-size=4", |
| 103 ] |
104 } | 104 } |
105 | 105 |
106 # Linker warnings. | 106 # Linker warnings. |
107 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) { | 107 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) { |
108 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 | 108 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 |
109 ldflags += [ "-Wl,--fatal-warnings" ] | 109 ldflags += [ "-Wl,--fatal-warnings" ] |
110 } | 110 } |
111 | 111 |
112 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and | 112 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and |
113 # MemorySanitizer | 113 # MemorySanitizer |
(...skipping 21 matching lines...) Expand all Loading... |
135 "-Wno-undefined-bool-conversion", | 135 "-Wno-undefined-bool-conversion", |
136 "-Wno-tautological-undefined-compare", | 136 "-Wno-tautological-undefined-compare", |
137 ] | 137 ] |
138 } | 138 } |
139 | 139 |
140 if (is_clang && !is_win) { | 140 if (is_clang && !is_win) { |
141 # This is here so that all files get recompiled after a clang roll and | 141 # This is here so that all files get recompiled after a clang roll and |
142 # when turning clang on or off. (defines are passed via the command line, | 142 # when turning clang on or off. (defines are passed via the command line, |
143 # and build system rebuild things when their commandline changes). Nothing | 143 # and build system rebuild things when their commandline changes). Nothing |
144 # should ever read this define. | 144 # should ever read this define. |
145 defines += [ | 145 defines += [ "CR_CLANG_REVISION=" + |
146 "CR_CLANG_REVISION=" + | 146 exec_script("//tools/clang/scripts/posix-print-revision.py", |
147 exec_script( | 147 [], |
148 "//tools/clang/scripts/posix-print-revision.py", [], "value") | 148 "value") ] |
149 ] | |
150 } | 149 } |
151 | 150 |
152 # Mac-specific compiler flags setup. | 151 # Mac-specific compiler flags setup. |
153 # ---------------------------------- | 152 # ---------------------------------- |
154 if (is_mac || is_ios) { | 153 if (is_mac || is_ios) { |
155 # These flags are shared between the C compiler and linker. | 154 # These flags are shared between the C compiler and linker. |
156 common_mac_flags = [] | 155 common_mac_flags = [] |
157 | 156 |
158 # CPU architecture. | 157 # CPU architecture. |
159 if (cpu_arch == "x64") { | 158 if (cpu_arch == "x64") { |
160 common_mac_flags += [ "-arch", "x86_64" ] | 159 common_mac_flags += [ |
| 160 "-arch", |
| 161 "x86_64", |
| 162 ] |
161 } else if (cpu_arch == "x86") { | 163 } else if (cpu_arch == "x86") { |
162 common_mac_flags += [ "-arch", "i386" ] | 164 common_mac_flags += [ |
| 165 "-arch", |
| 166 "i386", |
| 167 ] |
163 } | 168 } |
164 | 169 |
165 cflags += common_mac_flags | 170 cflags += common_mac_flags |
166 | 171 |
167 # Without this, the constructors and destructors of a C++ object inside | 172 # Without this, the constructors and destructors of a C++ object inside |
168 # an Objective C struct won't be called, which is very bad. | 173 # an Objective C struct won't be called, which is very bad. |
169 cflags_objcc = [ "-fobjc-call-cxx-cdtors", ] | 174 cflags_objcc = [ "-fobjc-call-cxx-cdtors" ] |
170 | 175 |
171 cflags_c += [ "-std=c99" ] | 176 cflags_c += [ "-std=c99" ] |
172 cflags_cc += [ "-std=gnu++11" ] | 177 cflags_cc += [ "-std=gnu++11" ] |
173 | 178 |
174 ldflags += common_mac_flags | 179 ldflags += common_mac_flags |
175 } else if (is_posix) { | 180 } else if (is_posix) { |
176 # Non-Mac Posix compiler flags setup. | 181 # Non-Mac Posix compiler flags setup. |
177 # ----------------------------------- | 182 # ----------------------------------- |
178 if (gcc_version >= 48) { | 183 if (gcc_version >= 48) { |
179 cflags_cc += [ | 184 cflags_cc += [ "-std=gnu++11" ] |
180 "-std=gnu++11", | |
181 ] | |
182 } | 185 } |
183 | 186 |
184 # CPU architecture. We may or may not be doing a cross compile now, so for | 187 # CPU architecture. We may or may not be doing a cross compile now, so for |
185 # simplicity we always explicitly set the architecture. | 188 # simplicity we always explicitly set the architecture. |
186 if (cpu_arch == "x64") { | 189 if (cpu_arch == "x64") { |
187 cflags += [ "-m64", "-march=x86-64", ] | 190 cflags += [ |
| 191 "-m64", |
| 192 "-march=x86-64", |
| 193 ] |
188 ldflags += [ "-m64" ] | 194 ldflags += [ "-m64" ] |
189 } else if (cpu_arch == "x86") { | 195 } else if (cpu_arch == "x86") { |
190 cflags += [ "-m32" ] | 196 cflags += [ "-m32" ] |
191 ldflags += [ "-m32" ] | 197 ldflags += [ "-m32" ] |
192 if (is_clang) { | 198 if (is_clang) { |
193 cflags += [ | 199 cflags += [ |
194 # Else building libyuv gives clang's register allocator issues, | 200 # Else building libyuv gives clang's register allocator issues, |
195 # see llvm.org/PR15798 / crbug.com/233709 | 201 # see llvm.org/PR15798 / crbug.com/233709 |
196 "-momit-leaf-frame-pointer", | 202 "-momit-leaf-frame-pointer", |
| 203 |
197 # Align the stack on 16-byte boundaries, http://crbug.com/418554. | 204 # Align the stack on 16-byte boundaries, http://crbug.com/418554. |
198 "-mstack-alignment=16", | 205 "-mstack-alignment=16", |
199 "-mstackrealign", | 206 "-mstackrealign", |
200 ] | 207 ] |
201 } | 208 } |
202 } else if (cpu_arch == "arm") { | 209 } else if (cpu_arch == "arm") { |
203 # Don't set the compiler flags for the WebView build. These will come | 210 # Don't set the compiler flags for the WebView build. These will come |
204 # from the Android build system. | 211 # from the Android build system. |
205 if (!is_android_webview_build) { | 212 if (!is_android_webview_build) { |
206 cflags += [ | 213 cflags += [ |
(...skipping 11 matching lines...) Expand all Loading... |
218 } | 225 } |
219 if (!is_clang) { | 226 if (!is_clang) { |
220 # Clang doesn't support these flags. | 227 # Clang doesn't support these flags. |
221 cflags += [ | 228 cflags += [ |
222 # The tree-sra optimization (scalar replacement for | 229 # The tree-sra optimization (scalar replacement for |
223 # aggregates enabling subsequent optimizations) leads to | 230 # aggregates enabling subsequent optimizations) leads to |
224 # invalid code generation when using the Android NDK's | 231 # invalid code generation when using the Android NDK's |
225 # compiler (r5-r7). This can be verified using | 232 # compiler (r5-r7). This can be verified using |
226 # webkit_unit_tests' WTF.Checked_int8_t test. | 233 # webkit_unit_tests' WTF.Checked_int8_t test. |
227 "-fno-tree-sra", | 234 "-fno-tree-sra", |
| 235 |
228 # The following option is disabled to improve binary | 236 # The following option is disabled to improve binary |
229 # size and performance in gcc 4.9. | 237 # size and performance in gcc 4.9. |
230 "-fno-caller-saves", | 238 "-fno-caller-saves", |
231 ] | 239 ] |
232 } | 240 } |
233 } | 241 } |
234 } | 242 } |
235 | 243 |
236 defines += [ "_FILE_OFFSET_BITS=64" ] | 244 defines += [ "_FILE_OFFSET_BITS=64" ] |
237 | 245 |
(...skipping 22 matching lines...) Expand all Loading... |
260 "-Wl,-z,noexecstack", | 268 "-Wl,-z,noexecstack", |
261 "-Wl,-z,now", | 269 "-Wl,-z,now", |
262 "-Wl,-z,relro", | 270 "-Wl,-z,relro", |
263 ] | 271 ] |
264 } | 272 } |
265 | 273 |
266 # Linux-specific compiler flags setup. | 274 # Linux-specific compiler flags setup. |
267 # ------------------------------------ | 275 # ------------------------------------ |
268 if (is_linux) { | 276 if (is_linux) { |
269 cflags += [ "-pthread" ] | 277 cflags += [ "-pthread" ] |
270 ldflags += [ | 278 ldflags += [ "-pthread" ] |
271 "-pthread", | |
272 ] | |
273 } | 279 } |
274 if (use_gold) { | 280 if (use_gold) { |
275 # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of | 281 # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of |
276 # address space, and it doesn't support cross-compiling). | 282 # address space, and it doesn't support cross-compiling). |
277 gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 283 gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
278 root_build_dir) | 284 root_build_dir) |
279 ldflags += [ | 285 ldflags += [ |
280 "-B$gold_path", | 286 "-B$gold_path", |
281 | 287 |
282 # Newer gccs and clangs support -fuse-ld, use the flag to force gold | 288 # Newer gccs and clangs support -fuse-ld, use the flag to force gold |
(...skipping 18 matching lines...) Expand all Loading... |
301 | 307 |
302 if (linux_use_bundled_binutils) { | 308 if (linux_use_bundled_binutils) { |
303 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 309 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
304 root_build_dir) | 310 root_build_dir) |
305 cflags += [ "-B$binutils_path" ] | 311 cflags += [ "-B$binutils_path" ] |
306 } | 312 } |
307 | 313 |
308 # Clang-specific compiler flags setup. | 314 # Clang-specific compiler flags setup. |
309 # ------------------------------------ | 315 # ------------------------------------ |
310 if (is_clang) { | 316 if (is_clang) { |
311 cflags += [ | 317 cflags += [ "-fcolor-diagnostics" ] |
312 "-fcolor-diagnostics", | 318 cflags_cc += [ "-std=gnu++11" ] |
313 ] | |
314 cflags_cc += [ | |
315 "-std=gnu++11", | |
316 ] | |
317 } | 319 } |
318 | 320 |
319 # Android-specific flags setup. | 321 # Android-specific flags setup. |
320 # ----------------------------- | 322 # ----------------------------- |
321 if (is_android) { | 323 if (is_android) { |
322 cflags += [ | 324 cflags += [ |
323 "-ffunction-sections", | 325 "-ffunction-sections", |
324 "-funwind-tables", | 326 "-funwind-tables", |
325 "-fno-short-enums", | 327 "-fno-short-enums", |
326 ] | 328 ] |
327 if (!is_clang) { | 329 if (!is_clang) { |
328 # Clang doesn't support these flags. | 330 # Clang doesn't support these flags. |
329 cflags += [ | 331 cflags += [ "-finline-limit=64" ] |
330 "-finline-limit=64", | |
331 ] | |
332 } | 332 } |
333 if (is_android_webview_build) { | 333 if (is_android_webview_build) { |
334 # Android predefines this as 1; undefine it here so Chromium can redefine | 334 # Android predefines this as 1; undefine it here so Chromium can redefine |
335 # it later to be 2 for chromium code and unset for third party code. This | 335 # it later to be 2 for chromium code and unset for third party code. This |
336 # works because cflags are added before defines. | 336 # works because cflags are added before defines. |
337 # TODO(brettw) the above comment seems incorrect. We specify defines | 337 # TODO(brettw) the above comment seems incorrect. We specify defines |
338 # before cflags on our compiler command lines. | 338 # before cflags on our compiler command lines. |
339 cflags += [ "-U_FORTIFY_SOURCE" ] | 339 cflags += [ "-U_FORTIFY_SOURCE" ] |
340 } | 340 } |
341 | 341 |
(...skipping 10 matching lines...) Expand all Loading... |
352 # The NDK has these things, but doesn't define the constants | 352 # The NDK has these things, but doesn't define the constants |
353 # to say that it does. Define them here instead. | 353 # to say that it does. Define them here instead. |
354 defines += [ "HAVE_SYS_UIO_H" ] | 354 defines += [ "HAVE_SYS_UIO_H" ] |
355 } | 355 } |
356 | 356 |
357 # Use gold for Android for most CPU architectures. | 357 # Use gold for Android for most CPU architectures. |
358 if (cpu_arch == "x86" || cpu_arch == "x64" || cpu_arch == "arm") { | 358 if (cpu_arch == "x86" || cpu_arch == "x64" || cpu_arch == "arm") { |
359 ldflags += [ "-fuse-ld=gold" ] | 359 ldflags += [ "-fuse-ld=gold" ] |
360 if (is_clang) { | 360 if (is_clang) { |
361 # Let clang find the ld.gold in the NDK. | 361 # Let clang find the ld.gold in the NDK. |
362 ldflags += [ "--gcc-toolchain=" + rebase_path(android_toolchain_root, | 362 ldflags += [ "--gcc-toolchain=" + |
363 root_build_dir) ] | 363 rebase_path(android_toolchain_root, root_build_dir) ] |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 ldflags += [ | 367 ldflags += [ |
368 "-Wl,--no-undefined", | 368 "-Wl,--no-undefined", |
| 369 |
369 # Don't export symbols from statically linked libraries. | 370 # Don't export symbols from statically linked libraries. |
370 "-Wl,--exclude-libs=ALL", | 371 "-Wl,--exclude-libs=ALL", |
371 ] | 372 ] |
372 if (cpu_arch == "arm") { | 373 if (cpu_arch == "arm") { |
373 ldflags += [ | 374 ldflags += [ |
374 # Enable identical code folding to reduce size. | 375 # Enable identical code folding to reduce size. |
375 "-Wl,--icf=safe", | 376 "-Wl,--icf=safe", |
376 ] | 377 ] |
377 } | 378 } |
378 | 379 |
379 if (is_clang) { | 380 if (is_clang) { |
380 if (cpu_arch == "arm") { | 381 if (cpu_arch == "arm") { |
381 cflags += [ | 382 cflags += [ "-target arm-linux-androideabi" ] |
382 "-target arm-linux-androideabi", | |
383 ] | |
384 ldflags += [ "-target arm-linux-androideabi" ] | 383 ldflags += [ "-target arm-linux-androideabi" ] |
385 } else if (cpu_arch == "x86") { | 384 } else if (cpu_arch == "x86") { |
386 cflags += [ "-target x86-linux-androideabi" ] | 385 cflags += [ "-target x86-linux-androideabi" ] |
387 ldflags += [ "-target x86-linux-androideabi" ] | 386 ldflags += [ "-target x86-linux-androideabi" ] |
388 } | 387 } |
389 } | 388 } |
390 } | 389 } |
391 } | 390 } |
392 | 391 |
393 config("compiler_arm_fpu") { | 392 config("compiler_arm_fpu") { |
394 if (cpu_arch == "arm" && !is_android_webview_build) { | 393 if (cpu_arch == "arm" && !is_android_webview_build) { |
395 cflags = [ | 394 cflags = [ "-mfpu=$arm_fpu" ] |
396 "-mfpu=$arm_fpu", | |
397 ] | |
398 } | 395 } |
399 } | 396 } |
400 | 397 |
401 # runtime_library ------------------------------------------------------------- | 398 # runtime_library ------------------------------------------------------------- |
402 # | 399 # |
403 # Sets the runtime library and associated options. | 400 # Sets the runtime library and associated options. |
404 # | 401 # |
405 # How do you determine what should go in here vs. "compiler" above? Consider if | 402 # How do you determine what should go in here vs. "compiler" above? Consider if |
406 # a target might choose to use a different runtime library (ignore for a moment | 403 # a target might choose to use a different runtime library (ignore for a moment |
407 # if this is possible or reasonable on your system). If such a target would want | 404 # if this is possible or reasonable on your system). If such a target would want |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 ] | 471 ] |
475 | 472 |
476 # NOTE: The stlport header include paths below are specified in cflags | 473 # NOTE: The stlport header include paths below are specified in cflags |
477 # rather than include_dirs because they need to come after include_dirs. | 474 # rather than include_dirs because they need to come after include_dirs. |
478 # Think of them like system headers, but don't use '-isystem' because the | 475 # Think of them like system headers, but don't use '-isystem' because the |
479 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit | 476 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit |
480 # strange errors. The include ordering here is important; change with | 477 # strange errors. The include ordering here is important; change with |
481 # caution. | 478 # caution. |
482 android_stlport_root = "$android_ndk_root/sources/cxx-stl/stlport" | 479 android_stlport_root = "$android_ndk_root/sources/cxx-stl/stlport" |
483 | 480 |
484 cflags += [ | 481 cflags += [ "-isystem" + |
485 "-isystem" + rebase_path("$android_stlport_root/stlport", | 482 rebase_path("$android_stlport_root/stlport", root_build_dir) ] |
486 root_build_dir) | |
487 ] | |
488 if (arm_use_thumb) { | 483 if (arm_use_thumb) { |
489 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi/thumb" ] | 484 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi/thumb" ] |
490 } else { | 485 } else { |
491 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ] | 486 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ] |
492 } | 487 } |
493 | 488 |
494 if (component_mode == "shared_library") { | 489 if (component_mode == "shared_library") { |
495 libs += [ "stlport_shared" ] | 490 libs += [ "stlport_shared" ] |
496 } else { | 491 } else { |
497 libs += [ "stlport_static" ] | 492 libs += [ "stlport_static" ] |
(...skipping 13 matching lines...) Expand all Loading... |
511 # absolute because the linker will look inside the sysroot if it's not. | 506 # absolute because the linker will look inside the sysroot if it's not. |
512 rebase_path(android_libgcc_file), | 507 rebase_path(android_libgcc_file), |
513 ] | 508 ] |
514 } | 509 } |
515 | 510 |
516 libs += [ | 511 libs += [ |
517 "c", | 512 "c", |
518 "dl", | 513 "dl", |
519 "m", | 514 "m", |
520 ] | 515 ] |
521 | |
522 } | 516 } |
523 } | 517 } |
524 | 518 |
525 # chromium_code --------------------------------------------------------------- | 519 # chromium_code --------------------------------------------------------------- |
526 # | 520 # |
527 # Toggles between higher and lower warnings for code that is (or isn't) | 521 # Toggles between higher and lower warnings for code that is (or isn't) |
528 # part of Chromium. | 522 # part of Chromium. |
529 | 523 |
530 config("chromium_code") { | 524 config("chromium_code") { |
531 if (is_win) { | 525 if (is_win) { |
532 cflags = [ | 526 cflags = [ "/W4" ] # Warning level 4. |
533 "/W4", # Warning level 4. | |
534 ] | |
535 } else { | 527 } else { |
536 cflags = [ | 528 cflags = [ |
537 "-Wall", | 529 "-Wall", |
538 | 530 |
539 # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, | 531 # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, |
540 # so we specify it explicitly. | 532 # so we specify it explicitly. |
541 # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it. | 533 # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it. |
542 # http://code.google.com/p/chromium/issues/detail?id=90453 | 534 # http://code.google.com/p/chromium/issues/detail?id=90453 |
543 "-Wsign-compare", | 535 "-Wsign-compare", |
544 ] | 536 ] |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 } | 614 } |
623 | 615 |
624 # Warnings --------------------------------------------------------------------- | 616 # Warnings --------------------------------------------------------------------- |
625 # | 617 # |
626 # This is where we disable various warnings that we've decided aren't | 618 # This is where we disable various warnings that we've decided aren't |
627 # worthwhile, and enable special warnings. | 619 # worthwhile, and enable special warnings. |
628 | 620 |
629 config("default_warnings") { | 621 config("default_warnings") { |
630 if (is_win) { | 622 if (is_win) { |
631 cflags = [ | 623 cflags = [ |
632 "/WX", # Treat warnings as errors. | 624 "/WX", # Treat warnings as errors. |
633 | |
634 # Warnings permanently disabled: | 625 # Warnings permanently disabled: |
635 | 626 |
636 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled | 627 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled |
637 # for a bunch of individual targets. Re-enable this globally when those | 628 # for a bunch of individual targets. Re-enable this globally when those |
638 # targets are fixed. | 629 # targets are fixed. |
639 "/wd4018", # Comparing signed and unsigned values. | 630 "/wd4018", # Comparing signed and unsigned values. |
640 | 631 |
641 # C4127: conditional expression is constant | 632 # C4127: conditional expression is constant |
642 # This warning can in theory catch dead code and other problems, but | 633 # This warning can in theory catch dead code and other problems, but |
643 # triggers in far too many desirable cases where the conditional | 634 # triggers in far too many desirable cases where the conditional |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 669 |
679 # C4611: interaction between 'function' and C++ object destruction is | 670 # C4611: interaction between 'function' and C++ object destruction is |
680 # non-portable | 671 # non-portable |
681 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN | 672 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN |
682 # suggests using exceptions instead of setjmp/longjmp for C++, but | 673 # suggests using exceptions instead of setjmp/longjmp for C++, but |
683 # Chromium code compiles without exception support. We therefore have to | 674 # Chromium code compiles without exception support. We therefore have to |
684 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we | 675 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we |
685 # have to turn off this warning (and be careful about how object | 676 # have to turn off this warning (and be careful about how object |
686 # destruction happens in such cases). | 677 # destruction happens in such cases). |
687 "/wd4611", | 678 "/wd4611", |
688 | |
689 | |
690 # Warnings to evaluate and possibly fix/reenable later: | 679 # Warnings to evaluate and possibly fix/reenable later: |
691 | 680 |
692 "/wd4100", # Unreferenced formal function parameter. | 681 "/wd4100", # Unreferenced formal function parameter. |
693 "/wd4121", # Alignment of a member was sensitive to packing. | 682 "/wd4121", # Alignment of a member was sensitive to packing. |
694 "/wd4244", # Conversion: possible loss of data. | 683 "/wd4244", # Conversion: possible loss of data. |
695 "/wd4481", # Nonstandard extension: override specifier. | 684 "/wd4481", # Nonstandard extension: override specifier. |
696 "/wd4505", # Unreferenced local function has been removed. | 685 "/wd4505", # Unreferenced local function has been removed. |
697 "/wd4510", # Default constructor could not be generated. | 686 "/wd4510", # Default constructor could not be generated. |
698 "/wd4512", # Assignment operator could not be generated. | 687 "/wd4512", # Assignment operator could not be generated. |
699 "/wd4610", # Class can never be instantiated, constructor required. | 688 "/wd4610", # Class can never be instantiated, constructor required. |
700 "/wd4996", # Deprecated function warning. | 689 "/wd4996", # Deprecated function warning. |
701 ] | 690 ] |
702 } else { | 691 } else { |
703 # Common GCC warning setup. | 692 # Common GCC warning setup. |
704 cflags = [ | 693 cflags = [ |
705 # Enables. | 694 # Enables. |
706 "-Wendif-labels", # Weird old-style text after an #endif. | 695 "-Wendif-labels", # Weird old-style text after an #endif. |
707 "-Werror", # Warnings as errors. | 696 "-Werror", # Warnings as errors. |
708 | 697 |
709 # Disables. | 698 # Disables. |
710 "-Wno-missing-field-initializers", # "struct foo f = {0};" | 699 "-Wno-missing-field-initializers", # "struct foo f = {0};" |
711 "-Wno-unused-parameter", # Unused function parameters. | 700 "-Wno-unused-parameter", # Unused function parameters. |
712 ] | 701 ] |
713 cflags_cc = [] | 702 cflags_cc = [] |
714 | 703 |
715 if (is_mac) { | 704 if (is_mac) { |
716 cflags += [ | 705 cflags += [ "-Wnewline-eof" ] |
717 "-Wnewline-eof", | |
718 ] | |
719 } | 706 } |
720 | 707 |
721 if (is_clang) { | 708 if (is_clang) { |
722 cflags += [ | 709 cflags += [ |
723 # This warns on using ints as initializers for floats in | 710 # This warns on using ints as initializers for floats in |
724 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), | 711 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), |
725 # which happens in several places in chrome code. Not sure if | 712 # which happens in several places in chrome code. Not sure if |
726 # this is worth fixing. | 713 # this is worth fixing. |
727 "-Wno-c++11-narrowing", | 714 "-Wno-c++11-narrowing", |
728 | 715 |
(...skipping 17 matching lines...) Expand all Loading... |
746 "-Wno-unneeded-internal-declaration", | 733 "-Wno-unneeded-internal-declaration", |
747 | 734 |
748 # TODO(thakis): Remove, http://crbug.com/263960 | 735 # TODO(thakis): Remove, http://crbug.com/263960 |
749 "-Wno-reserved-user-defined-literal", | 736 "-Wno-reserved-user-defined-literal", |
750 ] | 737 ] |
751 } | 738 } |
752 if (gcc_version >= 48) { | 739 if (gcc_version >= 48) { |
753 cflags_cc += [ | 740 cflags_cc += [ |
754 # See comment for -Wno-c++11-narrowing. | 741 # See comment for -Wno-c++11-narrowing. |
755 "-Wno-narrowing", | 742 "-Wno-narrowing", |
| 743 |
756 # TODO(thakis): Remove, http://crbug.com/263960 | 744 # TODO(thakis): Remove, http://crbug.com/263960 |
757 "-Wno-literal-suffix", | 745 "-Wno-literal-suffix", |
758 ] | 746 ] |
759 } | 747 } |
760 | 748 |
761 # Suppress warnings about ABI changes on ARM (Clang doesn't give this | 749 # Suppress warnings about ABI changes on ARM (Clang doesn't give this |
762 # warning). | 750 # warning). |
763 if (cpu_arch == "arm" && !is_clang) { | 751 if (cpu_arch == "arm" && !is_clang) { |
764 cflags += [ "-Wno-psabi" ] | 752 cflags += [ "-Wno-psabi" ] |
765 } | 753 } |
766 | 754 |
767 if (is_android) { | 755 if (is_android) { |
768 # Disable any additional warnings enabled by the Android build system but | 756 # Disable any additional warnings enabled by the Android build system but |
769 # which chromium does not build cleanly with (when treating warning as | 757 # which chromium does not build cleanly with (when treating warning as |
770 # errors). | 758 # errors). |
771 cflags += [ | 759 cflags += [ |
772 "-Wno-extra", | 760 "-Wno-extra", |
773 "-Wno-ignored-qualifiers", | 761 "-Wno-ignored-qualifiers", |
774 "-Wno-type-limits", | 762 "-Wno-type-limits", |
775 ] | 763 ] |
776 cflags_cc += [ | 764 cflags_cc += [ |
777 # Disabling c++0x-compat should be handled in WebKit, but | 765 # Disabling c++0x-compat should be handled in WebKit, but |
778 # this currently doesn't work because gcc_version is not set | 766 # this currently doesn't work because gcc_version is not set |
779 # correctly when building with the Android build system. | 767 # correctly when building with the Android build system. |
780 # TODO(torne): Fix this in WebKit. | 768 # TODO(torne): Fix this in WebKit. |
781 "-Wno-error=c++0x-compat", | 769 "-Wno-error=c++0x-compat", |
| 770 |
782 # Other things unrelated to -Wextra: | 771 # Other things unrelated to -Wextra: |
783 "-Wno-non-virtual-dtor", | 772 "-Wno-non-virtual-dtor", |
784 "-Wno-sign-promo", | 773 "-Wno-sign-promo", |
785 ] | 774 ] |
786 } | 775 } |
787 | 776 |
788 if (gcc_version >= 48) { | 777 if (gcc_version >= 48) { |
789 # Don't warn about the "typedef 'foo' locally defined but not used" | 778 # Don't warn about the "typedef 'foo' locally defined but not used" |
790 # for gcc 4.8. | 779 # for gcc 4.8. |
791 # TODO: remove this flag once all builds work. See crbug.com/227506 | 780 # TODO: remove this flag once all builds work. See crbug.com/227506 |
792 cflags += [ | 781 cflags += [ "-Wno-unused-local-typedefs" ] |
793 "-Wno-unused-local-typedefs", | |
794 ] | |
795 } | 782 } |
796 } | 783 } |
797 } | 784 } |
798 | 785 |
799 # This will generate warnings when using Clang if code generates exit-time | 786 # This will generate warnings when using Clang if code generates exit-time |
800 # destructors, which will slow down closing the program. | 787 # destructors, which will slow down closing the program. |
801 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 | 788 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 |
802 config("wexit_time_destructors") { | 789 config("wexit_time_destructors") { |
803 if (is_clang) { | 790 if (is_clang) { |
804 cflags = [ "-Wexit-time-destructors" ] | 791 cflags = [ "-Wexit-time-destructors" ] |
(...skipping 10 matching lines...) Expand all Loading... |
815 # | 802 # |
816 # configs -= default_optimization_config | 803 # configs -= default_optimization_config |
817 # configs += [ "//build/config/compiler/optimize_max" ] | 804 # configs += [ "//build/config/compiler/optimize_max" ] |
818 | 805 |
819 # Shared settings for both "optimize" and "optimize_max" configs. | 806 # Shared settings for both "optimize" and "optimize_max" configs. |
820 if (is_win) { | 807 if (is_win) { |
821 common_optimize_on_cflags = [ | 808 common_optimize_on_cflags = [ |
822 "/O2", | 809 "/O2", |
823 "/Ob2", # both explicit and auto inlining. | 810 "/Ob2", # both explicit and auto inlining. |
824 "/Oy-", # disable omitting frame pointers, must be after /o2. | 811 "/Oy-", # disable omitting frame pointers, must be after /o2. |
825 "/Os", # favor size over speed. | 812 "/Os", # favor size over speed. |
826 ] | 813 ] |
827 common_optimize_on_ldflags = [] | 814 common_optimize_on_ldflags = [] |
828 } else { | 815 } else { |
829 common_optimize_on_cflags = [ | 816 common_optimize_on_cflags = [ |
830 # Don't emit the GCC version ident directives, they just end up in the | 817 # Don't emit the GCC version ident directives, they just end up in the |
831 # .comment section taking up binary size. | 818 # .comment section taking up binary size. |
832 "-fno-ident", | 819 "-fno-ident", |
| 820 |
833 # Put data and code in their own sections, so that unused symbols | 821 # Put data and code in their own sections, so that unused symbols |
834 # can be removed at link time with --gc-sections. | 822 # can be removed at link time with --gc-sections. |
835 "-fdata-sections", | 823 "-fdata-sections", |
836 "-ffunction-sections", | 824 "-ffunction-sections", |
837 ] | 825 ] |
838 common_optimize_on_ldflags = [] | 826 common_optimize_on_ldflags = [] |
839 | 827 |
840 if (is_android) { | 828 if (is_android) { |
841 if (!using_sanitizer) { | 829 if (!using_sanitizer) { |
842 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] | 830 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] |
843 } | 831 } |
844 common_optimize_on_ldflags += [ | 832 common_optimize_on_ldflags += [ |
845 # Warn in case of text relocations. | 833 # Warn in case of text relocations. |
846 "-Wl,--warn-shared-textrel", | 834 "-Wl,--warn-shared-textrel", |
847 ] | 835 ] |
848 } | 836 } |
849 | 837 |
850 if (is_mac) { | 838 if (is_mac) { |
851 if (symbol_level == 2) { | 839 if (symbol_level == 2) { |
852 # Mac dead code stripping requires symbols. | 840 # Mac dead code stripping requires symbols. |
853 common_optimize_on_ldflags += [ | 841 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] |
854 "-Wl,-dead_strip", | |
855 ] | |
856 } | 842 } |
857 } else { | 843 } else { |
858 # Non-Mac Posix linker flags. | 844 # Non-Mac Posix linker flags. |
859 common_optimize_on_ldflags += [ | 845 common_optimize_on_ldflags += [ |
860 # Specifically tell the linker to perform optimizations. | 846 # Specifically tell the linker to perform optimizations. |
861 # See http://lwn.net/Articles/192624/ . | 847 # See http://lwn.net/Articles/192624/ . |
862 "-Wl,-O1", | 848 "-Wl,-O1", |
863 "-Wl,--as-needed", | 849 "-Wl,--as-needed", |
864 "-Wl,--gc-sections", | 850 "-Wl,--gc-sections", |
865 ] | 851 ] |
866 } | 852 } |
867 } | 853 } |
868 | 854 |
869 # Default "optimization on" config. On Windows, this favors size over speed. | 855 # Default "optimization on" config. On Windows, this favors size over speed. |
870 config("optimize") { | 856 config("optimize") { |
871 cflags = common_optimize_on_cflags | 857 cflags = common_optimize_on_cflags |
872 ldflags = common_optimize_on_ldflags | 858 ldflags = common_optimize_on_ldflags |
873 if (is_win) { | 859 if (is_win) { |
874 cflags += [ | 860 cflags += [ "/Os" ] # favor size over speed. |
875 "/Os", # favor size over speed. | |
876 ] | |
877 } else if (is_android || is_ios) { | 861 } else if (is_android || is_ios) { |
878 cflags += [ | 862 cflags += [ "-Os" ] # Favor size over speed. |
879 "-Os", # Favor size over speed. | |
880 ] | |
881 } else { | 863 } else { |
882 cflags += [ | 864 cflags += [ "-O2" ] |
883 "-O2", | |
884 ] | |
885 } | 865 } |
886 } | 866 } |
887 | 867 |
888 # Turn off optimizations. | 868 # Turn off optimizations. |
889 config("no_optimize") { | 869 config("no_optimize") { |
890 if (is_win) { | 870 if (is_win) { |
891 cflags = [ | 871 cflags = [ |
892 "/Od", # Disable optimization. | 872 "/Od", # Disable optimization. |
893 "/Ob0", # Disable all inlining (on by default). | 873 "/Ob0", # Disable all inlining (on by default). |
894 "/RTC1", # Runtime checks for stack frame and uninitialized variables. | 874 "/RTC1", # Runtime checks for stack frame and uninitialized variables. |
(...skipping 15 matching lines...) Expand all Loading... |
910 } | 890 } |
911 } | 891 } |
912 | 892 |
913 # Turns up the optimization level. On Windows, this implies whole program | 893 # Turns up the optimization level. On Windows, this implies whole program |
914 # optimization and link-time code generation which is very expensive and should | 894 # optimization and link-time code generation which is very expensive and should |
915 # be used sparingly. | 895 # be used sparingly. |
916 config("optimize_max") { | 896 config("optimize_max") { |
917 cflags = common_optimize_on_cflags | 897 cflags = common_optimize_on_cflags |
918 ldflags = common_optimize_on_ldflags | 898 ldflags = common_optimize_on_ldflags |
919 if (is_win) { | 899 if (is_win) { |
920 cflags -= [ | 900 cflags -= [ "/Os" ] |
921 "/Os", | 901 cflags += [ "/Ot" ] # Favor speed over size. |
922 ] | |
923 cflags += [ | |
924 "/Ot", # Favor speed over size. | |
925 ] | |
926 if (is_official_build) { | 902 if (is_official_build) { |
927 # TODO(GYP): TODO(dpranke): Should these only be on in an official | 903 # TODO(GYP): TODO(dpranke): Should these only be on in an official |
928 # build, or on all the time? For now we'll require official build so | 904 # build, or on all the time? For now we'll require official build so |
929 # that the compile is clean. | 905 # that the compile is clean. |
930 cflags += [ | 906 cflags += [ |
931 "/GL", # Whole program optimization. | 907 "/GL", # Whole program optimization. |
| 908 |
932 # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds. | 909 # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds. |
933 # Probably anything that this would catch that wouldn't be caught in a | 910 # Probably anything that this would catch that wouldn't be caught in a |
934 # normal build isn't going to actually be a bug, so the incremental | 911 # normal build isn't going to actually be a bug, so the incremental |
935 # value of C4702 for PGO builds is likely very small. | 912 # value of C4702 for PGO builds is likely very small. |
936 "/wd4702", | 913 "/wd4702", |
937 ] | 914 ] |
938 ldflags += [ | 915 ldflags += [ "/LTCG" ] |
939 "/LTCG", | |
940 ] | |
941 } | 916 } |
942 } else { | 917 } else { |
943 cflags += [ | 918 cflags += [ "-O2" ] |
944 "-O2", | |
945 ] | |
946 } | 919 } |
947 } | 920 } |
948 | 921 |
949 # Symbols ---------------------------------------------------------------------- | 922 # Symbols ---------------------------------------------------------------------- |
950 | 923 |
951 config("symbols") { | 924 config("symbols") { |
952 if (is_win) { | 925 if (is_win) { |
953 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | 926 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. |
954 ldflags = [ "/DEBUG" ] | 927 ldflags = [ "/DEBUG" ] |
955 } else { | 928 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
970 cflags += [ "-gsplit-dwarf" ] | 943 cflags += [ "-gsplit-dwarf" ] |
971 } | 944 } |
972 } | 945 } |
973 } | 946 } |
974 | 947 |
975 config("no_symbols") { | 948 config("no_symbols") { |
976 if (!is_win) { | 949 if (!is_win) { |
977 cflags = [ "-g0" ] | 950 cflags = [ "-g0" ] |
978 } | 951 } |
979 } | 952 } |
OLD | NEW |