Chromium Code Reviews| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 # where stuff should go. Put warning related stuff in the "warnings" config. | 92 # where stuff should go. Put warning related stuff in the "warnings" config. |
| 93 | 93 |
| 94 config("compiler") { | 94 config("compiler") { |
| 95 cflags = [] | 95 cflags = [] |
| 96 cflags_c = [] | 96 cflags_c = [] |
| 97 cflags_cc = [] | 97 cflags_cc = [] |
| 98 cflags_objc = [] | 98 cflags_objc = [] |
| 99 cflags_objcc = [] | 99 cflags_objcc = [] |
| 100 ldflags = [] | 100 ldflags = [] |
| 101 defines = [] | 101 defines = [] |
| 102 configs = [] | |
| 102 | 103 |
| 103 # In general, Windows is totally different, but all the other builds share | 104 # In general, Windows is totally different, but all the other builds share |
| 104 # some common GCC configuration. This section sets up Windows and the common | 105 # some common GCC configuration. This section sets up Windows and the common |
| 105 # GCC flags, and then we handle the other non-Windows platforms specifically | 106 # GCC flags, and then we handle the other non-Windows platforms specifically |
| 106 # below. | 107 # below. |
| 107 if (is_win) { | 108 if (is_win) { |
| 108 # Windows compiler flags setup. | 109 # Windows compiler flags setup. |
| 109 # ----------------------------- | 110 # ----------------------------- |
| 110 cflags += [ | 111 cflags += [ |
| 111 "/Gy", # Enable function-level linking. | 112 "/Gy", # Enable function-level linking. |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11 | 582 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11 |
| 582 # or c++11; we technically don't need this toolchain any more, but there | 583 # or c++11; we technically don't need this toolchain any more, but there |
| 583 # are still a few buildbots using it, so until those are turned off | 584 # are still a few buildbots using it, so until those are turned off |
| 584 # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above. | 585 # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above. |
| 585 cflags_cc += [ "-std=c++11" ] | 586 cflags_cc += [ "-std=c++11" ] |
| 586 } | 587 } |
| 587 | 588 |
| 588 # Android-specific flags setup. | 589 # Android-specific flags setup. |
| 589 # ----------------------------- | 590 # ----------------------------- |
| 590 if (is_android) { | 591 if (is_android) { |
| 591 cflags += [ | 592 configs += [ "//build/config/android:compiler" ] |
| 592 "-ffunction-sections", | |
| 593 "-funwind-tables", | |
| 594 "-fno-short-enums", | |
| 595 ] | |
| 596 if (!is_clang) { | |
| 597 # Clang doesn't support these flags. | |
| 598 cflags += [ "-finline-limit=64" ] | |
| 599 } | |
| 600 if (is_clang) { | |
| 601 rebased_android_toolchain_root = | |
| 602 rebase_path(android_toolchain_root, root_build_dir) | |
| 603 if (current_cpu == "arm") { | |
| 604 cflags += [ | |
| 605 # TODO(hans) Enable integrated-as (crbug.com/124610). | |
| 606 "-no-integrated-as", | |
| 607 "-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets pi cked up. | |
| 608 ] | |
| 609 } | |
| 610 } | |
| 611 if (is_asan) { | |
| 612 # Android build relies on -Wl,--gc-sections removing unreachable code. | |
| 613 # ASan instrumentation for globals inhibits this and results in a library | |
| 614 # with unresolvable relocations. | |
| 615 # TODO(eugenis): find a way to reenable this. | |
| 616 cflags += [ "-mllvm -asan-globals=0" ] | |
| 617 } | |
| 618 | |
| 619 defines += [ "ANDROID" ] | |
| 620 | |
| 621 # The NDK has these things, but doesn't define the constants | |
| 622 # to say that it does. Define them here instead. | |
| 623 defines += [ "HAVE_SYS_UIO_H" ] | |
| 624 | |
| 625 # Use gold for Android for most CPU architectures. | |
| 626 if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") { | |
| 627 ldflags += [ "-fuse-ld=gold" ] | |
| 628 if (is_clang) { | |
| 629 # Let clang find the ld.gold in the NDK. | |
| 630 ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ] | |
| 631 } | |
| 632 | |
| 633 # Use -mstackrealign due to a bug on ia32 Jelly Bean. | |
| 634 # See crbug.com/521527 | |
| 635 if (current_cpu == "x86") { | |
| 636 cflags += [ "-mstackrealign" ] | |
| 637 } | |
| 638 } | |
| 639 | |
| 640 ldflags += [ | |
| 641 "-Wl,--no-undefined", | |
| 642 | |
| 643 # Don't allow visible symbols from libgcc or libc++ to be | |
| 644 # re-exported. | |
| 645 "-Wl,--exclude-libs=libgcc.a", | |
| 646 "-Wl,--exclude-libs=libc++_static.a", | |
| 647 | |
| 648 # Don't allow visible symbols from libraries that contain | |
| 649 # assembly code with symbols that aren't hidden properly. | |
| 650 # http://crbug.com/448386 | |
| 651 "-Wl,--exclude-libs=libvpx_assembly_arm.a", | |
| 652 ] | |
| 653 if (current_cpu == "arm") { | |
| 654 ldflags += [ | |
| 655 # Enable identical code folding to reduce size. | |
| 656 "-Wl,--icf=safe", | |
| 657 ] | |
| 658 } | |
| 659 | |
| 660 if (is_clang) { | |
| 661 if (current_cpu == "arm") { | |
| 662 _abi_target = "arm-linux-androideabi" | |
| 663 } else if (current_cpu == "x86") { | |
| 664 _abi_target = "i686-linux-androideabi" | |
| 665 } else if (current_cpu == "arm64") { | |
| 666 # Place holder for arm64 support, not tested. | |
| 667 _abi_target = "aarch64-linux-androideabi" | |
| 668 } else if (current_cpu == "x64") { | |
| 669 # Place holder for x64 support, not tested. | |
| 670 # TODO: Enable clang support for Android x64. http://crbug.com/346626 | |
| 671 _abi_target = "x86_64-linux-androideabi" | |
| 672 } else if (current_cpu == "mipsel") { | |
| 673 # Place holder for mips support, not tested. | |
| 674 _abi_target = "mipsel-linux-androideabi" | |
| 675 } else if (current_cpu == "mips64el") { | |
| 676 # Place holder for mips64 support, not tested. | |
| 677 _abi_target = "mips64el-linux-androideabi" | |
| 678 } else { | |
| 679 assert(false, "Architecture not supported") | |
| 680 } | |
| 681 cflags += [ | |
| 682 "-target", | |
| 683 _abi_target, | |
| 684 ] | |
| 685 ldflags += [ | |
| 686 "-target", | |
| 687 _abi_target, | |
| 688 ] | |
| 689 } | |
| 690 } | 593 } |
| 691 | 594 |
| 692 # Pass the same C/C++ flags to the objective C/C++ compiler. | 595 # Pass the same C/C++ flags to the objective C/C++ compiler. |
| 693 cflags_objc += cflags_c | 596 cflags_objc += cflags_c |
| 694 cflags_objcc += cflags_cc | 597 cflags_objcc += cflags_cc |
| 695 } | 598 } |
| 696 | 599 |
| 697 config("compiler_arm_fpu") { | 600 config("compiler_arm_fpu") { |
| 698 if (current_cpu == "arm" && !is_ios && !is_nacl) { | 601 if (current_cpu == "arm" && !is_ios && !is_nacl) { |
| 699 cflags = [ "-mfpu=$arm_fpu" ] | 602 cflags = [ "-mfpu=$arm_fpu" ] |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 | 1207 |
| 1305 if (!using_sanitizer) { | 1208 if (!using_sanitizer) { |
| 1306 # Functions interposed by the sanitizers can make ld think | 1209 # Functions interposed by the sanitizers can make ld think |
| 1307 # that some libraries aren't needed when they actually are, | 1210 # that some libraries aren't needed when they actually are, |
| 1308 # http://crbug.com/234010. As workaround, disable --as-needed. | 1211 # http://crbug.com/234010. As workaround, disable --as-needed. |
| 1309 common_optimize_on_ldflags += [ "-Wl,--as-needed" ] | 1212 common_optimize_on_ldflags += [ "-Wl,--as-needed" ] |
| 1310 } | 1213 } |
| 1311 } | 1214 } |
| 1312 } | 1215 } |
| 1313 | 1216 |
| 1314 # Default "optimization on" config. Set up variables so the | 1217 # Default "optimization on" config. |
| 1315 # "default_optimization" config can re-use these settings. | |
| 1316 if (is_win) { | |
| 1317 # Favor size over speed, /O1 must be before the common flags. The GYP | |
| 1318 # build also specifies /Os and /GF but these are implied by /O1. | |
| 1319 optimize_cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ] | |
| 1320 } else if (is_android || is_ios) { | |
| 1321 # Favor size over speed. | |
| 1322 optimize_cflags = [ "-Os" ] + common_optimize_on_cflags | |
| 1323 } else { | |
| 1324 # Linux & Mac favor speed over size. | |
| 1325 # TODO(brettw) it's weird that Mac and desktop Linux are different. We should | |
| 1326 # explore favoring size over speed in this case as well. | |
| 1327 optimize_cflags = [ "-O2" ] + common_optimize_on_cflags | |
| 1328 } | |
| 1329 optimize_ldflags = common_optimize_on_ldflags | |
| 1330 | |
| 1331 config("optimize") { | 1218 config("optimize") { |
| 1332 cflags = optimize_cflags | 1219 if (is_win) { |
| 1333 ldflags = optimize_ldflags | 1220 # Favor size over speed, /O1 must be before the common flags. The GYP |
| 1221 # build also specifies /Os and /GF but these are implied by /O1. | |
| 1222 cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ] | |
| 1223 } else if (is_android || is_ios) { | |
| 1224 # Favor size over speed. | |
| 1225 cflags = [ "-Os" ] + common_optimize_on_cflags | |
| 1226 } else { | |
| 1227 # Linux & Mac favor speed over size. | |
| 1228 # TODO(brettw) it's weird that Mac and desktop Linux are different. We shoul d | |
| 1229 # explore favoring size over speed in this case as well. | |
| 1230 cflags = [ "-O2" ] + common_optimize_on_cflags | |
| 1231 } | |
| 1232 ldflags = common_optimize_on_ldflags | |
| 1334 } | 1233 } |
| 1335 | 1234 |
| 1336 # Turn off optimizations. Set up variables so the | 1235 # Turn off optimizations. |
| 1337 # "default_optimization" config can re-use these settings. | 1236 config("no_optimize") { |
| 1338 if (is_win) { | 1237 if (is_win) { |
| 1339 no_optimize_cflags = [ | 1238 cflags = [ |
| 1340 "/Od", # Disable optimization. | 1239 "/Od", # Disable optimization. |
| 1341 "/Ob0", # Disable all inlining (on by default). | 1240 "/Ob0", # Disable all inlining (on by default). |
| 1342 "/RTC1", # Runtime checks for stack frame and uninitialized variables. | 1241 "/RTC1", # Runtime checks for stack frame and uninitialized variables. |
| 1343 ] | 1242 ] |
| 1344 no_optimize_ldflags = [] | 1243 } else if (is_android && !android_full_debug) { |
| 1345 } else if (is_android && !android_full_debug) { | 1244 # On Android we kind of optimize some things that don't affect debugging |
| 1346 # On Android we kind of optimize some things that don't affect debugging | 1245 # much even when optimization is disabled to get the binary size down. |
| 1347 # much even when optimization is disabled to get the binary size down. | 1246 cflags = [ |
| 1348 no_optimize_cflags = [ | 1247 "-Os", |
| 1349 "-Os", | 1248 "-fdata-sections", |
| 1350 "-fdata-sections", | 1249 "-ffunction-sections", |
| 1351 "-ffunction-sections", | 1250 ] |
| 1352 ] | 1251 if (!using_sanitizer) { |
| 1353 if (!using_sanitizer) { | 1252 cflags += [ "-fomit-frame-pointer" ] |
| 1354 no_optimize_cflags += [ "-fomit-frame-pointer" ] | 1253 } |
| 1254 ldflags = common_optimize_on_ldflags | |
| 1255 } else { | |
| 1256 cflags = [ "-O0" ] | |
| 1257 ldflags = [] | |
| 1355 } | 1258 } |
| 1356 no_optimize_ldflags = common_optimize_on_ldflags | |
| 1357 } else { | |
| 1358 no_optimize_cflags = [ "-O0" ] | |
| 1359 no_optimize_ldflags = [] | |
| 1360 } | |
| 1361 | |
| 1362 config("no_optimize") { | |
| 1363 cflags = no_optimize_cflags | |
| 1364 ldflags = no_optimize_ldflags | |
| 1365 } | 1259 } |
| 1366 | 1260 |
| 1367 # Turns up the optimization level. On Windows, this implies whole program | 1261 # Turns up the optimization level. On Windows, this implies whole program |
| 1368 # optimization and link-time code generation which is very expensive and should | 1262 # optimization and link-time code generation which is very expensive and should |
| 1369 # be used sparingly. | 1263 # be used sparingly. |
| 1370 config("optimize_max") { | 1264 config("optimize_max") { |
| 1371 ldflags = common_optimize_on_ldflags | 1265 ldflags = common_optimize_on_ldflags |
| 1372 if (is_win) { | 1266 if (is_win) { |
| 1373 # Favor speed over size, /O2 must be before the common flags. The GYP | 1267 # Favor speed over size, /O2 must be before the common flags. The GYP |
| 1374 # build also specifies /Ot, /Oi, and /GF, but these are implied by /O2. | 1268 # build also specifies /Ot, /Oi, and /GF, but these are implied by /O2. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1389 } | 1283 } |
| 1390 } else { | 1284 } else { |
| 1391 cflags = [ "-O2" ] + common_optimize_on_cflags | 1285 cflags = [ "-O2" ] + common_optimize_on_cflags |
| 1392 } | 1286 } |
| 1393 } | 1287 } |
| 1394 | 1288 |
| 1395 # The default optimization applied to all targets. This will be equivalent to | 1289 # The default optimization applied to all targets. This will be equivalent to |
| 1396 # either "optimize" or "no_optimize", depending on the build flags. | 1290 # either "optimize" or "no_optimize", depending on the build flags. |
| 1397 config("default_optimization") { | 1291 config("default_optimization") { |
| 1398 if (is_debug) { | 1292 if (is_debug) { |
| 1399 cflags = no_optimize_cflags | 1293 configs = [ ":no_optimize" ] |
| 1400 ldflags = no_optimize_ldflags | |
| 1401 } else { | 1294 } else { |
| 1402 cflags = optimize_cflags | 1295 configs = [ ":optimize" ] |
| 1403 ldflags = optimize_ldflags | |
| 1404 } | 1296 } |
| 1405 } | 1297 } |
| 1406 | 1298 |
| 1407 # Symbols ---------------------------------------------------------------------- | 1299 # Symbols ---------------------------------------------------------------------- |
| 1408 | 1300 |
| 1409 # The BUILDCONFIG file sets the "default_symbols" config on targets by | 1301 # The BUILDCONFIG file sets the "default_symbols" config on targets by |
| 1410 # default. It will be equivalent to one the three specific symbol levels. | 1302 # default. It will be equivalent to one the three specific symbol levels. |
| 1411 # | 1303 # |
| 1412 # You can override the symbol level on a per-target basis by removing the | 1304 # You can override the symbol level on a per-target basis by removing the |
| 1413 # default config and then adding the named one you want: | 1305 # default config and then adding the named one you want: |
| 1414 # | 1306 # |
| 1415 # configs -= [ "//build/config/compiler:default_symbols" ] | 1307 # configs -= [ "//build/config/compiler:default_symbols" ] |
| 1416 # configs += [ "//build/config/compiler:symbols" ] | 1308 # configs += [ "//build/config/compiler:symbols" ] |
| 1417 | 1309 |
| 1418 # Full symbols. | 1310 # Full symbols. |
| 1419 if (is_win) { | 1311 config("symbols") { |
|
Dirk Pranke
2015/09/16 21:07:31
nit: I wonder if this would be better named as "fu
brettw
2015/09/16 21:34:32
I'm not opposed to renaming it but it's in like 5
| |
| 1420 import("//build/toolchain/goma.gni") | 1312 if (is_win) { |
| 1421 if (use_goma) { | 1313 import("//build/toolchain/goma.gni") |
| 1422 symbols_cflags = [ "/Z7" ] # No PDB file | 1314 if (use_goma) { |
| 1315 cflags = [ "/Z7" ] # No PDB file | |
| 1316 } else { | |
| 1317 cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | |
| 1318 } | |
| 1319 if (is_win_fastlink) { | |
| 1320 # Tell VS 2015+ to create a PDB that references debug | |
| 1321 # information in .obj and .lib files instead of copying | |
| 1322 # it all. This flag is incompatible with /PROFILE | |
| 1323 ldflags = [ "/DEBUG:FASTLINK" ] | |
| 1324 } else { | |
| 1325 ldflags = [ "/DEBUG" ] | |
| 1326 } | |
| 1423 } else { | 1327 } else { |
| 1424 symbols_cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. | 1328 cflags = [ "-g2" ] |
| 1329 if (use_debug_fission) { | |
| 1330 cflags += [ "-gsplit-dwarf" ] | |
| 1331 } | |
| 1332 ldflags = [] | |
| 1425 } | 1333 } |
| 1426 if (is_win_fastlink) { | |
| 1427 # Tell VS 2015+ to create a PDB that references debug | |
| 1428 # information in .obj and .lib files instead of copying | |
| 1429 # it all. This flag is incompatible with /PROFILE | |
| 1430 symbols_ldflags = [ "/DEBUG:FASTLINK" ] | |
| 1431 } else { | |
| 1432 symbols_ldflags = [ "/DEBUG" ] | |
| 1433 } | |
| 1434 } else { | |
| 1435 symbols_cflags = [ "-g2" ] | |
| 1436 if (use_debug_fission) { | |
| 1437 symbols_cflags += [ "-gsplit-dwarf" ] | |
| 1438 } | |
| 1439 symbols_ldflags = [] | |
| 1440 } | |
| 1441 | |
| 1442 config("symbols") { | |
| 1443 cflags = symbols_cflags | |
| 1444 ldflags = symbols_ldflags | |
| 1445 } | 1334 } |
| 1446 | 1335 |
| 1447 # Minimal symbols. | 1336 # Minimal symbols. |
| 1448 if (is_win) { | 1337 config("minimal_symbols") { |
| 1449 # Linker symbols for backtraces only. | 1338 if (is_win) { |
| 1450 minimal_symbols_cflags = [] | 1339 # Linker symbols for backtraces only. |
| 1451 if (is_win_fastlink) { | 1340 cflags = [] |
| 1452 # Tell VS 2015+ to create a PDB that references debug | 1341 if (is_win_fastlink) { |
| 1453 # information in .obj and .lib files instead of copying | 1342 # Tell VS 2015+ to create a PDB that references debug |
| 1454 # it all. This flag is incompatible with /PROFILE | 1343 # information in .obj and .lib files instead of copying |
| 1455 minimal_symbols_ldflags = [ "/DEBUG:FASTLINK" ] | 1344 # it all. This flag is incompatible with /PROFILE |
| 1345 ldflags = [ "/DEBUG:FASTLINK" ] | |
| 1346 } else { | |
| 1347 ldflags = [ "/DEBUG" ] | |
| 1348 } | |
| 1456 } else { | 1349 } else { |
| 1457 minimal_symbols_ldflags = [ "/DEBUG" ] | 1350 cflags = [ "-g1" ] |
| 1351 if (use_debug_fission) { | |
| 1352 cflags += [ "-gsplit-dwarf" ] | |
| 1353 } | |
| 1354 ldflags = [] | |
| 1458 } | 1355 } |
| 1459 } else { | |
| 1460 minimal_symbols_cflags = [ "-g1" ] | |
| 1461 if (use_debug_fission) { | |
| 1462 minimal_symbols_cflags += [ "-gsplit-dwarf" ] | |
| 1463 } | |
| 1464 minimal_symbols_ldflags = [] | |
| 1465 } | |
| 1466 | |
| 1467 config("minimal_symbols") { | |
| 1468 cflags = minimal_symbols_cflags | |
| 1469 ldflags = minimal_symbols_ldflags | |
| 1470 } | 1356 } |
| 1471 | 1357 |
| 1472 # No symbols. | 1358 # No symbols. |
| 1473 if (is_win) { | |
| 1474 no_symbols_cflags = [] | |
| 1475 } else { | |
| 1476 no_symbols_cflags = [ "-g0" ] | |
| 1477 } | |
| 1478 | |
| 1479 config("no_symbols") { | 1359 config("no_symbols") { |
| 1480 cflags = no_symbols_cflags | 1360 if (!is_win) { |
| 1361 cflags = [ "-g0" ] | |
| 1362 } | |
| 1481 } | 1363 } |
| 1482 | 1364 |
| 1483 # Default symbols. | 1365 # Default symbols. |
| 1484 config("default_symbols") { | 1366 config("default_symbols") { |
| 1485 if (symbol_level == 0) { | 1367 if (symbol_level == 0) { |
| 1486 cflags = no_symbols_cflags | 1368 configs = [ ":no_symbols" ] |
| 1487 } else if (symbol_level == 1) { | 1369 } else if (symbol_level == 1) { |
| 1488 cflags = minimal_symbols_cflags | 1370 configs = [ ":minimal_symbols" ] |
| 1489 ldflags = minimal_symbols_ldflags | |
| 1490 } else if (symbol_level == 2) { | 1371 } else if (symbol_level == 2) { |
| 1491 cflags = symbols_cflags | 1372 configs = [ ":symbols" ] |
| 1492 ldflags = symbols_ldflags | |
| 1493 } else { | 1373 } else { |
| 1494 assert(false) | 1374 assert(false) |
| 1495 } | 1375 } |
| 1496 } | 1376 } |
| OLD | NEW |