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