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 declare_args() { | 5 declare_args() { |
6 # The optimization level to use for debug builds. | 6 # The optimization level to use for debug builds. |
7 if (is_android) { | 7 if (is_android) { |
8 # On Android we kind of optimize some things that don't affect debugging | 8 # On Android we kind of optimize some things that don't affect debugging |
9 # much even when optimization is disabled to get the binary size down. | 9 # much even when optimization is disabled to get the binary size down. |
10 debug_optimization_level = "s" | 10 debug_optimization_level = "s" |
11 } else { | 11 } else { |
12 debug_optimization_level = "2" | 12 debug_optimization_level = "2" |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 import("//build/config/android/config.gni") | 16 import("//build/config/android/config.gni") |
17 if (current_cpu == "arm") { | 17 if (current_cpu == "arm") { |
18 import("//build/config/arm.gni") | 18 import("//build/config/arm.gni") |
19 } | 19 } |
20 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | |
21 import("//build/config/mips.gni") | |
22 } | |
23 if (is_posix) { | |
24 import("//build/config/gcc/gcc_version.gni") | |
25 } | |
26 if (is_win) { | 20 if (is_win) { |
27 import("//build/config/win/visual_studio_version.gni") | 21 import("//build/config/win/visual_studio_version.gni") |
28 } | 22 } |
29 | 23 |
30 import("//build/toolchain/ccache.gni") | 24 import("//build/toolchain/ccache.gni") |
31 | 25 |
32 # default_include_dirs --------------------------------------------------------- | 26 # default_include_dirs --------------------------------------------------------- |
33 # | 27 # |
34 # This is a separate config so that third_party code (which would not use the | 28 # This is a separate config so that third_party code (which would not use the |
35 # source root and might have conflicting versions of some headers) can remove | 29 # source root and might have conflicting versions of some headers) can remove |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 # invalid code generation when using the Android NDK's | 212 # invalid code generation when using the Android NDK's |
219 # compiler (r5-r7). This can be verified using | 213 # compiler (r5-r7). This can be verified using |
220 # webkit_unit_tests' WTF.Checked_int8_t test. | 214 # webkit_unit_tests' WTF.Checked_int8_t test. |
221 "-fno-tree-sra", | 215 "-fno-tree-sra", |
222 | 216 |
223 # The following option is disabled to improve binary | 217 # The following option is disabled to improve binary |
224 # size and performance in gcc 4.9. | 218 # size and performance in gcc 4.9. |
225 "-fno-caller-saves", | 219 "-fno-caller-saves", |
226 ] | 220 ] |
227 } | 221 } |
228 } else if (current_cpu == "mipsel") { | |
229 # Some toolchains default to big-endian. | |
230 cflags += [ "-EL" ] | |
231 ldflags += [ "-EL" ] | |
232 | |
233 # We have to explicitly request exceptions to get good heap profiles from | |
234 # tcmalloc. | |
235 if (is_debug || is_release) { | |
236 cflags += [ | |
237 "-fexceptions", | |
238 "-funwind-tables", | |
239 ] | |
240 } | |
241 | |
242 if (mips_arch_variant == "r6") { | |
243 cflags += [ | |
244 "-mips32r6", | |
245 "-Wa,-mips32r6", | |
246 ] | |
247 if (is_android) { | |
248 ldflags += [ | |
249 "-mips32r6", | |
250 "-Wl,-melf32ltsmip", | |
251 ] | |
252 } | |
253 } else if (mips_arch_variant == "r2") { | |
254 cflags += [ | |
255 "-mips32r2", | |
256 "-Wa,-mips32r2", | |
257 ] | |
258 if (mips_float_abi == "hard" && mips_fpu_mode != "") { | |
259 cflags += [ "-m$mips_fpu_mode" ] | |
260 } | |
261 } else if (mips_arch_variant == "r1") { | |
262 cflags += [ | |
263 "-mips32", | |
264 "-Wa,-mips32", | |
265 ] | |
266 } | |
267 | |
268 if (mips_dsp_rev == 1) { | |
269 cflags += [ "-mdsp" ] | |
270 } else if (mips_dsp_rev == 2) { | |
271 cflags += [ "-mdspr2" ] | |
272 } | |
273 | |
274 cflags += [ "-m${mips_float_abi}-float" ] | |
275 } else if (current_cpu == "mips64el") { | |
276 if (mips_arch_variant == "r6") { | |
277 cflags += [ | |
278 "-mips64r6", | |
279 "-Wa,-mips64r6", | |
280 ] | |
281 ldflags += [ "-mips64r6" ] | |
282 } else if (mips_arch_variant == "r2") { | |
283 cflags += [ | |
284 "-mips64r2", | |
285 "-Wa,-mips64r2", | |
286 ] | |
287 ldflags += [ "-mips64r2" ] | |
288 } | |
289 } | 222 } |
290 | 223 |
291 if (current_cpu != "mipsel") { | 224 cflags += [ "-fno-exceptions" ] |
292 cflags += [ "-fno-exceptions" ] | |
293 } | |
294 } | 225 } |
295 | 226 |
296 # Linux/Android common flags setup. | 227 # Linux/Android common flags setup. |
297 # --------------------------------- | 228 # --------------------------------- |
298 if (is_linux || is_android) { | 229 if (is_linux || is_android) { |
299 ldflags += [ | 230 ldflags += [ |
300 "-Wl,-z,noexecstack", | 231 "-Wl,-z,noexecstack", |
301 "-Wl,-z,now", | 232 "-Wl,-z,now", |
302 "-Wl,-z,relro", | 233 "-Wl,-z,relro", |
303 ] | 234 ] |
304 } | 235 } |
305 | 236 |
306 # We need -fPIC: | 237 # We need -fPIC: |
307 # 1. On ARM and MIPS for tcmalloc. | 238 # 1. On ARM for tcmalloc. |
308 # 2. On Android. | 239 # 2. On Android. |
309 # 3. When using the sanitizers. | 240 # 3. When using the sanitizers. |
310 # Otherwise there is a performance hit, in particular on ia32. | 241 # Otherwise there is a performance hit, in particular on ia32. |
311 if (is_android || is_asan || is_lsan || is_msan || is_tsan || | 242 if (is_android || is_asan || is_lsan || is_msan || is_tsan || |
312 (is_linux && (current_cpu == "arm" || current_cpu == "mipsel"))) { | 243 (is_linux && current_cpu == "arm")) { |
313 cflags += [ "-fPIC" ] | 244 cflags += [ "-fPIC" ] |
314 ldflags += [ "-fPIC" ] | 245 ldflags += [ "-fPIC" ] |
315 } | 246 } |
316 | 247 |
317 # Linux-specific compiler flags setup. | 248 # Linux-specific compiler flags setup. |
318 # ------------------------------------ | 249 # ------------------------------------ |
319 if (is_linux) { | 250 if (is_linux) { |
320 cflags += [ "-pthread" ] | 251 cflags += [ "-pthread" ] |
321 ldflags += [ "-pthread" ] | 252 ldflags += [ "-pthread" ] |
322 } | 253 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 "_CRT_SECURE_NO_DEPRECATE", | 371 "_CRT_SECURE_NO_DEPRECATE", |
441 "_HAS_EXCEPTIONS=0", | 372 "_HAS_EXCEPTIONS=0", |
442 "_SCL_SECURE_NO_DEPRECATE", | 373 "_SCL_SECURE_NO_DEPRECATE", |
443 ] | 374 ] |
444 } | 375 } |
445 | 376 |
446 # Android standard library setup. | 377 # Android standard library setup. |
447 if (is_android) { | 378 if (is_android) { |
448 if (is_clang) { | 379 if (is_clang) { |
449 # Work around incompatibilities between bionic and clang headers. | 380 # Work around incompatibilities between bionic and clang headers. |
450 defines += [ | 381 defines += [ "__compiler_offsetof=__builtin_offsetof" ] |
451 "__compiler_offsetof=__builtin_offsetof", | |
452 ] | |
453 } | 382 } |
454 | 383 |
455 defines += [ "__GNU_SOURCE=1" ] # Necessary for clone(). | 384 defines += [ "__GNU_SOURCE=1" ] # Necessary for clone(). |
456 | 385 |
457 # TODO(jdduke) Re-enable on mips after resolving linking | 386 ldflags += [ |
458 # issues with libc++ (crbug.com/456380). | 387 "-Wl,--warn-shared-textrel", |
459 if (current_cpu != "mipsel" && current_cpu != "mips64el") { | 388 "-nostdlib", |
460 ldflags += [ "-Wl,--warn-shared-textrel" ] | 389 ] |
461 } | |
462 ldflags += [ "-nostdlib" ] | |
463 | 390 |
464 # NOTE: The libc++ header include paths below are specified in cflags | 391 # NOTE: The libc++ header include paths below are specified in cflags |
465 # rather than include_dirs because they need to come after include_dirs. | 392 # rather than include_dirs because they need to come after include_dirs. |
466 # Think of them like system headers, but don't use '-isystem' because the | 393 # Think of them like system headers, but don't use '-isystem' because the |
467 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit | 394 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit |
468 # strange errors. The include ordering here is important; change with | 395 # strange errors. The include ordering here is important; change with |
469 # caution. | 396 # caution. |
470 cflags += [ | 397 cflags += [ |
471 "-isystem" + | 398 "-isystem" + |
472 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), | 399 rebase_path("$android_libcpp_root/libcxx/include", root_build_dir), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 if (is_android) { | 492 if (is_android) { |
566 # Disable any additional warnings enabled by the Android build system but | 493 # Disable any additional warnings enabled by the Android build system but |
567 # which chromium does not build cleanly with (when treating warning as | 494 # which chromium does not build cleanly with (when treating warning as |
568 # errors). | 495 # errors). |
569 default_warning_flags += [ | 496 default_warning_flags += [ |
570 "-Wno-extra", | 497 "-Wno-extra", |
571 "-Wno-ignored-qualifiers", | 498 "-Wno-ignored-qualifiers", |
572 "-Wno-type-limits", | 499 "-Wno-type-limits", |
573 ] | 500 ] |
574 default_warning_flags_cc += [ | 501 default_warning_flags_cc += [ |
575 # Disabling c++0x-compat should be handled in WebKit, but | |
576 # this currently doesn't work because gcc_version is not set | |
577 # correctly when building with the Android build system. | |
578 # TODO(torne): Fix this in WebKit. | |
579 "-Wno-error=c++0x-compat", | |
580 | |
581 # Other things unrelated to -Wextra: | 502 # Other things unrelated to -Wextra: |
582 "-Wno-non-virtual-dtor", | 503 "-Wno-non-virtual-dtor", |
583 "-Wno-sign-promo", | 504 "-Wno-sign-promo", |
584 ] | 505 ] |
585 } | 506 } |
586 | |
587 if (gcc_version >= 48) { | |
588 # Don't warn about the "typedef 'foo' locally defined but not used" | |
589 # for gcc 4.8. | |
590 # TODO: remove this flag once all builds work. See crbug.com/227506 | |
591 default_warning_flags += [ "-Wno-unused-local-typedefs" ] | |
592 } | |
593 } | 507 } |
594 | 508 |
595 # chromium_code --------------------------------------------------------------- | 509 # chromium_code --------------------------------------------------------------- |
596 # | 510 # |
597 # Toggles between higher and lower warnings for code that is (or isn't) | 511 # Toggles between higher and lower warnings for code that is (or isn't) |
598 # part of Chromium. | 512 # part of Chromium. |
599 | 513 |
600 config("chromium_code") { | 514 config("chromium_code") { |
601 if (is_win) { | 515 if (is_win) { |
602 # TODO(zra): Enable higher warning levels. | 516 # TODO(zra): Enable higher warning levels. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | 696 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. |
783 } | 697 } |
784 ldflags = [ "/DEBUG" ] | 698 ldflags = [ "/DEBUG" ] |
785 } else { | 699 } else { |
786 cflags = [ | 700 cflags = [ |
787 "-g3", | 701 "-g3", |
788 "-ggdb3", | 702 "-ggdb3", |
789 ] | 703 ] |
790 } | 704 } |
791 } | 705 } |
OLD | NEW |