| 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 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
| 7 import("//build/config/compiler/compiler.gni") | 7 import("//build/config/compiler/compiler.gni") |
| 8 import("//build/toolchain/ccache.gni") | 8 import("//build/toolchain/ccache.gni") |
| 9 | 9 |
| 10 if (current_cpu == "arm") { | 10 if (current_cpu == "arm") { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (is_win) { | 124 if (is_win) { |
| 125 configs += [ "//build/config/win:compiler" ] | 125 configs += [ "//build/config/win:compiler" ] |
| 126 } else if (is_android) { | 126 } else if (is_android) { |
| 127 configs += [ "//build/config/android:compiler" ] | 127 configs += [ "//build/config/android:compiler" ] |
| 128 } else if (is_linux) { | 128 } else if (is_linux) { |
| 129 configs += [ "//build/config/linux:compiler" ] | 129 configs += [ "//build/config/linux:compiler" ] |
| 130 } else if (is_ios || is_mac) { | 130 } else if (is_ios || is_mac) { |
| 131 configs += [ "//build/config/mac:compiler" ] | 131 configs += [ "//build/config/mac:compiler" ] |
| 132 } | 132 } |
| 133 | 133 |
| 134 # See the definitions below. |
| 135 configs += [ |
| 136 ":compiler_cpu_abi", |
| 137 ":compiler_codegen", |
| 138 ] |
| 139 |
| 134 # In general, Windows is totally different, but all the other builds share | 140 # In general, Windows is totally different, but all the other builds share |
| 135 # some common GCC configuration. | 141 # some common GCC configuration. |
| 136 if (!is_win) { | 142 if (!is_win) { |
| 137 # Common GCC compiler flags setup. | 143 # Common GCC compiler flags setup. |
| 138 # -------------------------------- | 144 # -------------------------------- |
| 139 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 | 145 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 |
| 140 cflags_cc += [ | 146 cflags_cc += [ |
| 141 "-fno-threadsafe-statics", | 147 "-fno-threadsafe-statics", |
| 142 | 148 |
| 143 # Not exporting C++ inline functions can generally be applied anywhere | 149 # Not exporting C++ inline functions can generally be applied anywhere |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 ] | 212 ] |
| 207 | 213 |
| 208 if (enable_full_stack_frames_for_profiling) { | 214 if (enable_full_stack_frames_for_profiling) { |
| 209 cflags += [ | 215 cflags += [ |
| 210 "-fno-inline", | 216 "-fno-inline", |
| 211 "-fno-optimize-sibling-calls", | 217 "-fno-optimize-sibling-calls", |
| 212 ] | 218 ] |
| 213 } | 219 } |
| 214 } | 220 } |
| 215 | 221 |
| 216 # CPU architecture. We may or may not be doing a cross compile now, so for | |
| 217 # simplicity we always explicitly set the architecture. | |
| 218 if (current_cpu == "x64") { | |
| 219 cflags += [ | |
| 220 "-m64", | |
| 221 "-march=x86-64", | |
| 222 ] | |
| 223 ldflags += [ "-m64" ] | |
| 224 } else if (current_cpu == "x86") { | |
| 225 cflags += [ "-m32" ] | |
| 226 ldflags += [ "-m32" ] | |
| 227 if (is_clang) { | |
| 228 cflags += [ | |
| 229 # Else building libyuv gives clang's register allocator issues, | |
| 230 # see llvm.org/PR15798 / crbug.com/233709 | |
| 231 "-momit-leaf-frame-pointer", | |
| 232 | |
| 233 # Align the stack on 16-byte boundaries, http://crbug.com/418554. | |
| 234 "-mstack-alignment=16", | |
| 235 "-mstackrealign", | |
| 236 ] | |
| 237 } | |
| 238 } else if (current_cpu == "arm") { | |
| 239 if (is_clang && !is_android && !is_nacl) { | |
| 240 cflags += [ | |
| 241 "-target", | |
| 242 "arm-linux-gnueabihf", | |
| 243 ] | |
| 244 ldflags += [ | |
| 245 "-target", | |
| 246 "arm-linux-gnueabihf", | |
| 247 ] | |
| 248 | |
| 249 # We need to disable clang's builtin assembler as it can't | |
| 250 # handle several asm files, crbug.com/124610 | |
| 251 cflags += [ "-no-integrated-as" ] | |
| 252 } | |
| 253 if (!is_nacl) { | |
| 254 cflags += [ | |
| 255 "-march=$arm_arch", | |
| 256 "-mfloat-abi=$arm_float_abi", | |
| 257 ] | |
| 258 if (arm_use_thumb) { | |
| 259 cflags += [ "-mthumb" ] | |
| 260 if (is_android && !is_clang) { | |
| 261 # Clang doesn't support this option. | |
| 262 cflags += [ "-mthumb-interwork" ] | |
| 263 } | |
| 264 } | |
| 265 } | |
| 266 if (arm_tune != "") { | |
| 267 cflags += [ "-mtune=$arm_tune" ] | |
| 268 } | |
| 269 if (!is_clang) { | |
| 270 # Clang doesn't support these flags. | |
| 271 cflags += [ | |
| 272 # The tree-sra optimization (scalar replacement for | |
| 273 # aggregates enabling subsequent optimizations) leads to | |
| 274 # invalid code generation when using the Android NDK's | |
| 275 # compiler (r5-r7). This can be verified using | |
| 276 # webkit_unit_tests' WTF.Checked_int8_t test. | |
| 277 "-fno-tree-sra", | |
| 278 | |
| 279 # The following option is disabled to improve binary | |
| 280 # size and performance in gcc 4.9. | |
| 281 "-fno-caller-saves", | |
| 282 ] | |
| 283 } | |
| 284 } else if (current_cpu == "mipsel") { | |
| 285 if (mips_arch_variant == "r6") { | |
| 286 cflags += [ | |
| 287 "-mips32r6", | |
| 288 "-Wa,-mips32r6", | |
| 289 ] | |
| 290 if (is_android) { | |
| 291 ldflags += [ | |
| 292 "-mips32r6", | |
| 293 "-Wl,-melf32ltsmip", | |
| 294 ] | |
| 295 } | |
| 296 } else if (mips_arch_variant == "r2") { | |
| 297 cflags += [ | |
| 298 "-mips32r2", | |
| 299 "-Wa,-mips32r2", | |
| 300 ] | |
| 301 if (mips_float_abi == "hard" && mips_fpu_mode != "") { | |
| 302 cflags += [ "-m$mips_fpu_mode" ] | |
| 303 } | |
| 304 } else if (mips_arch_variant == "r1") { | |
| 305 cflags += [ | |
| 306 "-mips32", | |
| 307 "-Wa,-mips32", | |
| 308 ] | |
| 309 } | |
| 310 | |
| 311 if (mips_dsp_rev == 1) { | |
| 312 cflags += [ "-mdsp" ] | |
| 313 } else if (mips_dsp_rev == 2) { | |
| 314 cflags += [ "-mdspr2" ] | |
| 315 } | |
| 316 | |
| 317 cflags += [ "-m${mips_float_abi}-float" ] | |
| 318 } else if (current_cpu == "mips64el") { | |
| 319 if (mips_arch_variant == "r6") { | |
| 320 cflags += [ | |
| 321 "-mips64r6", | |
| 322 "-Wa,-mips64r6", | |
| 323 ] | |
| 324 ldflags += [ "-mips64r6" ] | |
| 325 } else if (mips_arch_variant == "r2") { | |
| 326 cflags += [ | |
| 327 "-mips64r2", | |
| 328 "-Wa,-mips64r2", | |
| 329 ] | |
| 330 ldflags += [ "-mips64r2" ] | |
| 331 } | |
| 332 } | |
| 333 | |
| 334 defines += [ "_FILE_OFFSET_BITS=64" ] | 222 defines += [ "_FILE_OFFSET_BITS=64" ] |
| 335 | 223 |
| 336 if (!is_android) { | 224 if (!is_android) { |
| 337 defines += [ | 225 defines += [ |
| 338 "_LARGEFILE_SOURCE", | 226 "_LARGEFILE_SOURCE", |
| 339 "_LARGEFILE64_SOURCE", | 227 "_LARGEFILE64_SOURCE", |
| 340 ] | 228 ] |
| 341 } | 229 } |
| 342 | 230 |
| 343 # Omit unwind support in official builds to save space. We can use breakpad | 231 # Omit unwind support in official builds to save space. We can use breakpad |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 327 |
| 440 # Assign any flags set for the C compiler to asmflags so that they are sent | 328 # Assign any flags set for the C compiler to asmflags so that they are sent |
| 441 # to the assembler. The Windows assembler takes different types of flags | 329 # to the assembler. The Windows assembler takes different types of flags |
| 442 # so only do so for posix platforms. | 330 # so only do so for posix platforms. |
| 443 if (is_posix) { | 331 if (is_posix) { |
| 444 asmflags += cflags | 332 asmflags += cflags |
| 445 asmflags += cflags_c | 333 asmflags += cflags_c |
| 446 } | 334 } |
| 447 } | 335 } |
| 448 | 336 |
| 337 # This provides the basic options to select the target CPU and ABI. |
| 338 # It is factored out of "compiler" so that special cases can use this |
| 339 # without using everything that "compiler" brings in. Options that |
| 340 # tweak code generation for a particular CPU do not belong here! |
| 341 # See "compiler_codegen", below. |
| 342 config("compiler_cpu_abi") { |
| 343 cflags = [] |
| 344 ldflags = [] |
| 345 |
| 346 if (is_posix && !(is_mac || is_ios)) { |
| 347 # CPU architecture. We may or may not be doing a cross compile now, so for |
| 348 # simplicity we always explicitly set the architecture. |
| 349 if (current_cpu == "x64") { |
| 350 cflags += [ |
| 351 "-m64", |
| 352 "-march=x86-64", |
| 353 ] |
| 354 ldflags += [ "-m64" ] |
| 355 } else if (current_cpu == "x86") { |
| 356 cflags += [ "-m32" ] |
| 357 ldflags += [ "-m32" ] |
| 358 } else if (current_cpu == "arm") { |
| 359 if (is_clang && !is_android && !is_nacl) { |
| 360 cflags += [ |
| 361 "-target", |
| 362 "arm-linux-gnueabihf", |
| 363 ] |
| 364 ldflags += [ |
| 365 "-target", |
| 366 "arm-linux-gnueabihf", |
| 367 ] |
| 368 } |
| 369 if (!is_nacl) { |
| 370 cflags += [ |
| 371 "-march=$arm_arch", |
| 372 "-mfloat-abi=$arm_float_abi", |
| 373 ] |
| 374 if (arm_use_thumb) { |
| 375 cflags += [ "-mthumb" ] |
| 376 if (is_android && !is_clang) { |
| 377 # Clang doesn't support this option. |
| 378 cflags += [ "-mthumb-interwork" ] |
| 379 } |
| 380 } |
| 381 } |
| 382 if (arm_tune != "") { |
| 383 cflags += [ "-mtune=$arm_tune" ] |
| 384 } |
| 385 } else if (current_cpu == "mipsel") { |
| 386 if (mips_arch_variant == "r6") { |
| 387 cflags += [ |
| 388 "-mips32r6", |
| 389 "-Wa,-mips32r6", |
| 390 ] |
| 391 if (is_android) { |
| 392 ldflags += [ |
| 393 "-mips32r6", |
| 394 "-Wl,-melf32ltsmip", |
| 395 ] |
| 396 } |
| 397 } else if (mips_arch_variant == "r2") { |
| 398 cflags += [ |
| 399 "-mips32r2", |
| 400 "-Wa,-mips32r2", |
| 401 ] |
| 402 if (mips_float_abi == "hard" && mips_fpu_mode != "") { |
| 403 cflags += [ "-m$mips_fpu_mode" ] |
| 404 } |
| 405 } else if (mips_arch_variant == "r1") { |
| 406 cflags += [ |
| 407 "-mips32", |
| 408 "-Wa,-mips32", |
| 409 ] |
| 410 } |
| 411 |
| 412 if (mips_dsp_rev == 1) { |
| 413 cflags += [ "-mdsp" ] |
| 414 } else if (mips_dsp_rev == 2) { |
| 415 cflags += [ "-mdspr2" ] |
| 416 } |
| 417 |
| 418 cflags += [ "-m${mips_float_abi}-float" ] |
| 419 } else if (current_cpu == "mips64el") { |
| 420 if (mips_arch_variant == "r6") { |
| 421 cflags += [ |
| 422 "-mips64r6", |
| 423 "-Wa,-mips64r6", |
| 424 ] |
| 425 ldflags += [ "-mips64r6" ] |
| 426 } else if (mips_arch_variant == "r2") { |
| 427 cflags += [ |
| 428 "-mips64r2", |
| 429 "-Wa,-mips64r2", |
| 430 ] |
| 431 ldflags += [ "-mips64r2" ] |
| 432 } |
| 433 } |
| 434 } |
| 435 |
| 436 asmflags = cflags |
| 437 } |
| 438 |
| 439 # This provides options to tweak code generation that are necessary |
| 440 # for particular Chromium code or for working around particular |
| 441 # compiler bugs (or the combination of the two). |
| 442 config("compiler_codegen") { |
| 443 cflags = [] |
| 444 |
| 445 if (is_posix && !is_mac && !is_ios && !is_nacl) { |
| 446 if (current_cpu == "x86") { |
| 447 if (is_clang) { |
| 448 cflags += [ |
| 449 # Else building libyuv gives clang's register allocator issues, |
| 450 # see llvm.org/PR15798 / crbug.com/233709 |
| 451 "-momit-leaf-frame-pointer", |
| 452 |
| 453 # Align the stack on 16-byte boundaries, http://crbug.com/418554. |
| 454 "-mstack-alignment=16", |
| 455 "-mstackrealign", |
| 456 ] |
| 457 } |
| 458 } else if (current_cpu == "arm") { |
| 459 if (is_clang) { |
| 460 if (!is_android) { |
| 461 # We need to disable clang's builtin assembler as it can't |
| 462 # handle several asm files, crbug.com/124610 |
| 463 cflags += [ "-no-integrated-as" ] |
| 464 } |
| 465 } else { |
| 466 # Clang doesn't support these flags. |
| 467 cflags += [ |
| 468 # The tree-sra optimization (scalar replacement for |
| 469 # aggregates enabling subsequent optimizations) leads to |
| 470 # invalid code generation when using the Android NDK's |
| 471 # compiler (r5-r7). This can be verified using |
| 472 # webkit_unit_tests' WTF.Checked_int8_t test. |
| 473 "-fno-tree-sra", |
| 474 |
| 475 # The following option is disabled to improve binary |
| 476 # size and performance in gcc 4.9. |
| 477 "-fno-caller-saves", |
| 478 ] |
| 479 } |
| 480 } |
| 481 } |
| 482 |
| 483 asmflags = cflags |
| 484 } |
| 485 |
| 449 config("compiler_arm_fpu") { | 486 config("compiler_arm_fpu") { |
| 450 if (current_cpu == "arm" && !is_ios && !is_nacl) { | 487 if (current_cpu == "arm" && !is_ios && !is_nacl) { |
| 451 cflags = [ "-mfpu=$arm_fpu" ] | 488 cflags = [ "-mfpu=$arm_fpu" ] |
| 452 asmflags = cflags | 489 asmflags = cflags |
| 453 } | 490 } |
| 454 } | 491 } |
| 455 | 492 |
| 456 # runtime_library ------------------------------------------------------------- | 493 # runtime_library ------------------------------------------------------------- |
| 457 # | 494 # |
| 458 # Sets the runtime library and associated options. | 495 # Sets the runtime library and associated options. |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 if (symbol_level == 0) { | 1167 if (symbol_level == 0) { |
| 1131 configs = [ ":no_symbols" ] | 1168 configs = [ ":no_symbols" ] |
| 1132 } else if (symbol_level == 1) { | 1169 } else if (symbol_level == 1) { |
| 1133 configs = [ ":minimal_symbols" ] | 1170 configs = [ ":minimal_symbols" ] |
| 1134 } else if (symbol_level == 2) { | 1171 } else if (symbol_level == 2) { |
| 1135 configs = [ ":symbols" ] | 1172 configs = [ ":symbols" ] |
| 1136 } else { | 1173 } else { |
| 1137 assert(false) | 1174 assert(false) |
| 1138 } | 1175 } |
| 1139 } | 1176 } |
| OLD | NEW |