| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 if (cpu_arch == "arm") { | 6 if (cpu_arch == "arm") { |
| 7 import("//build/config/arm.gni") | 7 import("//build/config/arm.gni") |
| 8 } | 8 } |
| 9 if (is_posix) { | 9 if (is_posix) { |
| 10 import("//build/config/gcc/gcc_version.gni") | 10 import("//build/config/gcc/gcc_version.gni") |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 # below. | 83 # below. |
| 84 if (is_win) { | 84 if (is_win) { |
| 85 # Windows compiler flags setup. | 85 # Windows compiler flags setup. |
| 86 # ----------------------------- | 86 # ----------------------------- |
| 87 cflags += [ | 87 cflags += [ |
| 88 "/Gy", # Enable function-level linking. | 88 "/Gy", # Enable function-level linking. |
| 89 "/GS", # Enable buffer security checking. | 89 "/GS", # Enable buffer security checking. |
| 90 "/FS", # Preserve previous PDB behavior. | 90 "/FS", # Preserve previous PDB behavior. |
| 91 ] | 91 ] |
| 92 if (is_component_build) { | 92 if (is_component_build) { |
| 93 cflags += [ | 93 cflags += [ "/EHsc" ] # Assume C functions can't throw exceptions and don
't catch |
| 94 "/EHsc", # Assume C functions can't throw exceptions and don't catch | 94 # structured exceptions (only C++ ones). |
| 95 # structured exceptions (only C++ ones). | |
| 96 ] | |
| 97 } | 95 } |
| 98 } else { | 96 } else { |
| 99 # Common GCC compiler flags setup. | 97 # Common GCC compiler flags setup. |
| 100 # -------------------------------- | 98 # -------------------------------- |
| 101 cflags += [ | 99 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 |
| 102 "-fno-strict-aliasing", # See http://crbug.com/32204 | |
| 103 ] | |
| 104 cflags_cc += [ | 100 cflags_cc += [ |
| 105 "-fno-threadsafe-statics", | 101 "-fno-threadsafe-statics", |
| 102 |
| 106 # Not exporting C++ inline functions can generally be applied anywhere | 103 # Not exporting C++ inline functions can generally be applied anywhere |
| 107 # so we do so here. Normal function visibility is controlled by | 104 # so we do so here. Normal function visibility is controlled by |
| 108 # //build/config/gcc:symbol_visibility_hidden. | 105 # //build/config/gcc:symbol_visibility_hidden. |
| 109 "-fvisibility-inlines-hidden", | 106 "-fvisibility-inlines-hidden", |
| 110 ] | 107 ] |
| 111 | 108 |
| 112 # Stack protection. | 109 # Stack protection. |
| 113 if (is_mac) { | 110 if (is_mac) { |
| 114 cflags += [ "-fstack-protector-all" ] | 111 cflags += [ "-fstack-protector-all" ] |
| 115 } else if (is_linux) { | 112 } else if (is_linux) { |
| 116 cflags += [ "-fstack-protector", "--param=ssp-buffer-size=4" ] | 113 cflags += [ |
| 114 "-fstack-protector", |
| 115 "--param=ssp-buffer-size=4", |
| 116 ] |
| 117 } | 117 } |
| 118 | 118 |
| 119 # Linker warnings. | 119 # Linker warnings. |
| 120 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) { | 120 if (!(is_chromeos && cpu_arch == "arm") && !is_mac) { |
| 121 # 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 |
| 122 ldflags += [ "-Wl,--fatal-warnings" ] | 122 ldflags += [ "-Wl,--fatal-warnings" ] |
| 123 } | 123 } |
| 124 | 124 |
| 125 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and | 125 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and |
| 126 # MemorySanitizer | 126 # MemorySanitizer |
| (...skipping 21 matching lines...) Expand all Loading... |
| 148 "-Wno-undefined-bool-conversion", | 148 "-Wno-undefined-bool-conversion", |
| 149 "-Wno-tautological-undefined-compare", | 149 "-Wno-tautological-undefined-compare", |
| 150 ] | 150 ] |
| 151 } | 151 } |
| 152 | 152 |
| 153 if (is_clang && !is_win) { | 153 if (is_clang && !is_win) { |
| 154 # 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 |
| 155 # 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, |
| 156 # and build system rebuild things when their commandline changes). Nothing | 156 # and build system rebuild things when their commandline changes). Nothing |
| 157 # should ever read this define. | 157 # should ever read this define. |
| 158 defines += [ | 158 defines += [ "CR_CLANG_REVISION=" + |
| 159 "CR_CLANG_REVISION=" + | 159 exec_script("//tools/clang/scripts/posix-print-revision.py", |
| 160 exec_script( | 160 [], |
| 161 "//tools/clang/scripts/posix-print-revision.py", [], "value") | 161 "value") ] |
| 162 ] | |
| 163 } | 162 } |
| 164 | 163 |
| 165 # Mac-specific compiler flags setup. | 164 # Mac-specific compiler flags setup. |
| 166 # ---------------------------------- | 165 # ---------------------------------- |
| 167 if (is_mac || is_ios) { | 166 if (is_mac || is_ios) { |
| 168 # These flags are shared between the C compiler and linker. | 167 # These flags are shared between the C compiler and linker. |
| 169 common_mac_flags = [] | 168 common_mac_flags = [] |
| 170 | 169 |
| 171 # CPU architecture. | 170 # CPU architecture. |
| 172 if (cpu_arch == "x64") { | 171 if (cpu_arch == "x64") { |
| 173 common_mac_flags += [ "-arch", "x86_64" ] | 172 common_mac_flags += [ |
| 173 "-arch", |
| 174 "x86_64", |
| 175 ] |
| 174 } else if (cpu_arch == "x86") { | 176 } else if (cpu_arch == "x86") { |
| 175 common_mac_flags += [ "-arch", "i386" ] | 177 common_mac_flags += [ |
| 178 "-arch", |
| 179 "i386", |
| 180 ] |
| 176 } | 181 } |
| 177 | 182 |
| 178 cflags += common_mac_flags | 183 cflags += common_mac_flags |
| 179 | 184 |
| 180 # Without this, the constructors and destructors of a C++ object inside | 185 # Without this, the constructors and destructors of a C++ object inside |
| 181 # 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. |
| 182 cflags_objcc = [ "-fobjc-call-cxx-cdtors", ] | 187 cflags_objcc = [ "-fobjc-call-cxx-cdtors" ] |
| 183 | 188 |
| 184 cflags_c += [ "-std=c99" ] | 189 cflags_c += [ "-std=c99" ] |
| 185 cflags_cc += [ "-std=gnu++11" ] | 190 cflags_cc += [ "-std=gnu++11" ] |
| 186 | 191 |
| 187 ldflags += common_mac_flags | 192 ldflags += common_mac_flags |
| 188 } else if (is_posix) { | 193 } else if (is_posix) { |
| 189 # Non-Mac Posix compiler flags setup. | 194 # Non-Mac Posix compiler flags setup. |
| 190 # ----------------------------------- | 195 # ----------------------------------- |
| 191 if (gcc_version >= 48) { | 196 if (gcc_version >= 48) { |
| 192 cflags_cc += [ | 197 cflags_cc += [ "-std=gnu++11" ] |
| 193 "-std=gnu++11", | |
| 194 ] | |
| 195 } | 198 } |
| 196 | 199 |
| 197 if (enable_profiling && !is_debug) { | 200 if (enable_profiling && !is_debug) { |
| 198 # The GYP build spams this define into every compilation unit, as we do | 201 # The GYP build spams this define into every compilation unit, as we do |
| 199 # here, but it only appears to be used in base and a couple other places. | 202 # here, but it only appears to be used in base and a couple other places. |
| 200 # TODO(abarth): Should we move this define closer to where it's used? | 203 # TODO(abarth): Should we move this define closer to where it's used? |
| 201 defines += [ "ENABLE_PROFILING" ] | 204 defines += [ "ENABLE_PROFILING" ] |
| 202 | 205 |
| 203 cflags += [ | 206 cflags += [ |
| 204 "-fno-omit-frame-pointer", | 207 "-fno-omit-frame-pointer", |
| 205 "-g", | 208 "-g", |
| 206 ] | 209 ] |
| 207 | 210 |
| 208 if (enable_full_stack_frames_for_profiling) { | 211 if (enable_full_stack_frames_for_profiling) { |
| 209 cflags += [ | 212 cflags += [ |
| 210 "-fno-inline", | 213 "-fno-inline", |
| 211 "-fno-optimize-sibling-calls", | 214 "-fno-optimize-sibling-calls", |
| 212 ] | 215 ] |
| 213 } | 216 } |
| 214 } | 217 } |
| 215 | 218 |
| 216 # 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 |
| 217 # simplicity we always explicitly set the architecture. | 220 # simplicity we always explicitly set the architecture. |
| 218 if (cpu_arch == "x64") { | 221 if (cpu_arch == "x64") { |
| 219 cflags += [ "-m64", "-march=x86-64", ] | 222 cflags += [ |
| 223 "-m64", |
| 224 "-march=x86-64", |
| 225 ] |
| 220 ldflags += [ "-m64" ] | 226 ldflags += [ "-m64" ] |
| 221 } else if (cpu_arch == "x86") { | 227 } else if (cpu_arch == "x86") { |
| 222 cflags += [ "-m32" ] | 228 cflags += [ "-m32" ] |
| 223 ldflags += [ "-m32" ] | 229 ldflags += [ "-m32" ] |
| 224 if (is_clang) { | 230 if (is_clang) { |
| 225 cflags += [ | 231 cflags += [ |
| 226 # Else building libyuv gives clang's register allocator issues, | 232 # Else building libyuv gives clang's register allocator issues, |
| 227 # see llvm.org/PR15798 / crbug.com/233709 | 233 # see llvm.org/PR15798 / crbug.com/233709 |
| 228 "-momit-leaf-frame-pointer", | 234 "-momit-leaf-frame-pointer", |
| 235 |
| 229 # Align the stack on 16-byte boundaries, http://crbug.com/418554. | 236 # Align the stack on 16-byte boundaries, http://crbug.com/418554. |
| 230 "-mstack-alignment=16", | 237 "-mstack-alignment=16", |
| 231 "-mstackrealign", | 238 "-mstackrealign", |
| 232 ] | 239 ] |
| 233 } | 240 } |
| 234 } else if (cpu_arch == "arm") { | 241 } else if (cpu_arch == "arm") { |
| 235 # 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 |
| 236 # from the Android build system. | 243 # from the Android build system. |
| 237 if (!is_android_webview_build) { | 244 if (!is_android_webview_build) { |
| 238 cflags += [ | 245 cflags += [ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 250 } | 257 } |
| 251 if (!is_clang) { | 258 if (!is_clang) { |
| 252 # Clang doesn't support these flags. | 259 # Clang doesn't support these flags. |
| 253 cflags += [ | 260 cflags += [ |
| 254 # The tree-sra optimization (scalar replacement for | 261 # The tree-sra optimization (scalar replacement for |
| 255 # aggregates enabling subsequent optimizations) leads to | 262 # aggregates enabling subsequent optimizations) leads to |
| 256 # invalid code generation when using the Android NDK's | 263 # invalid code generation when using the Android NDK's |
| 257 # compiler (r5-r7). This can be verified using | 264 # compiler (r5-r7). This can be verified using |
| 258 # webkit_unit_tests' WTF.Checked_int8_t test. | 265 # webkit_unit_tests' WTF.Checked_int8_t test. |
| 259 "-fno-tree-sra", | 266 "-fno-tree-sra", |
| 267 |
| 260 # The following option is disabled to improve binary | 268 # The following option is disabled to improve binary |
| 261 # size and performance in gcc 4.9. | 269 # size and performance in gcc 4.9. |
| 262 "-fno-caller-saves", | 270 "-fno-caller-saves", |
| 263 ] | 271 ] |
| 264 } | 272 } |
| 265 } | 273 } |
| 266 } | 274 } |
| 267 | 275 |
| 268 defines += [ "_FILE_OFFSET_BITS=64" ] | 276 defines += [ "_FILE_OFFSET_BITS=64" ] |
| 269 | 277 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 292 "-Wl,-z,noexecstack", | 300 "-Wl,-z,noexecstack", |
| 293 "-Wl,-z,now", | 301 "-Wl,-z,now", |
| 294 "-Wl,-z,relro", | 302 "-Wl,-z,relro", |
| 295 ] | 303 ] |
| 296 } | 304 } |
| 297 | 305 |
| 298 # Linux-specific compiler flags setup. | 306 # Linux-specific compiler flags setup. |
| 299 # ------------------------------------ | 307 # ------------------------------------ |
| 300 if (is_linux) { | 308 if (is_linux) { |
| 301 cflags += [ "-pthread" ] | 309 cflags += [ "-pthread" ] |
| 302 ldflags += [ | 310 ldflags += [ "-pthread" ] |
| 303 "-pthread", | |
| 304 ] | |
| 305 } | 311 } |
| 306 if (use_gold) { | 312 if (use_gold) { |
| 307 # 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 |
| 308 # address space, and it doesn't support cross-compiling). | 314 # address space, and it doesn't support cross-compiling). |
| 309 gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 315 gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
| 310 root_build_dir) | 316 root_build_dir) |
| 311 ldflags += [ | 317 ldflags += [ |
| 312 "-B$gold_path", | 318 "-B$gold_path", |
| 313 | 319 |
| 314 # 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... |
| 333 | 339 |
| 334 if (linux_use_bundled_binutils) { | 340 if (linux_use_bundled_binutils) { |
| 335 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 341 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
| 336 root_build_dir) | 342 root_build_dir) |
| 337 cflags += [ "-B$binutils_path" ] | 343 cflags += [ "-B$binutils_path" ] |
| 338 } | 344 } |
| 339 | 345 |
| 340 # Clang-specific compiler flags setup. | 346 # Clang-specific compiler flags setup. |
| 341 # ------------------------------------ | 347 # ------------------------------------ |
| 342 if (is_clang) { | 348 if (is_clang) { |
| 343 cflags += [ | 349 cflags += [ "-fcolor-diagnostics" ] |
| 344 "-fcolor-diagnostics", | 350 cflags_cc += [ "-std=gnu++11" ] |
| 345 ] | |
| 346 cflags_cc += [ | |
| 347 "-std=gnu++11", | |
| 348 ] | |
| 349 } | 351 } |
| 350 | 352 |
| 351 # Android-specific flags setup. | 353 # Android-specific flags setup. |
| 352 # ----------------------------- | 354 # ----------------------------- |
| 353 if (is_android) { | 355 if (is_android) { |
| 354 cflags += [ | 356 cflags += [ |
| 355 "-ffunction-sections", | 357 "-ffunction-sections", |
| 356 "-funwind-tables", | 358 "-funwind-tables", |
| 357 "-fno-short-enums", | 359 "-fno-short-enums", |
| 358 ] | 360 ] |
| 359 if (!is_clang) { | 361 if (!is_clang) { |
| 360 # Clang doesn't support these flags. | 362 # Clang doesn't support these flags. |
| 361 cflags += [ | 363 cflags += [ "-finline-limit=64" ] |
| 362 "-finline-limit=64", | |
| 363 ] | |
| 364 } | 364 } |
| 365 if (is_android_webview_build) { | 365 if (is_android_webview_build) { |
| 366 # 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 |
| 367 # 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 |
| 368 # works because cflags are added before defines. | 368 # works because cflags are added before defines. |
| 369 # TODO(brettw) the above comment seems incorrect. We specify defines | 369 # TODO(brettw) the above comment seems incorrect. We specify defines |
| 370 # before cflags on our compiler command lines. | 370 # before cflags on our compiler command lines. |
| 371 cflags += [ "-U_FORTIFY_SOURCE" ] | 371 cflags += [ "-U_FORTIFY_SOURCE" ] |
| 372 } | 372 } |
| 373 | 373 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 384 # The NDK has these things, but doesn't define the constants | 384 # The NDK has these things, but doesn't define the constants |
| 385 # to say that it does. Define them here instead. | 385 # to say that it does. Define them here instead. |
| 386 defines += [ "HAVE_SYS_UIO_H" ] | 386 defines += [ "HAVE_SYS_UIO_H" ] |
| 387 } | 387 } |
| 388 | 388 |
| 389 # Use gold for Android for most CPU architectures. | 389 # Use gold for Android for most CPU architectures. |
| 390 if (cpu_arch == "x86" || cpu_arch == "x64" || cpu_arch == "arm") { | 390 if (cpu_arch == "x86" || cpu_arch == "x64" || cpu_arch == "arm") { |
| 391 ldflags += [ "-fuse-ld=gold" ] | 391 ldflags += [ "-fuse-ld=gold" ] |
| 392 if (is_clang) { | 392 if (is_clang) { |
| 393 # Let clang find the ld.gold in the NDK. | 393 # Let clang find the ld.gold in the NDK. |
| 394 ldflags += [ "--gcc-toolchain=" + rebase_path(android_toolchain_root, | 394 ldflags += [ "--gcc-toolchain=" + |
| 395 root_build_dir) ] | 395 rebase_path(android_toolchain_root, root_build_dir) ] |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 ldflags += [ | 399 ldflags += [ |
| 400 "-Wl,--no-undefined", | 400 "-Wl,--no-undefined", |
| 401 |
| 401 # Don't export symbols from statically linked libraries. | 402 # Don't export symbols from statically linked libraries. |
| 402 "-Wl,--exclude-libs=ALL", | 403 "-Wl,--exclude-libs=ALL", |
| 403 ] | 404 ] |
| 404 if (cpu_arch == "arm") { | 405 if (cpu_arch == "arm") { |
| 405 ldflags += [ | 406 ldflags += [ |
| 406 # Enable identical code folding to reduce size. | 407 # Enable identical code folding to reduce size. |
| 407 "-Wl,--icf=safe", | 408 "-Wl,--icf=safe", |
| 408 ] | 409 ] |
| 409 } | 410 } |
| 410 | 411 |
| 411 if (is_clang) { | 412 if (is_clang) { |
| 412 if (cpu_arch == "arm") { | 413 if (cpu_arch == "arm") { |
| 413 cflags += [ | 414 cflags += [ "-target arm-linux-androideabi" ] |
| 414 "-target arm-linux-androideabi", | |
| 415 ] | |
| 416 ldflags += [ "-target arm-linux-androideabi" ] | 415 ldflags += [ "-target arm-linux-androideabi" ] |
| 417 } else if (cpu_arch == "x86") { | 416 } else if (cpu_arch == "x86") { |
| 418 cflags += [ "-target x86-linux-androideabi" ] | 417 cflags += [ "-target x86-linux-androideabi" ] |
| 419 ldflags += [ "-target x86-linux-androideabi" ] | 418 ldflags += [ "-target x86-linux-androideabi" ] |
| 420 } | 419 } |
| 421 } | 420 } |
| 422 } | 421 } |
| 423 } | 422 } |
| 424 | 423 |
| 425 config("compiler_arm_fpu") { | 424 config("compiler_arm_fpu") { |
| 426 if (cpu_arch == "arm" && !is_android_webview_build) { | 425 if (cpu_arch == "arm" && !is_android_webview_build) { |
| 427 cflags = [ | 426 cflags = [ "-mfpu=$arm_fpu" ] |
| 428 "-mfpu=$arm_fpu", | |
| 429 ] | |
| 430 } | 427 } |
| 431 } | 428 } |
| 432 | 429 |
| 433 # runtime_library ------------------------------------------------------------- | 430 # runtime_library ------------------------------------------------------------- |
| 434 # | 431 # |
| 435 # Sets the runtime library and associated options. | 432 # Sets the runtime library and associated options. |
| 436 # | 433 # |
| 437 # 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 |
| 438 # 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 |
| 439 # 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... |
| 506 ] | 503 ] |
| 507 | 504 |
| 508 # NOTE: The stlport header include paths below are specified in cflags | 505 # NOTE: The stlport header include paths below are specified in cflags |
| 509 # 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. |
| 510 # 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 |
| 511 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit | 508 # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit |
| 512 # strange errors. The include ordering here is important; change with | 509 # strange errors. The include ordering here is important; change with |
| 513 # caution. | 510 # caution. |
| 514 android_stlport_root = "$android_ndk_root/sources/cxx-stl/stlport" | 511 android_stlport_root = "$android_ndk_root/sources/cxx-stl/stlport" |
| 515 | 512 |
| 516 cflags += [ | 513 cflags += [ "-isystem" + |
| 517 "-isystem" + rebase_path("$android_stlport_root/stlport", | 514 rebase_path("$android_stlport_root/stlport", root_build_dir) ] |
| 518 root_build_dir) | |
| 519 ] | |
| 520 if (cpu_arch == "arm" && arm_use_thumb) { | 515 if (cpu_arch == "arm" && arm_use_thumb) { |
| 521 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi/thumb" ] | 516 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi/thumb" ] |
| 522 } else { | 517 } else { |
| 523 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ] | 518 lib_dirs += [ "$android_stlport_root/libs/$android_app_abi" ] |
| 524 } | 519 } |
| 525 | 520 |
| 526 if (component_mode == "shared_library") { | 521 if (component_mode == "shared_library") { |
| 527 libs += [ "stlport_shared" ] | 522 libs += [ "stlport_shared" ] |
| 528 } else { | 523 } else { |
| 529 libs += [ "stlport_static" ] | 524 libs += [ "stlport_static" ] |
| (...skipping 13 matching lines...) Expand all Loading... |
| 543 # absolute because the linker will look inside the sysroot if it's not. | 538 # absolute because the linker will look inside the sysroot if it's not. |
| 544 rebase_path(android_libgcc_file), | 539 rebase_path(android_libgcc_file), |
| 545 ] | 540 ] |
| 546 } | 541 } |
| 547 | 542 |
| 548 libs += [ | 543 libs += [ |
| 549 "c", | 544 "c", |
| 550 "dl", | 545 "dl", |
| 551 "m", | 546 "m", |
| 552 ] | 547 ] |
| 553 | |
| 554 } | 548 } |
| 555 } | 549 } |
| 556 | 550 |
| 557 # chromium_code --------------------------------------------------------------- | 551 # chromium_code --------------------------------------------------------------- |
| 558 # | 552 # |
| 559 # Toggles between higher and lower warnings for code that is (or isn't) | 553 # Toggles between higher and lower warnings for code that is (or isn't) |
| 560 # part of Chromium. | 554 # part of Chromium. |
| 561 | 555 |
| 562 config("chromium_code") { | 556 config("chromium_code") { |
| 563 if (is_win) { | 557 if (is_win) { |
| 564 cflags = [ | 558 cflags = [ "/W4" ] # Warning level 4. |
| 565 "/W4", # Warning level 4. | |
| 566 ] | |
| 567 } else { | 559 } else { |
| 568 cflags = [ | 560 cflags = [ |
| 569 "-Wall", | 561 "-Wall", |
| 570 | 562 |
| 571 # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, | 563 # GCC turns on -Wsign-compare for C++ under -Wall, but clang doesn't, |
| 572 # so we specify it explicitly. | 564 # so we specify it explicitly. |
| 573 # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it. | 565 # TODO(fischman): remove this if http://llvm.org/PR10448 obsoletes it. |
| 574 # http://code.google.com/p/chromium/issues/detail?id=90453 | 566 # http://code.google.com/p/chromium/issues/detail?id=90453 |
| 575 "-Wsign-compare", | 567 "-Wsign-compare", |
| 576 ] | 568 ] |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 646 } |
| 655 | 647 |
| 656 # Warnings --------------------------------------------------------------------- | 648 # Warnings --------------------------------------------------------------------- |
| 657 # | 649 # |
| 658 # This is where we disable various warnings that we've decided aren't | 650 # This is where we disable various warnings that we've decided aren't |
| 659 # worthwhile, and enable special warnings. | 651 # worthwhile, and enable special warnings. |
| 660 | 652 |
| 661 config("default_warnings") { | 653 config("default_warnings") { |
| 662 if (is_win) { | 654 if (is_win) { |
| 663 cflags = [ | 655 cflags = [ |
| 664 "/WX", # Treat warnings as errors. | 656 "/WX", # Treat warnings as errors. |
| 665 | |
| 666 # Warnings permanently disabled: | 657 # Warnings permanently disabled: |
| 667 | 658 |
| 668 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled | 659 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled |
| 669 # for a bunch of individual targets. Re-enable this globally when those | 660 # for a bunch of individual targets. Re-enable this globally when those |
| 670 # targets are fixed. | 661 # targets are fixed. |
| 671 "/wd4018", # Comparing signed and unsigned values. | 662 "/wd4018", # Comparing signed and unsigned values. |
| 672 | 663 |
| 673 # C4127: conditional expression is constant | 664 # C4127: conditional expression is constant |
| 674 # This warning can in theory catch dead code and other problems, but | 665 # This warning can in theory catch dead code and other problems, but |
| 675 # triggers in far too many desirable cases where the conditional | 666 # triggers in far too many desirable cases where the conditional |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 701 |
| 711 # C4611: interaction between 'function' and C++ object destruction is | 702 # C4611: interaction between 'function' and C++ object destruction is |
| 712 # non-portable | 703 # non-portable |
| 713 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN | 704 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN |
| 714 # suggests using exceptions instead of setjmp/longjmp for C++, but | 705 # suggests using exceptions instead of setjmp/longjmp for C++, but |
| 715 # Chromium code compiles without exception support. We therefore have to | 706 # Chromium code compiles without exception support. We therefore have to |
| 716 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we | 707 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we |
| 717 # have to turn off this warning (and be careful about how object | 708 # have to turn off this warning (and be careful about how object |
| 718 # destruction happens in such cases). | 709 # destruction happens in such cases). |
| 719 "/wd4611", | 710 "/wd4611", |
| 720 | |
| 721 | |
| 722 # Warnings to evaluate and possibly fix/reenable later: | 711 # Warnings to evaluate and possibly fix/reenable later: |
| 723 | 712 |
| 724 "/wd4100", # Unreferenced formal function parameter. | 713 "/wd4100", # Unreferenced formal function parameter. |
| 725 "/wd4121", # Alignment of a member was sensitive to packing. | 714 "/wd4121", # Alignment of a member was sensitive to packing. |
| 726 "/wd4244", # Conversion: possible loss of data. | 715 "/wd4244", # Conversion: possible loss of data. |
| 727 "/wd4481", # Nonstandard extension: override specifier. | 716 "/wd4481", # Nonstandard extension: override specifier. |
| 728 "/wd4505", # Unreferenced local function has been removed. | 717 "/wd4505", # Unreferenced local function has been removed. |
| 729 "/wd4510", # Default constructor could not be generated. | 718 "/wd4510", # Default constructor could not be generated. |
| 730 "/wd4512", # Assignment operator could not be generated. | 719 "/wd4512", # Assignment operator could not be generated. |
| 731 "/wd4610", # Class can never be instantiated, constructor required. | 720 "/wd4610", # Class can never be instantiated, constructor required. |
| 732 "/wd4996", # Deprecated function warning. | 721 "/wd4996", # Deprecated function warning. |
| 733 ] | 722 ] |
| 734 } else { | 723 } else { |
| 735 # Common GCC warning setup. | 724 # Common GCC warning setup. |
| 736 cflags = [ | 725 cflags = [ |
| 737 # Enables. | 726 # Enables. |
| 738 "-Wendif-labels", # Weird old-style text after an #endif. | 727 "-Wendif-labels", # Weird old-style text after an #endif. |
| 739 "-Werror", # Warnings as errors. | 728 "-Werror", # Warnings as errors. |
| 740 | 729 |
| 741 # Disables. | 730 # Disables. |
| 742 "-Wno-missing-field-initializers", # "struct foo f = {0};" | 731 "-Wno-missing-field-initializers", # "struct foo f = {0};" |
| 743 "-Wno-unused-parameter", # Unused function parameters. | 732 "-Wno-unused-parameter", # Unused function parameters. |
| 744 ] | 733 ] |
| 745 cflags_cc = [] | 734 cflags_cc = [] |
| 746 | 735 |
| 747 if (is_mac) { | 736 if (is_mac) { |
| 748 cflags += [ | 737 cflags += [ "-Wnewline-eof" ] |
| 749 "-Wnewline-eof", | |
| 750 ] | |
| 751 } | 738 } |
| 752 | 739 |
| 753 if (is_clang) { | 740 if (is_clang) { |
| 754 cflags += [ | 741 cflags += [ |
| 755 # This warns on using ints as initializers for floats in | 742 # This warns on using ints as initializers for floats in |
| 756 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), | 743 # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|), |
| 757 # which happens in several places in chrome code. Not sure if | 744 # which happens in several places in chrome code. Not sure if |
| 758 # this is worth fixing. | 745 # this is worth fixing. |
| 759 "-Wno-c++11-narrowing", | 746 "-Wno-c++11-narrowing", |
| 760 | 747 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 778 "-Wno-unneeded-internal-declaration", | 765 "-Wno-unneeded-internal-declaration", |
| 779 | 766 |
| 780 # TODO(thakis): Remove, http://crbug.com/263960 | 767 # TODO(thakis): Remove, http://crbug.com/263960 |
| 781 "-Wno-reserved-user-defined-literal", | 768 "-Wno-reserved-user-defined-literal", |
| 782 ] | 769 ] |
| 783 } | 770 } |
| 784 if (gcc_version >= 48) { | 771 if (gcc_version >= 48) { |
| 785 cflags_cc += [ | 772 cflags_cc += [ |
| 786 # See comment for -Wno-c++11-narrowing. | 773 # See comment for -Wno-c++11-narrowing. |
| 787 "-Wno-narrowing", | 774 "-Wno-narrowing", |
| 775 |
| 788 # TODO(thakis): Remove, http://crbug.com/263960 | 776 # TODO(thakis): Remove, http://crbug.com/263960 |
| 789 "-Wno-literal-suffix", | 777 "-Wno-literal-suffix", |
| 790 ] | 778 ] |
| 791 } | 779 } |
| 792 | 780 |
| 793 # Suppress warnings about ABI changes on ARM (Clang doesn't give this | 781 # Suppress warnings about ABI changes on ARM (Clang doesn't give this |
| 794 # warning). | 782 # warning). |
| 795 if (cpu_arch == "arm" && !is_clang) { | 783 if (cpu_arch == "arm" && !is_clang) { |
| 796 cflags += [ "-Wno-psabi" ] | 784 cflags += [ "-Wno-psabi" ] |
| 797 } | 785 } |
| 798 | 786 |
| 799 if (is_android) { | 787 if (is_android) { |
| 800 # Disable any additional warnings enabled by the Android build system but | 788 # Disable any additional warnings enabled by the Android build system but |
| 801 # which chromium does not build cleanly with (when treating warning as | 789 # which chromium does not build cleanly with (when treating warning as |
| 802 # errors). | 790 # errors). |
| 803 cflags += [ | 791 cflags += [ |
| 804 "-Wno-extra", | 792 "-Wno-extra", |
| 805 "-Wno-ignored-qualifiers", | 793 "-Wno-ignored-qualifiers", |
| 806 "-Wno-type-limits", | 794 "-Wno-type-limits", |
| 807 ] | 795 ] |
| 808 cflags_cc += [ | 796 cflags_cc += [ |
| 809 # Disabling c++0x-compat should be handled in WebKit, but | 797 # Disabling c++0x-compat should be handled in WebKit, but |
| 810 # this currently doesn't work because gcc_version is not set | 798 # this currently doesn't work because gcc_version is not set |
| 811 # correctly when building with the Android build system. | 799 # correctly when building with the Android build system. |
| 812 # TODO(torne): Fix this in WebKit. | 800 # TODO(torne): Fix this in WebKit. |
| 813 "-Wno-error=c++0x-compat", | 801 "-Wno-error=c++0x-compat", |
| 802 |
| 814 # Other things unrelated to -Wextra: | 803 # Other things unrelated to -Wextra: |
| 815 "-Wno-non-virtual-dtor", | 804 "-Wno-non-virtual-dtor", |
| 816 "-Wno-sign-promo", | 805 "-Wno-sign-promo", |
| 817 ] | 806 ] |
| 818 } | 807 } |
| 819 | 808 |
| 820 if (gcc_version >= 48) { | 809 if (gcc_version >= 48) { |
| 821 # Don't warn about the "typedef 'foo' locally defined but not used" | 810 # Don't warn about the "typedef 'foo' locally defined but not used" |
| 822 # for gcc 4.8. | 811 # for gcc 4.8. |
| 823 # TODO: remove this flag once all builds work. See crbug.com/227506 | 812 # TODO: remove this flag once all builds work. See crbug.com/227506 |
| 824 cflags += [ | 813 cflags += [ "-Wno-unused-local-typedefs" ] |
| 825 "-Wno-unused-local-typedefs", | |
| 826 ] | |
| 827 } | 814 } |
| 828 } | 815 } |
| 829 } | 816 } |
| 830 | 817 |
| 831 # This will generate warnings when using Clang if code generates exit-time | 818 # This will generate warnings when using Clang if code generates exit-time |
| 832 # destructors, which will slow down closing the program. | 819 # destructors, which will slow down closing the program. |
| 833 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 | 820 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 |
| 834 config("wexit_time_destructors") { | 821 config("wexit_time_destructors") { |
| 835 if (is_clang) { | 822 if (is_clang) { |
| 836 cflags = [ "-Wexit-time-destructors" ] | 823 cflags = [ "-Wexit-time-destructors" ] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 847 # | 834 # |
| 848 # configs -= default_optimization_config | 835 # configs -= default_optimization_config |
| 849 # configs += [ "//build/config/compiler/optimize_max" ] | 836 # configs += [ "//build/config/compiler/optimize_max" ] |
| 850 | 837 |
| 851 # Shared settings for both "optimize" and "optimize_max" configs. | 838 # Shared settings for both "optimize" and "optimize_max" configs. |
| 852 if (is_win) { | 839 if (is_win) { |
| 853 common_optimize_on_cflags = [ | 840 common_optimize_on_cflags = [ |
| 854 "/O2", | 841 "/O2", |
| 855 "/Ob2", # both explicit and auto inlining. | 842 "/Ob2", # both explicit and auto inlining. |
| 856 "/Oy-", # disable omitting frame pointers, must be after /o2. | 843 "/Oy-", # disable omitting frame pointers, must be after /o2. |
| 857 "/Os", # favor size over speed. | 844 "/Os", # favor size over speed. |
| 858 ] | 845 ] |
| 859 common_optimize_on_ldflags = [] | 846 common_optimize_on_ldflags = [] |
| 860 } else { | 847 } else { |
| 861 common_optimize_on_cflags = [ | 848 common_optimize_on_cflags = [ |
| 862 # Don't emit the GCC version ident directives, they just end up in the | 849 # Don't emit the GCC version ident directives, they just end up in the |
| 863 # .comment section taking up binary size. | 850 # .comment section taking up binary size. |
| 864 "-fno-ident", | 851 "-fno-ident", |
| 852 |
| 865 # Put data and code in their own sections, so that unused symbols | 853 # Put data and code in their own sections, so that unused symbols |
| 866 # can be removed at link time with --gc-sections. | 854 # can be removed at link time with --gc-sections. |
| 867 "-fdata-sections", | 855 "-fdata-sections", |
| 868 "-ffunction-sections", | 856 "-ffunction-sections", |
| 869 ] | 857 ] |
| 870 common_optimize_on_ldflags = [] | 858 common_optimize_on_ldflags = [] |
| 871 | 859 |
| 872 if (is_android) { | 860 if (is_android) { |
| 873 if (!using_sanitizer) { | 861 if (!using_sanitizer) { |
| 874 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] | 862 common_optimize_on_cflags += [ "-fomit-frame-pointer" ] |
| 875 } | 863 } |
| 876 common_optimize_on_ldflags += [ | 864 common_optimize_on_ldflags += [ |
| 877 # Warn in case of text relocations. | 865 # Warn in case of text relocations. |
| 878 "-Wl,--warn-shared-textrel", | 866 "-Wl,--warn-shared-textrel", |
| 879 ] | 867 ] |
| 880 } | 868 } |
| 881 | 869 |
| 882 if (is_mac) { | 870 if (is_mac) { |
| 883 if (symbol_level == 2) { | 871 if (symbol_level == 2) { |
| 884 # Mac dead code stripping requires symbols. | 872 # Mac dead code stripping requires symbols. |
| 885 common_optimize_on_ldflags += [ | 873 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] |
| 886 "-Wl,-dead_strip", | |
| 887 ] | |
| 888 } | 874 } |
| 889 } else { | 875 } else { |
| 890 # Non-Mac Posix linker flags. | 876 # Non-Mac Posix linker flags. |
| 891 common_optimize_on_ldflags += [ | 877 common_optimize_on_ldflags += [ |
| 892 # Specifically tell the linker to perform optimizations. | 878 # Specifically tell the linker to perform optimizations. |
| 893 # See http://lwn.net/Articles/192624/ . | 879 # See http://lwn.net/Articles/192624/ . |
| 894 "-Wl,-O1", | 880 "-Wl,-O1", |
| 895 "-Wl,--as-needed", | 881 "-Wl,--as-needed", |
| 896 "-Wl,--gc-sections", | 882 "-Wl,--gc-sections", |
| 897 ] | 883 ] |
| 898 } | 884 } |
| 899 } | 885 } |
| 900 | 886 |
| 901 # Default "optimization on" config. On Windows, this favors size over speed. | 887 # Default "optimization on" config. On Windows, this favors size over speed. |
| 902 config("optimize") { | 888 config("optimize") { |
| 903 cflags = common_optimize_on_cflags | 889 cflags = common_optimize_on_cflags |
| 904 ldflags = common_optimize_on_ldflags | 890 ldflags = common_optimize_on_ldflags |
| 905 if (is_win) { | 891 if (is_win) { |
| 906 cflags += [ | 892 cflags += [ "/Os" ] # favor size over speed. |
| 907 "/Os", # favor size over speed. | |
| 908 ] | |
| 909 } else if (is_android || is_ios) { | 893 } else if (is_android || is_ios) { |
| 910 cflags += [ | 894 cflags += [ "-Os" ] # Favor size over speed. |
| 911 "-Os", # Favor size over speed. | |
| 912 ] | |
| 913 } else { | 895 } else { |
| 914 cflags += [ | 896 cflags += [ "-O2" ] |
| 915 "-O2", | |
| 916 ] | |
| 917 } | 897 } |
| 918 } | 898 } |
| 919 | 899 |
| 920 # Turn off optimizations. | 900 # Turn off optimizations. |
| 921 config("no_optimize") { | 901 config("no_optimize") { |
| 922 if (is_win) { | 902 if (is_win) { |
| 923 cflags = [ | 903 cflags = [ |
| 924 "/Od", # Disable optimization. | 904 "/Od", # Disable optimization. |
| 925 "/Ob0", # Disable all inlining (on by default). | 905 "/Ob0", # Disable all inlining (on by default). |
| 926 "/RTC1", # Runtime checks for stack frame and uninitialized variables. | 906 "/RTC1", # Runtime checks for stack frame and uninitialized variables. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 942 } | 922 } |
| 943 } | 923 } |
| 944 | 924 |
| 945 # Turns up the optimization level. On Windows, this implies whole program | 925 # Turns up the optimization level. On Windows, this implies whole program |
| 946 # optimization and link-time code generation which is very expensive and should | 926 # optimization and link-time code generation which is very expensive and should |
| 947 # be used sparingly. | 927 # be used sparingly. |
| 948 config("optimize_max") { | 928 config("optimize_max") { |
| 949 cflags = common_optimize_on_cflags | 929 cflags = common_optimize_on_cflags |
| 950 ldflags = common_optimize_on_ldflags | 930 ldflags = common_optimize_on_ldflags |
| 951 if (is_win) { | 931 if (is_win) { |
| 952 cflags -= [ | 932 cflags -= [ "/Os" ] |
| 953 "/Os", | 933 cflags += [ "/Ot" ] # Favor speed over size. |
| 954 ] | |
| 955 cflags += [ | |
| 956 "/Ot", # Favor speed over size. | |
| 957 ] | |
| 958 if (is_official_build) { | 934 if (is_official_build) { |
| 959 # TODO(GYP): TODO(dpranke): Should these only be on in an official | 935 # TODO(GYP): TODO(dpranke): Should these only be on in an official |
| 960 # build, or on all the time? For now we'll require official build so | 936 # build, or on all the time? For now we'll require official build so |
| 961 # that the compile is clean. | 937 # that the compile is clean. |
| 962 cflags += [ | 938 cflags += [ |
| 963 "/GL", # Whole program optimization. | 939 "/GL", # Whole program optimization. |
| 940 |
| 964 # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds. | 941 # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds. |
| 965 # Probably anything that this would catch that wouldn't be caught in a | 942 # Probably anything that this would catch that wouldn't be caught in a |
| 966 # normal build isn't going to actually be a bug, so the incremental | 943 # normal build isn't going to actually be a bug, so the incremental |
| 967 # value of C4702 for PGO builds is likely very small. | 944 # value of C4702 for PGO builds is likely very small. |
| 968 "/wd4702", | 945 "/wd4702", |
| 969 ] | 946 ] |
| 970 ldflags += [ | 947 ldflags += [ "/LTCG" ] |
| 971 "/LTCG", | |
| 972 ] | |
| 973 } | 948 } |
| 974 } else { | 949 } else { |
| 975 cflags += [ | 950 cflags += [ "-O2" ] |
| 976 "-O2", | |
| 977 ] | |
| 978 } | 951 } |
| 979 } | 952 } |
| 980 | 953 |
| 981 # Symbols ---------------------------------------------------------------------- | 954 # Symbols ---------------------------------------------------------------------- |
| 982 | 955 |
| 983 config("symbols") { | 956 config("symbols") { |
| 984 if (is_win) { | 957 if (is_win) { |
| 985 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | 958 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. |
| 986 ldflags = [ "/DEBUG" ] | 959 ldflags = [ "/DEBUG" ] |
| 987 } else { | 960 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1002 cflags += [ "-gsplit-dwarf" ] | 975 cflags += [ "-gsplit-dwarf" ] |
| 1003 } | 976 } |
| 1004 } | 977 } |
| 1005 } | 978 } |
| 1006 | 979 |
| 1007 config("no_symbols") { | 980 config("no_symbols") { |
| 1008 if (!is_win) { | 981 if (!is_win) { |
| 1009 cflags = [ "-g0" ] | 982 cflags = [ "-g0" ] |
| 1010 } | 983 } |
| 1011 } | 984 } |
| OLD | NEW |