Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: build/config/compiler/BUILD.gn

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 (current_cpu == "arm") { 6 if (current_cpu == "arm") {
7 import("//build/config/arm.gni") 7 import("//build/config/arm.gni")
8 } 8 }
9 if (current_cpu == "mipsel" || current_cpu == "mips64el") { 9 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
10 import("//build/config/mips.gni") 10 import("//build/config/mips.gni")
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 if (is_clang && !is_win && !is_nacl) { 160 if (is_clang && !is_win && !is_nacl) {
161 # This is here so that all files get recompiled after a clang roll and 161 # This is here so that all files get recompiled after a clang roll and
162 # when turning clang on or off. (defines are passed via the command line, 162 # when turning clang on or off. (defines are passed via the command line,
163 # and build system rebuild things when their commandline changes). Nothing 163 # and build system rebuild things when their commandline changes). Nothing
164 # should ever read this define. 164 # should ever read this define.
165 defines += [ "CR_CLANG_REVISION=" + 165 defines += [ "CR_CLANG_REVISION=" +
166 exec_script("//tools/clang/scripts/posix-print-revision.py", 166 exec_script("//tools/clang/scripts/posix-print-revision.py",
167 [], 167 [],
168 "value") ] 168 "trim string") ]
169 } 169 }
170 170
171 # Mac-specific compiler flags setup. 171 # Mac-specific compiler flags setup.
172 # ---------------------------------- 172 # ----------------------------------
173 if (is_mac || is_ios) { 173 if (is_mac || is_ios) {
174 # These flags are shared between the C compiler and linker. 174 # These flags are shared between the C compiler and linker.
175 common_mac_flags = [] 175 common_mac_flags = []
176 176
177 # CPU architecture. 177 # CPU architecture.
178 if (current_cpu == "x64") { 178 if (current_cpu == "x64") {
179 common_mac_flags += [ 179 common_mac_flags += [
180 "-arch", 180 "-arch",
181 "x86_64", 181 "x86_64",
182 ] 182 ]
183 } else if (current_cpu == "x86") { 183 } else if (current_cpu == "x86") {
184 common_mac_flags += [ 184 common_mac_flags += [
185 "-arch", 185 "-arch",
186 "i386", 186 "i386",
187 ] 187 ]
188 } 188 }
189 189
190 cflags += common_mac_flags 190 cflags += common_mac_flags
191 191
192 # Without this, the constructors and destructors of a C++ object inside 192 # Without this, the constructors and destructors of a C++ object inside
193 # an Objective C struct won't be called, which is very bad. 193 # an Objective C struct won't be called, which is very bad.
194 cflags_objcc = [ "-fobjc-call-cxx-cdtors" ] 194 cflags_objcc = [ "-fobjc-call-cxx-cdtors" ]
195 195
196 cflags_c += [ "-std=c99" ] 196 cflags_c += [ "-std=c99" ]
197 cflags_cc += [ "-std=gnu++11" ]
198 197
199 ldflags += common_mac_flags 198 ldflags += common_mac_flags
200 } else if (is_posix) { 199 } else if (is_posix) {
201 # Non-Mac Posix compiler flags setup. 200 # Non-Mac Posix compiler flags setup.
202 # ----------------------------------- 201 # -----------------------------------
203 if (gcc_version >= 48) {
204 cflags_cc += [ "-std=gnu++11" ]
205 }
206
207 if (enable_profiling && !is_debug) { 202 if (enable_profiling && !is_debug) {
208 # The GYP build spams this define into every compilation unit, as we do 203 # The GYP build spams this define into every compilation unit, as we do
209 # here, but it only appears to be used in base and a couple other places. 204 # here, but it only appears to be used in base and a couple other places.
210 # TODO(abarth): Should we move this define closer to where it's used? 205 # TODO(abarth): Should we move this define closer to where it's used?
211 defines += [ "ENABLE_PROFILING" ] 206 defines += [ "ENABLE_PROFILING" ]
212 207
213 cflags += [ 208 cflags += [
214 "-fno-omit-frame-pointer", 209 "-fno-omit-frame-pointer",
215 "-g", 210 "-g",
216 ] 211 ]
(...skipping 22 matching lines...) Expand all
239 # Else building libyuv gives clang's register allocator issues, 234 # Else building libyuv gives clang's register allocator issues,
240 # see llvm.org/PR15798 / crbug.com/233709 235 # see llvm.org/PR15798 / crbug.com/233709
241 "-momit-leaf-frame-pointer", 236 "-momit-leaf-frame-pointer",
242 237
243 # Align the stack on 16-byte boundaries, http://crbug.com/418554. 238 # Align the stack on 16-byte boundaries, http://crbug.com/418554.
244 "-mstack-alignment=16", 239 "-mstack-alignment=16",
245 "-mstackrealign", 240 "-mstackrealign",
246 ] 241 ]
247 } 242 }
248 } else if (current_cpu == "arm") { 243 } else if (current_cpu == "arm") {
249 # Don't set the compiler flags for the WebView build. These will come 244 cflags += [
250 # from the Android build system. 245 "-march=$arm_arch",
251 if (!is_android_webview_build) { 246 "-mfloat-abi=$arm_float_abi",
247 ]
248 if (arm_tune != "") {
249 cflags += [ "-mtune=$arm_tune" ]
250 }
251 if (arm_use_thumb) {
252 cflags += [ "-mthumb" ]
253 if (is_android && !is_clang) { # Clang doesn't support this option.
254 cflags += [ "-mthumb-interwork" ]
255 }
256 }
257 if (!is_clang) {
258 # Clang doesn't support these flags.
252 cflags += [ 259 cflags += [
253 "-march=$arm_arch", 260 # The tree-sra optimization (scalar replacement for
254 "-mfloat-abi=$arm_float_abi", 261 # aggregates enabling subsequent optimizations) leads to
262 # invalid code generation when using the Android NDK's
263 # compiler (r5-r7). This can be verified using
264 # webkit_unit_tests' WTF.Checked_int8_t test.
265 "-fno-tree-sra",
266
267 # The following option is disabled to improve binary
268 # size and performance in gcc 4.9.
269 "-fno-caller-saves",
255 ] 270 ]
256 if (arm_tune != "") { 271 }
257 cflags += [ "-mtune=$arm_tune" ] 272 } else if (current_cpu == "mipsel") {
258 } 273 if (mips_arch_variant == "r6") {
259 if (arm_use_thumb) { 274 cflags += [
260 cflags += [ "-mthumb" ] 275 "-mips32r6",
261 if (is_android && !is_clang) { # Clang doesn't support this option. 276 "-Wa,-mips32r6",
262 cflags += [ "-mthumb-interwork" ] 277 ]
263 } 278 if (is_android) {
264 } 279 ldflags += [
265 if (!is_clang) { 280 "-mips32r6",
266 # Clang doesn't support these flags. 281 "-Wl,-melf32ltsmip",
267 cflags += [
268 # The tree-sra optimization (scalar replacement for
269 # aggregates enabling subsequent optimizations) leads to
270 # invalid code generation when using the Android NDK's
271 # compiler (r5-r7). This can be verified using
272 # webkit_unit_tests' WTF.Checked_int8_t test.
273 "-fno-tree-sra",
274
275 # The following option is disabled to improve binary
276 # size and performance in gcc 4.9.
277 "-fno-caller-saves",
278 ] 282 ]
279 } 283 }
284 } else if (mips_arch_variant == "r2") {
285 cflags += [
286 "-mips32r2",
287 "-Wa,-mips32r2",
288 ]
289 if (mips_float_abi == "hard" && mips_fpu_mode != "") {
290 cflags += [ "-m$mips_fpu_mode" ]
291 }
292 } else if (mips_arch_variant == "r1") {
293 cflags += [
294 "-mips32",
295 "-Wa,-mips32",
296 ]
280 } 297 }
281 } else if (current_cpu == "mipsel") {
282 # Don't set the compiler flags for the WebView build. These will come
283 # from the Android build system.
284 if (!is_android_webview_build) {
285 if (mips_arch_variant == "r6") {
286 cflags += [
287 "-mips32r6",
288 "-Wa,-mips32r6",
289 ]
290 if (is_android) {
291 ldflags += [
292 "-mips32r6",
293 "-Wl,-melf32ltsmip",
294 ]
295 }
296 } else if (mips_arch_variant == "r2") {
297 cflags += [
298 "-mips32r2",
299 "-Wa,-mips32r2",
300 ]
301 if (mips_float_abi == "hard" && mips_fpu_mode != "") {
302 cflags += [ "-m$mips_fpu_mode" ]
303 }
304 } else if (mips_arch_variant == "r1") {
305 cflags += [
306 "-mips32",
307 "-Wa,-mips32",
308 ]
309 }
310 298
311 if (mips_dsp_rev == 1) { 299 if (mips_dsp_rev == 1) {
312 cflags += [ "-mdsp" ] 300 cflags += [ "-mdsp" ]
313 } else if (mips_dsp_rev == 2) { 301 } else if (mips_dsp_rev == 2) {
314 cflags += [ "-mdspr2" ] 302 cflags += [ "-mdspr2" ]
315 } 303 }
316 304
317 cflags += [ "-m${mips_float_abi}-float" ] 305 cflags += [ "-m${mips_float_abi}-float" ]
318 }
319 } else if (current_cpu == "mips64el") { 306 } else if (current_cpu == "mips64el") {
320 # Don't set the compiler flags for the WebView build. These will come 307 if (mips_arch_variant == "r6") {
321 # from the Android build system. 308 cflags += [
322 if (!is_android_webview_build) { 309 "-mips64r6",
323 if (mips_arch_variant == "r6") { 310 "-Wa,-mips64r6",
324 cflags += [ 311 ]
325 "-mips64r6", 312 ldflags += [ "-mips64r6" ]
326 "-Wa,-mips64r6", 313 } else if (mips_arch_variant == "r2") {
327 ] 314 cflags += [
328 ldflags += [ "-mips64r6" ] 315 "-mips64r2",
329 } else if (mips_arch_variant == "r2") { 316 "-Wa,-mips64r2",
330 cflags += [ 317 ]
331 "-mips64r2", 318 ldflags += [ "-mips64r2" ]
332 "-Wa,-mips64r2",
333 ]
334 ldflags += [ "-mips64r2" ]
335 }
336 } 319 }
337 } 320 }
338 321
339 defines += [ "_FILE_OFFSET_BITS=64" ] 322 defines += [ "_FILE_OFFSET_BITS=64" ]
340 323
324 if (!is_android) {
325 defines += [
326 "_LARGEFILE_SOURCE",
327 "_LARGEFILE64_SOURCE",
328 ]
329 }
330
341 # Omit unwind support in official builds to save space. We can use breakpad 331 # Omit unwind support in official builds to save space. We can use breakpad
342 # for these builds. 332 # for these builds.
343 if (is_chrome_branded && is_official_build) { 333 if (is_chrome_branded && is_official_build) {
344 cflags += [ 334 cflags += [
345 "-fno-unwind-tables", 335 "-fno-unwind-tables",
346 "-fno-asynchronous-unwind-tables", 336 "-fno-asynchronous-unwind-tables",
347 ] 337 ]
348 } else { 338 } else {
349 cflags += [ "-funwind-tables" ] 339 cflags += [ "-funwind-tables" ]
350 } 340 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (linux_use_bundled_binutils) { 401 if (linux_use_bundled_binutils) {
412 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", 402 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin",
413 root_build_dir) 403 root_build_dir)
414 cflags += [ "-B$binutils_path" ] 404 cflags += [ "-B$binutils_path" ]
415 } 405 }
416 406
417 # Clang-specific compiler flags setup. 407 # Clang-specific compiler flags setup.
418 # ------------------------------------ 408 # ------------------------------------
419 if (is_clang) { 409 if (is_clang) {
420 cflags += [ "-fcolor-diagnostics" ] 410 cflags += [ "-fcolor-diagnostics" ]
411 }
412
413 # C++11 compiler flags setup.
414 # ---------------------------
415 if (is_linux || is_android || is_nacl) {
416 # gnu++11 instead of c++11 is needed because some code uses typeof() (a
417 # GNU extension).
418 # TODO(thakis): Eventually switch this to c++11 instead,
419 # http://crbug.com/427584
421 cflags_cc += [ "-std=gnu++11" ] 420 cflags_cc += [ "-std=gnu++11" ]
421 } else if (!is_win) {
422 cflags_cc += [ "-std=c++11" ]
422 } 423 }
423 424
424 # Android-specific flags setup. 425 # Android-specific flags setup.
425 # ----------------------------- 426 # -----------------------------
426 if (is_android) { 427 if (is_android) {
427 cflags += [ 428 cflags += [
428 "-ffunction-sections", 429 "-ffunction-sections",
429 "-funwind-tables", 430 "-funwind-tables",
430 "-fno-short-enums", 431 "-fno-short-enums",
431 ] 432 ]
432 if (!is_clang) { 433 if (!is_clang) {
433 # Clang doesn't support these flags. 434 # Clang doesn't support these flags.
434 cflags += [ "-finline-limit=64" ] 435 cflags += [ "-finline-limit=64" ]
435 } 436 }
436 if (is_android_webview_build) {
437 # Android predefines this as 1; undefine it here so Chromium can redefine
438 # it later to be 2 for chromium code and unset for third party code. This
439 # works because cflags are added before defines.
440 # TODO(brettw) the above comment seems incorrect. We specify defines
441 # before cflags on our compiler command lines.
442 cflags += [ "-U_FORTIFY_SOURCE" ]
443 }
444
445 if (is_asan) { 437 if (is_asan) {
446 # Android build relies on -Wl,--gc-sections removing unreachable code. 438 # Android build relies on -Wl,--gc-sections removing unreachable code.
447 # ASan instrumentation for globals inhibits this and results in a library 439 # ASan instrumentation for globals inhibits this and results in a library
448 # with unresolvable relocations. 440 # with unresolvable relocations.
449 # TODO(eugenis): find a way to reenable this. 441 # TODO(eugenis): find a way to reenable this.
450 cflags += [ "-mllvm -asan-globals=0" ] 442 cflags += [ "-mllvm -asan-globals=0" ]
451 } 443 }
452 444
453 defines += [ "ANDROID" ] 445 defines += [ "ANDROID" ]
454 if (!is_android_webview_build) { 446
455 # The NDK has these things, but doesn't define the constants 447 # The NDK has these things, but doesn't define the constants
456 # to say that it does. Define them here instead. 448 # to say that it does. Define them here instead.
457 defines += [ "HAVE_SYS_UIO_H" ] 449 defines += [ "HAVE_SYS_UIO_H" ]
458 }
459 450
460 # Use gold for Android for most CPU architectures. 451 # Use gold for Android for most CPU architectures.
461 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { 452 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") {
462 ldflags += [ "-fuse-ld=gold" ] 453 ldflags += [ "-fuse-ld=gold" ]
463 if (is_clang) { 454 if (is_clang) {
464 # Let clang find the ld.gold in the NDK. 455 # Let clang find the ld.gold in the NDK.
465 ldflags += [ "--gcc-toolchain=" + 456 ldflags += [ "--gcc-toolchain=" +
466 rebase_path(android_toolchain_root, root_build_dir) ] 457 rebase_path(android_toolchain_root, root_build_dir) ]
467 } 458 }
468 } 459 }
(...skipping 24 matching lines...) Expand all
493 ldflags += [ "-target arm-linux-androideabi" ] 484 ldflags += [ "-target arm-linux-androideabi" ]
494 } else if (current_cpu == "x86") { 485 } else if (current_cpu == "x86") {
495 cflags += [ "-target x86-linux-androideabi" ] 486 cflags += [ "-target x86-linux-androideabi" ]
496 ldflags += [ "-target x86-linux-androideabi" ] 487 ldflags += [ "-target x86-linux-androideabi" ]
497 } 488 }
498 } 489 }
499 } 490 }
500 } 491 }
501 492
502 config("compiler_arm_fpu") { 493 config("compiler_arm_fpu") {
503 if (current_cpu == "arm" && !is_android_webview_build) { 494 if (current_cpu == "arm") {
504 cflags = [ "-mfpu=$arm_fpu" ] 495 cflags = [ "-mfpu=$arm_fpu" ]
505 } 496 }
506 } 497 }
507 498
508 # runtime_library ------------------------------------------------------------- 499 # runtime_library -------------------------------------------------------------
509 # 500 #
510 # Sets the runtime library and associated options. 501 # Sets the runtime library and associated options.
511 # 502 #
512 # How do you determine what should go in here vs. "compiler" above? Consider if 503 # How do you determine what should go in here vs. "compiler" above? Consider if
513 # a target might choose to use a different runtime library (ignore for a moment 504 # a target might choose to use a different runtime library (ignore for a moment
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 557 }
567 558
568 defines += [ 559 defines += [
569 "USE_STLPORT=1", 560 "USE_STLPORT=1",
570 "_STLP_USE_PTR_SPECIALIZATIONS=1", 561 "_STLP_USE_PTR_SPECIALIZATIONS=1",
571 "__GNU_SOURCE=1", # Necessary for clone(). 562 "__GNU_SOURCE=1", # Necessary for clone().
572 ] 563 ]
573 564
574 # TODO(jdduke) Re-enable on mips after resolving linking 565 # TODO(jdduke) Re-enable on mips after resolving linking
575 # issues with libc++ (crbug.com/456380). 566 # issues with libc++ (crbug.com/456380).
576 if (cpu_arch != "mipsel" && cpu_arch != "mips64el") { 567 if (current_cpu != "mipsel" && current_cpu != "mips64el") {
577 ldflags += [ "-Wl,--warn-shared-textrel" ] 568 ldflags += [ "-Wl,--warn-shared-textrel" ]
578 } 569 }
579 ldflags += [ "-nostdlib" ] 570 ldflags += [ "-nostdlib" ]
580 571
581 # NOTE: The stlport header include paths below are specified in cflags 572 # NOTE: The stlport header include paths below are specified in cflags
582 # rather than include_dirs because they need to come after include_dirs. 573 # rather than include_dirs because they need to come after include_dirs.
583 # Think of them like system headers, but don't use '-isystem' because the 574 # Think of them like system headers, but don't use '-isystem' because the
584 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit 575 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit
585 # strange errors. The include ordering here is important; change with 576 # strange errors. The include ordering here is important; change with
586 # caution. 577 # caution.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 cflags += [ 668 cflags += [
678 # Don't warn about printf format problems. This is off by default in gcc 669 # Don't warn about printf format problems. This is off by default in gcc
679 # but on in Ubuntu's gcc(!). 670 # but on in Ubuntu's gcc(!).
680 "-Wno-format", 671 "-Wno-format",
681 ] 672 ]
682 cflags_cc += [ 673 cflags_cc += [
683 # Don't warn about hash_map in third-party code. 674 # Don't warn about hash_map in third-party code.
684 "-Wno-deprecated", 675 "-Wno-deprecated",
685 ] 676 ]
686 } 677 }
687
688 if (is_android_webview_build) {
689 # There is a class of warning which:
690 # 1) Android always enables and also treats as errors
691 # 2) Chromium ignores in third party code
692 # So we re-enable those warnings when building Android.
693 cflags += [
694 "-Wno-address",
695 "-Wno-format-security",
696 "-Wno-return-type",
697 "-Wno-sequence-point",
698 ]
699 cflags_cc += [ "-Wno-non-virtual-dtor" ]
700 }
701 } 678 }
702 679
703 # rtti ------------------------------------------------------------------------ 680 # rtti ------------------------------------------------------------------------
704 # 681 #
705 # Allows turning Run-Time Type Identification on or off. 682 # Allows turning Run-Time Type Identification on or off.
706 683
707 config("rtti") { 684 config("rtti") {
708 if (is_win) { 685 if (is_win) {
709 cflags_cc = [ "/GR" ] 686 cflags_cc = [ "/GR" ]
710 } 687 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 ] 953 ]
977 common_optimize_on_ldflags = [] 954 common_optimize_on_ldflags = []
978 955
979 if (is_android) { 956 if (is_android) {
980 if (!using_sanitizer) { 957 if (!using_sanitizer) {
981 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] 958 common_optimize_on_cflags += [ "-fomit-frame-pointer" ]
982 } 959 }
983 960
984 # TODO(jdduke) Re-enable on mips after resolving linking 961 # TODO(jdduke) Re-enable on mips after resolving linking
985 # issues with libc++ (crbug.com/456380). 962 # issues with libc++ (crbug.com/456380).
986 if (cpu_arch != "mipsel" && cpu_arch != "mips64el") { 963 if (current_cpu != "mipsel" && current_cpu != "mips64el") {
987 common_optimize_on_ldflags += [ 964 common_optimize_on_ldflags += [
988 # Warn in case of text relocations. 965 # Warn in case of text relocations.
989 "-Wl,--warn-shared-textrel", 966 "-Wl,--warn-shared-textrel",
990 ] 967 ]
991 } 968 }
992 } 969 }
993 970
994 if (is_mac) { 971 if (is_mac) {
995 if (symbol_level == 2) { 972 if (symbol_level == 2) {
996 # Mac dead code stripping requires symbols. 973 # Mac dead code stripping requires symbols.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 cflags += [ "-gsplit-dwarf" ] 1087 cflags += [ "-gsplit-dwarf" ]
1111 } 1088 }
1112 } 1089 }
1113 } 1090 }
1114 1091
1115 config("no_symbols") { 1092 config("no_symbols") {
1116 if (!is_win) { 1093 if (!is_win) {
1117 cflags = [ "-g0" ] 1094 cflags = [ "-g0" ]
1118 } 1095 }
1119 } 1096 }
OLDNEW
« no previous file with comments | « build/config/clang/BUILD.gn ('k') | build/config/crypto.gni » ('j') | mojo/public/tools/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698