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

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

Issue 913373002: Update Chomium's build files to work w/ latest GN binaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_cpu_arch_changes
Patch Set: merge to #317214 Created 5 years, 10 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 (cpu_arch == "arm") { 6 if (current_cpu == "arm") {
7 import("//build/config/arm.gni") 7 import("//build/config/arm.gni")
8 } 8 }
9 if (cpu_arch == "mipsel" || cpu_arch == "mips64el") { 9 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
10 import("//build/config/mips.gni") 10 import("//build/config/mips.gni")
11 } 11 }
12 if (is_posix) { 12 if (is_posix) {
13 import("//build/config/gcc/gcc_version.gni") 13 import("//build/config/gcc/gcc_version.gni")
14 } 14 }
15 15
16 import("//build/toolchain/ccache.gni") 16 import("//build/toolchain/ccache.gni")
17 17
18 declare_args() { 18 declare_args() {
19 # Normally, Android builds are lightly optimized, even for debug builds, to 19 # Normally, Android builds are lightly optimized, even for debug builds, to
20 # keep binary size down. Setting this flag to true disables such optimization 20 # keep binary size down. Setting this flag to true disables such optimization
21 android_full_debug = false 21 android_full_debug = false
22 22
23 # Whether to use the binary binutils checked into third_party/binutils. 23 # Whether to use the binary binutils checked into third_party/binutils.
24 # These are not multi-arch so cannot be used except on x86 and x86-64 (the 24 # These are not multi-arch so cannot be used except on x86 and x86-64 (the
25 # only two architectures that are currently checked in). Turn this off when 25 # only two architectures that are currently checked in). Turn this off when
26 # you are using a custom toolchain and need to control -B in cflags. 26 # you are using a custom toolchain and need to control -B in cflags.
27 linux_use_bundled_binutils = is_linux && cpu_arch == "x64" 27 linux_use_bundled_binutils = is_linux && current_cpu == "x64"
28 28
29 # Compile in such a way as to enable profiling of the generated code. For 29 # Compile in such a way as to enable profiling of the generated code. For
30 # example, don't omit the frame pointer and leave in symbols. 30 # example, don't omit the frame pointer and leave in symbols.
31 enable_profiling = false 31 enable_profiling = false
32 32
33 # Compile in such a way as to make it possible for the profiler to unwind full 33 # Compile in such a way as to make it possible for the profiler to unwind full
34 # stack frames. Setting this flag has a large effect on the performance of the 34 # stack frames. Setting this flag has a large effect on the performance of the
35 # generated code than just setting profiling, but gives the profiler more 35 # generated code than just setting profiling, but gives the profiler more
36 # information to analyze. 36 # information to analyze.
37 # Requires profiling to be set to true. 37 # Requires profiling to be set to true.
38 enable_full_stack_frames_for_profiling = false 38 enable_full_stack_frames_for_profiling = false
39 39
40 # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of 40 # Use gold for linking on 64-bit Linux only (on 32-bit it runs out of
41 # address space, and it doesn't support cross-compiling). 41 # address space, and it doesn't support cross-compiling).
42 use_gold = is_linux && cpu_arch == "x64" 42 use_gold = is_linux && current_cpu == "x64"
43 43
44 # use_debug_fission: whether to use split DWARF debug info 44 # use_debug_fission: whether to use split DWARF debug info
45 # files. This can reduce link time significantly, but is incompatible 45 # files. This can reduce link time significantly, but is incompatible
46 # with some utilities such as icecc and ccache. Requires gold and 46 # with some utilities such as icecc and ccache. Requires gold and
47 # gcc >= 4.8 or clang. 47 # gcc >= 4.8 or clang.
48 # http://gcc.gnu.org/wiki/DebugFission 48 # http://gcc.gnu.org/wiki/DebugFission
49 use_debug_fission = 49 use_debug_fission =
50 !is_win && use_gold && linux_use_bundled_binutils && !use_ccache 50 !is_win && use_gold && linux_use_bundled_binutils && !use_ccache
51 } 51 }
52 52
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (is_mac) { 114 if (is_mac) {
115 cflags += [ "-fstack-protector-all" ] 115 cflags += [ "-fstack-protector-all" ]
116 } else if (is_linux) { 116 } else if (is_linux) {
117 cflags += [ 117 cflags += [
118 "-fstack-protector", 118 "-fstack-protector",
119 "--param=ssp-buffer-size=4", 119 "--param=ssp-buffer-size=4",
120 ] 120 ]
121 } 121 }
122 122
123 # Linker warnings. 123 # Linker warnings.
124 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) { 124 if (!(is_chromeos && current_cpu == "arm") && !is_mac) {
125 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 125 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
126 ldflags += [ "-Wl,--fatal-warnings" ] 126 ldflags += [ "-Wl,--fatal-warnings" ]
127 } 127 }
128 128
129 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and 129 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and
130 # MemorySanitizer 130 # MemorySanitizer
131 if (using_sanitizer) { 131 if (using_sanitizer) {
132 cflags += [ 132 cflags += [
133 "-fno-omit-frame-pointer", 133 "-fno-omit-frame-pointer",
134 "-gline-tables-only", 134 "-gline-tables-only",
(...skipping 30 matching lines...) Expand all
165 "value") ] 165 "value") ]
166 } 166 }
167 167
168 # Mac-specific compiler flags setup. 168 # Mac-specific compiler flags setup.
169 # ---------------------------------- 169 # ----------------------------------
170 if (is_mac || is_ios) { 170 if (is_mac || is_ios) {
171 # These flags are shared between the C compiler and linker. 171 # These flags are shared between the C compiler and linker.
172 common_mac_flags = [] 172 common_mac_flags = []
173 173
174 # CPU architecture. 174 # CPU architecture.
175 if (cpu_arch == "x64") { 175 if (current_cpu == "x64") {
176 common_mac_flags += [ 176 common_mac_flags += [
177 "-arch", 177 "-arch",
178 "x86_64", 178 "x86_64",
179 ] 179 ]
180 } else if (cpu_arch == "x86") { 180 } else if (current_cpu == "x86") {
181 common_mac_flags += [ 181 common_mac_flags += [
182 "-arch", 182 "-arch",
183 "i386", 183 "i386",
184 ] 184 ]
185 } 185 }
186 186
187 cflags += common_mac_flags 187 cflags += common_mac_flags
188 188
189 # Without this, the constructors and destructors of a C++ object inside 189 # Without this, the constructors and destructors of a C++ object inside
190 # an Objective C struct won't be called, which is very bad. 190 # an Objective C struct won't be called, which is very bad.
(...skipping 24 matching lines...) Expand all
215 if (enable_full_stack_frames_for_profiling) { 215 if (enable_full_stack_frames_for_profiling) {
216 cflags += [ 216 cflags += [
217 "-fno-inline", 217 "-fno-inline",
218 "-fno-optimize-sibling-calls", 218 "-fno-optimize-sibling-calls",
219 ] 219 ]
220 } 220 }
221 } 221 }
222 222
223 # CPU architecture. We may or may not be doing a cross compile now, so for 223 # CPU architecture. We may or may not be doing a cross compile now, so for
224 # simplicity we always explicitly set the architecture. 224 # simplicity we always explicitly set the architecture.
225 if (cpu_arch == "x64") { 225 if (current_cpu == "x64") {
226 cflags += [ 226 cflags += [
227 "-m64", 227 "-m64",
228 "-march=x86-64", 228 "-march=x86-64",
229 ] 229 ]
230 ldflags += [ "-m64" ] 230 ldflags += [ "-m64" ]
231 } else if (cpu_arch == "x86") { 231 } else if (current_cpu == "x86") {
232 cflags += [ "-m32" ] 232 cflags += [ "-m32" ]
233 ldflags += [ "-m32" ] 233 ldflags += [ "-m32" ]
234 if (is_clang) { 234 if (is_clang) {
235 cflags += [ 235 cflags += [
236 # Else building libyuv gives clang's register allocator issues, 236 # Else building libyuv gives clang's register allocator issues,
237 # see llvm.org/PR15798 / crbug.com/233709 237 # see llvm.org/PR15798 / crbug.com/233709
238 "-momit-leaf-frame-pointer", 238 "-momit-leaf-frame-pointer",
239 239
240 # Align the stack on 16-byte boundaries, http://crbug.com/418554. 240 # Align the stack on 16-byte boundaries, http://crbug.com/418554.
241 "-mstack-alignment=16", 241 "-mstack-alignment=16",
242 "-mstackrealign", 242 "-mstackrealign",
243 ] 243 ]
244 } 244 }
245 } else if (cpu_arch == "arm") { 245 } else if (current_cpu == "arm") {
246 # Don't set the compiler flags for the WebView build. These will come 246 # Don't set the compiler flags for the WebView build. These will come
247 # from the Android build system. 247 # from the Android build system.
248 if (!is_android_webview_build) { 248 if (!is_android_webview_build) {
249 cflags += [ 249 cflags += [
250 "-march=$arm_arch", 250 "-march=$arm_arch",
251 "-mfloat-abi=$arm_float_abi", 251 "-mfloat-abi=$arm_float_abi",
252 ] 252 ]
253 if (arm_tune != "") { 253 if (arm_tune != "") {
254 cflags += [ "-mtune=$arm_tune" ] 254 cflags += [ "-mtune=$arm_tune" ]
255 } 255 }
(...skipping 12 matching lines...) Expand all
268 # compiler (r5-r7). This can be verified using 268 # compiler (r5-r7). This can be verified using
269 # webkit_unit_tests' WTF.Checked_int8_t test. 269 # webkit_unit_tests' WTF.Checked_int8_t test.
270 "-fno-tree-sra", 270 "-fno-tree-sra",
271 271
272 # The following option is disabled to improve binary 272 # The following option is disabled to improve binary
273 # size and performance in gcc 4.9. 273 # size and performance in gcc 4.9.
274 "-fno-caller-saves", 274 "-fno-caller-saves",
275 ] 275 ]
276 } 276 }
277 } 277 }
278 } else if (cpu_arch == "mipsel") { 278 } else if (current_cpu == "mipsel") {
279 # Don't set the compiler flags for the WebView build. These will come 279 # Don't set the compiler flags for the WebView build. These will come
280 # from the Android build system. 280 # from the Android build system.
281 if (!is_android_webview_build) { 281 if (!is_android_webview_build) {
282 if (mips_arch_variant == "r6") { 282 if (mips_arch_variant == "r6") {
283 cflags += [ 283 cflags += [
284 "-mips32r6", 284 "-mips32r6",
285 "-Wa,-mips32r6", 285 "-Wa,-mips32r6",
286 ] 286 ]
287 if (is_android) { 287 if (is_android) {
288 ldflags += [ 288 ldflags += [
289 "-mips32r6", 289 "-mips32r6",
290 "-Wl,-melf32ltsmip", 290 "-Wl,-melf32ltsmip",
291 ] 291 ]
292 } 292 }
293 } else if (mips_arch_variant == "r2") { 293 } else if (mips_arch_variant == "r2") {
294 cflags += [ 294 cflags += [
295 "-mips32r2", 295 "-mips32r2",
296 "-Wa,-mips32r2", 296 "-Wa,-mips32r2",
297 ] 297 ]
298 } else if (mips_arch_variant == "r1") { 298 } else if (mips_arch_variant == "r1") {
299 cflags += [ 299 cflags += [
300 "-mips32", 300 "-mips32",
301 "-Wa,-mips32", 301 "-Wa,-mips32",
302 ] 302 ]
303 } 303 }
304 } 304 }
305 } else if (cpu_arch == "mips64el") { 305 } else if (current_cpu == "mips64el") {
306 # Don't set the compiler flags for the WebView build. These will come 306 # Don't set the compiler flags for the WebView build. These will come
307 # from the Android build system. 307 # from the Android build system.
308 if (!is_android_webview_build) { 308 if (!is_android_webview_build) {
309 if (mips_arch_variant == "r6") { 309 if (mips_arch_variant == "r6") {
310 cflags += [ 310 cflags += [
311 "-mips64r6", 311 "-mips64r6",
312 "-Wa,-mips64r6", 312 "-Wa,-mips64r6",
313 ] 313 ]
314 ldflags += [ "-mips64r6" ] 314 ldflags += [ "-mips64r6" ]
315 } else if (mips_arch_variant == "r2") { 315 } else if (mips_arch_variant == "r2") {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 430 }
431 431
432 defines += [ "ANDROID" ] 432 defines += [ "ANDROID" ]
433 if (!is_android_webview_build) { 433 if (!is_android_webview_build) {
434 # The NDK has these things, but doesn't define the constants 434 # The NDK has these things, but doesn't define the constants
435 # to say that it does. Define them here instead. 435 # to say that it does. Define them here instead.
436 defines += [ "HAVE_SYS_UIO_H" ] 436 defines += [ "HAVE_SYS_UIO_H" ]
437 } 437 }
438 438
439 # Use gold for Android for most CPU architectures. 439 # Use gold for Android for most CPU architectures.
440 if (cpu_arch == "x86" || cpu_arch == "x64" || cpu_arch == "arm") { 440 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") {
441 ldflags += [ "-fuse-ld=gold" ] 441 ldflags += [ "-fuse-ld=gold" ]
442 if (is_clang) { 442 if (is_clang) {
443 # Let clang find the ld.gold in the NDK. 443 # Let clang find the ld.gold in the NDK.
444 ldflags += [ "--gcc-toolchain=" + 444 ldflags += [ "--gcc-toolchain=" +
445 rebase_path(android_toolchain_root, root_build_dir) ] 445 rebase_path(android_toolchain_root, root_build_dir) ]
446 } 446 }
447 } 447 }
448 448
449 ldflags += [ 449 ldflags += [
450 "-Wl,--no-undefined", 450 "-Wl,--no-undefined",
451 451
452 # Don't allow visible symbols from libgcc or stlport to be 452 # Don't allow visible symbols from libgcc or stlport to be
453 # re-exported. 453 # re-exported.
454 "-Wl,--exclude-libs=libgcc.a", 454 "-Wl,--exclude-libs=libgcc.a",
455 "-Wl,--exclude-libs=libstlport_static.a", 455 "-Wl,--exclude-libs=libstlport_static.a",
456 456
457 # Don't allow visible symbols from libraries that contain 457 # Don't allow visible symbols from libraries that contain
458 # assembly code with symbols that aren't hidden properly. 458 # assembly code with symbols that aren't hidden properly.
459 # http://crbug.com/448386 459 # http://crbug.com/448386
460 "-Wl,--exclude-libs=libvpx_assembly_arm.a", 460 "-Wl,--exclude-libs=libvpx_assembly_arm.a",
461 ] 461 ]
462 if (cpu_arch == "arm") { 462 if (current_cpu == "arm") {
463 ldflags += [ 463 ldflags += [
464 # Enable identical code folding to reduce size. 464 # Enable identical code folding to reduce size.
465 "-Wl,--icf=safe", 465 "-Wl,--icf=safe",
466 ] 466 ]
467 } 467 }
468 468
469 if (is_clang) { 469 if (is_clang) {
470 if (cpu_arch == "arm") { 470 if (current_cpu == "arm") {
471 cflags += [ "-target arm-linux-androideabi" ] 471 cflags += [ "-target arm-linux-androideabi" ]
472 ldflags += [ "-target arm-linux-androideabi" ] 472 ldflags += [ "-target arm-linux-androideabi" ]
473 } else if (cpu_arch == "x86") { 473 } else if (current_cpu == "x86") {
474 cflags += [ "-target x86-linux-androideabi" ] 474 cflags += [ "-target x86-linux-androideabi" ]
475 ldflags += [ "-target x86-linux-androideabi" ] 475 ldflags += [ "-target x86-linux-androideabi" ]
476 } 476 }
477 } 477 }
478 } 478 }
479 } 479 }
480 480
481 config("compiler_arm_fpu") { 481 config("compiler_arm_fpu") {
482 if (cpu_arch == "arm" && !is_android_webview_build) { 482 if (current_cpu == "arm" && !is_android_webview_build) {
483 cflags = [ "-mfpu=$arm_fpu" ] 483 cflags = [ "-mfpu=$arm_fpu" ]
484 } 484 }
485 } 485 }
486 486
487 # runtime_library ------------------------------------------------------------- 487 # runtime_library -------------------------------------------------------------
488 # 488 #
489 # Sets the runtime library and associated options. 489 # Sets the runtime library and associated options.
490 # 490 #
491 # How do you determine what should go in here vs. "compiler" above? Consider if 491 # How do you determine what should go in here vs. "compiler" above? Consider if
492 # a target might choose to use a different runtime library (ignore for a moment 492 # a target might choose to use a different runtime library (ignore for a moment
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 cflags += [ "-isystem" + 570 cflags += [ "-isystem" +
571 rebase_path("$android_stlport_root/stlport", root_build_dir) ] 571 rebase_path("$android_stlport_root/stlport", root_build_dir) ]
572 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ] 572 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ]
573 573
574 if (component_mode == "shared_library") { 574 if (component_mode == "shared_library") {
575 libs += [ "stlport_shared" ] 575 libs += [ "stlport_shared" ]
576 } else { 576 } else {
577 libs += [ "stlport_static" ] 577 libs += [ "stlport_static" ]
578 } 578 }
579 579
580 if (cpu_arch == "mipsel") { 580 if (current_cpu == "mipsel") {
581 libs += [ 581 libs += [
582 # ld linker is used for mips Android, and ld does not accept library 582 # ld linker is used for mips Android, and ld does not accept library
583 # absolute path prefixed by "-l"; Since libgcc does not exist in mips 583 # absolute path prefixed by "-l"; Since libgcc does not exist in mips
584 # sysroot the proper library will be linked. 584 # sysroot the proper library will be linked.
585 # TODO(gordanac): Remove once gold linker is used for mips Android. 585 # TODO(gordanac): Remove once gold linker is used for mips Android.
586 "gcc", 586 "gcc",
587 ] 587 ]
588 } else { 588 } else {
589 libs += [ 589 libs += [
590 # Manually link the libgcc.a that the cross compiler uses. This is 590 # Manually link the libgcc.a that the cross compiler uses. This is
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 # See comment for -Wno-c++11-narrowing. 837 # See comment for -Wno-c++11-narrowing.
838 "-Wno-narrowing", 838 "-Wno-narrowing",
839 839
840 # TODO(thakis): Remove, http://crbug.com/263960 840 # TODO(thakis): Remove, http://crbug.com/263960
841 "-Wno-literal-suffix", 841 "-Wno-literal-suffix",
842 ] 842 ]
843 } 843 }
844 844
845 # Suppress warnings about ABI changes on ARM (Clang doesn't give this 845 # Suppress warnings about ABI changes on ARM (Clang doesn't give this
846 # warning). 846 # warning).
847 if (cpu_arch == "arm" && !is_clang) { 847 if (current_cpu == "arm" && !is_clang) {
848 cflags += [ "-Wno-psabi" ] 848 cflags += [ "-Wno-psabi" ]
849 } 849 }
850 850
851 if (is_android) { 851 if (is_android) {
852 # Disable any additional warnings enabled by the Android build system but 852 # Disable any additional warnings enabled by the Android build system but
853 # which chromium does not build cleanly with (when treating warning as 853 # which chromium does not build cleanly with (when treating warning as
854 # errors). 854 # errors).
855 cflags += [ 855 cflags += [
856 "-Wno-extra", 856 "-Wno-extra",
857 "-Wno-ignored-qualifiers", 857 "-Wno-ignored-qualifiers",
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 890
891 # On Windows compiling on x64, VC will issue a warning when converting 891 # On Windows compiling on x64, VC will issue a warning when converting
892 # size_t to int because it will truncate the value. Our code should not have 892 # size_t to int because it will truncate the value. Our code should not have
893 # these warnings and one should use a static_cast or a checked_cast for the 893 # these warnings and one should use a static_cast or a checked_cast for the
894 # conversion depending on the case. However, a lot of code still needs to be 894 # conversion depending on the case. However, a lot of code still needs to be
895 # fixed. Apply this config to such targets to disable the warning. 895 # fixed. Apply this config to such targets to disable the warning.
896 # 896 #
897 # Note that this can be applied regardless of platform and architecture to 897 # Note that this can be applied regardless of platform and architecture to
898 # clean up the call sites. This will only apply the flag when necessary. 898 # clean up the call sites. This will only apply the flag when necessary.
899 config("no_size_t_to_int_warning") { 899 config("no_size_t_to_int_warning") {
900 if (is_win && cpu_arch == "x64") { 900 if (is_win && current_cpu == "x64") {
901 cflags = [ "/wd4267" ] 901 cflags = [ "/wd4267" ]
902 } 902 }
903 } 903 }
904 904
905 # Optimization ----------------------------------------------------------------- 905 # Optimization -----------------------------------------------------------------
906 # 906 #
907 # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config" 907 # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config"
908 # which it will assign to the config it implicitly applies to every target. If 908 # which it will assign to the config it implicitly applies to every target. If
909 # you want to override the optimization level for your target, remove this 909 # you want to override the optimization level for your target, remove this
910 # config (which will expand differently for debug or release builds), and then 910 # config (which will expand differently for debug or release builds), and then
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 cflags += [ "-gsplit-dwarf" ] 1074 cflags += [ "-gsplit-dwarf" ]
1075 } 1075 }
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 config("no_symbols") { 1079 config("no_symbols") {
1080 if (!is_win) { 1080 if (!is_win) {
1081 cflags = [ "-g0" ] 1081 cflags = [ "-g0" ]
1082 } 1082 }
1083 } 1083 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698