1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@depends(build_project)
def js_standalone(build_project):
if build_project == "js":
return True
# Debug (see Bug 939505)
# ==============================================================
set_define("JS_DEBUG", True, when=moz_debug)
# Branding
# ==============================================================
option(
"--with-app-name",
env="MOZ_APP_NAME",
nargs=1,
help="Used for e.g. the binary program file name. If not set, "
"defaults to a lowercase form of MOZ_APP_BASENAME.",
)
@depends("--with-app-name", js_standalone, moz_app_basename)
def moz_app_name(value, js_standalone, moz_app_basename):
if value:
return value[0]
if js_standalone:
return "js"
return moz_app_basename.lower()
set_config("MOZ_APP_NAME", moz_app_name)
# SmooshMonkey (new frontend)
# ==================================================
# Define here in order to use the option from bindgen.configure.
option(
"--enable-smoosh",
default=False,
help="Enable SmooshMonkey (new JS engine frontend)",
)
@depends("--enable-smoosh")
def enable_smoosh(value):
if value:
return True
set_config("JS_ENABLE_SMOOSH", enable_smoosh)
set_define("JS_ENABLE_SMOOSH", enable_smoosh)
include("../build/moz.configure/nspr.configure", when="--enable-compile-environment")
include("../build/moz.configure/rust.configure", when="--enable-compile-environment")
include("../build/moz.configure/bindgen.configure", when="--enable-compile-environment")
set_config("JS_STANDALONE", js_standalone)
set_define("JS_STANDALONE", js_standalone)
add_old_configure_assignment("JS_STANDALONE", js_standalone)
option(
"--enable-js-shell", default=js_standalone, help="{Build|Do not build} the JS shell"
)
@depends("--enable-js-shell")
def js_disable_shell(value):
if not value:
return True
set_config("JS_DISABLE_SHELL", js_disable_shell)
set_define("JS_64BIT", depends(target)(lambda t: t.bitness == 64 or None))
set_define("JS_PUNBOX64", depends(target)(lambda t: t.bitness == 64 or None))
set_define("JS_NUNBOX32", depends(target)(lambda t: t.bitness == 32 or None))
# SpiderMonkey as a shared library, and how its symbols are exported
# ==================================================================
option(
"--disable-shared-js",
when=js_standalone,
help="{Create|Do not create} a shared library",
)
option(
"--disable-export-js",
when=js_standalone,
help="{Mark|Do not mark} JS symbols as DLL exported/visible",
)
@depends("--disable-shared-js", "--disable-export-js", when=js_standalone)
def shared_js(shared_js, export_js):
if shared_js:
if not export_js:
die("Must export JS symbols when building a shared library.")
return True
set_config("JS_SHARED_LIBRARY", shared_js)
@depends(shared_js, "--disable-export-js", when=js_standalone)
def exportable_js_api(shared_js, export_js):
if not shared_js and export_js:
return True
set_define("STATIC_EXPORTABLE_JS_API", exportable_js_api)
@depends(shared_js, exportable_js_api)
def static_js_api(shared_js, export_js):
if not shared_js and not export_js:
return True
set_define("STATIC_JS_API", static_js_api)
@depends(shared_js)
def static_js(value):
if not value:
return True
set_define("MOZ_STATIC_JS", static_js)
# Enable records and tuples
# ===================================================
option(
"--enable-record-tuple",
default=False,
help="Enable records and tuples (and disables JIT)",
)
@depends("--enable-record-tuple")
def enable_record_tuple(value):
if value:
return True
set_config("ENABLE_RECORD_TUPLE", enable_record_tuple)
set_define("ENABLE_RECORD_TUPLE", enable_record_tuple)
# Enable decorators
# ===================================================
option(
"--enable-decorators",
default=False,
help="Enable experimental JS Decorators support",
)
@depends("--enable-decorators")
def enable_decorators(value):
if value:
return True
set_config("ENABLE_DECORATORS", enable_decorators)
set_define("ENABLE_DECORATORS", enable_decorators)
# Enable JSON.parse with source
# ===================================================
@depends(milestone.is_nightly)
def enable_json_parse_with_source(is_nightly):
if is_nightly:
return True
set_config("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
set_define("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
# Portable Baseline Intepreter
# =======================================================
option(
"--enable-portable-baseline-interp",
default=False,
help="{Enable|Disable} the portable baseline interpreter.",
)
set_define(
"ENABLE_PORTABLE_BASELINE_INTERP",
depends_if("--enable-portable-baseline-interp")(lambda _: True),
)
set_config(
"ENABLE_PORTABLE_BASELINE_INTERP",
depends_if("--enable-portable-baseline-interp")(lambda _: True),
)
# Option to always force PBL tier.
option(
"--enable-portable-baseline-interp-force",
default=False,
help="{Enable|Disable} forcing use of the portable baseline interpreter.",
)
set_define(
"ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
)
set_config(
"ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
)
# JIT support
# =======================================================
@depends(target, "--enable-record-tuple", "--enable-portable-baseline-interp")
def jit_default(target, enable_record_tuple, enable_portable_baseline_interp):
if enable_record_tuple:
return False
if enable_portable_baseline_interp:
return False
if target.cpu in (
"x86",
"x86_64",
"arm",
"aarch64",
"mips32",
"mips64",
"loongarch64",
):
return True
return False
option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
@deprecated_option("--enable-ion")
def report_deprecated(value):
if value:
die("--enable-ion is deprecated, use --enable-jit instead")
else:
die("--disable-ion is deprecated, use --disable-jit instead")
# JIT code simulator for cross compiles
# =======================================================
option(
"--enable-simulator",
choices=("arm", "arm64", "mips32", "mips64", "loong64", "riscv64"),
nargs=1,
help="Enable a JIT code simulator for the specified architecture",
)
@depends("--enable-jit", "--enable-simulator", target)
def simulator(jit_enabled, simulator_enabled, target):
if not jit_enabled or not simulator_enabled:
return
sim_cpu = simulator_enabled[0]
if sim_cpu in ("arm", "mips32"):
if target.cpu != "x86":
die("The %s simulator only works on x86." % sim_cpu)
if sim_cpu in ("arm64", "mips64", "loong64", "riscv64"):
if target.cpu != "x86_64" and target.cpu != "aarch64":
die("The %s simulator only works on x86-64 or arm64." % sim_cpu)
return namespace(**{sim_cpu: True})
set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
set_config("JS_SIMULATOR_ARM", simulator.arm)
set_config("JS_SIMULATOR_ARM64", simulator.arm64)
set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
set_config("JS_SIMULATOR_LOONG64", simulator.loong64)
set_config("JS_SIMULATOR_RISCV64", simulator.riscv64)
set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
set_define("JS_SIMULATOR_ARM", simulator.arm)
set_define("JS_SIMULATOR_ARM64", simulator.arm64)
set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
set_define("JS_SIMULATOR_LOONG64", simulator.loong64)
set_define("JS_SIMULATOR_RISCV64", simulator.riscv64)
@depends("--enable-jit", simulator, target)
def jit_codegen(jit_enabled, simulator, target):
if not jit_enabled:
return namespace(none=True)
if simulator:
return simulator
if target.cpu == "aarch64":
return namespace(arm64=True)
elif target.cpu == "x86_64":
return namespace(x64=True)
elif target.cpu == "loongarch64":
return namespace(loong64=True)
elif target.cpu == "riscv64":
return namespace(riscv64=True)
return namespace(**{str(target.cpu): True})
set_config("JS_CODEGEN_NONE", jit_codegen.none)
set_config("JS_CODEGEN_ARM", jit_codegen.arm)
set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
set_config("JS_CODEGEN_LOONG64", jit_codegen.loong64)
set_config("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
set_config("JS_CODEGEN_X86", jit_codegen.x86)
set_config("JS_CODEGEN_X64", jit_codegen.x64)
set_config("JS_CODEGEN_WASM32", jit_codegen.wasm32)
set_define("JS_CODEGEN_NONE", jit_codegen.none)
set_define("JS_CODEGEN_ARM", jit_codegen.arm)
set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
set_define("JS_CODEGEN_LOONG64", jit_codegen.loong64)
set_define("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
set_define("JS_CODEGEN_X86", jit_codegen.x86)
set_define("JS_CODEGEN_X64", jit_codegen.x64)
set_define("JS_CODEGEN_WASM32", jit_codegen.wasm32)
# Profiling
# =======================================================
option(
"--enable-instruments",
env="MOZ_INSTRUMENTS",
help="Enable instruments remote profiling",
)
@depends("--enable-instruments", target)
def instruments(value, target):
if value and target.os != "OSX":
die("--enable-instruments cannot be used when targeting %s", target.os)
if value:
return True
set_config("MOZ_INSTRUMENTS", instruments)
set_define("MOZ_INSTRUMENTS", instruments)
add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
imply_option("--enable-profiling", instruments, reason="--enable-instruments")
option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
@depends("--enable-callgrind")
def callgrind(value):
if value:
return True
set_define("MOZ_CALLGRIND", callgrind)
imply_option("--enable-profiling", callgrind)
@depends(milestone)
def enable_profiling(milestone):
return milestone.is_nightly
option(
"--enable-profiling",
env="MOZ_PROFILING",
default=enable_profiling,
help="{Set|Do not set} compile flags necessary for using sampling "
"profilers (e.g. shark, perf)",
)
@depends("--enable-profiling")
def profiling(value):
if value:
return True
with only_when("--enable-compile-environment"):
imply_option("--enable-frame-pointers", True, when=profiling)
@depends(profiling, target)
def imply_vtune(value, target):
ok_cpu = target.cpu in ["x86", "x86_64"]
ok_kernel = target.kernel == "WINNT" or (
target.kernel == "Linux" and target.os == "GNU"
)
if value and ok_cpu and ok_kernel:
return True
set_config("MOZ_PROFILING", profiling)
set_define("MOZ_PROFILING", profiling)
imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
@depends("--enable-vtune")
def vtune(value):
if value:
return True
set_config("MOZ_VTUNE", vtune)
set_define("MOZ_VTUNE", vtune)
option(
"--enable-gc-probes",
env="JS_GC_PROBES",
help="Turn on probes for allocation and finalization",
)
@depends("--enable-gc-probes")
def gc_probes(value):
if value:
return True
set_define("JS_GC_PROBES", gc_probes)
option(
"--enable-gczeal",
default=depends(when=moz_debug)(lambda: True),
help="{Enable|Disable} zealous GCing",
)
set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
# Enable breakpoint for artificial OOMs
# =======================================================
option(
"--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
)
set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
@depends("--enable-perf", target)
def ion_perf(value, target):
is_linux = target.kernel == "Linux"
is_mac = target.kernel == "Darwin" and target.os == "OSX"
if value and (is_linux or is_mac):
return True
set_define("JS_ION_PERF", ion_perf)
option(
"--enable-jitspew",
default=depends(when=moz_debug)(lambda: True),
help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
)
set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
# Also enable the structured spewer
set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
@depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
if not jit_enabled:
return
if simulator and (debug or spew):
if getattr(simulator, "arm", None):
return True
if target.cpu == "arm" and (debug or spew):
return True
set_config("JS_DISASM_ARM", jit_disasm_arm)
set_define("JS_DISASM_ARM", jit_disasm_arm)
@depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
def jit_disasm_riscv(jit_enabled, spew, simulator, target, debug):
if not jit_enabled:
return
if simulator and (debug or spew):
if getattr(simulator, "riscv64", None):
return True
if target.cpu == "riscv64" and (debug or spew):
return True
set_config("JS_DISASM_RISCV64", jit_disasm_riscv)
set_define("JS_DISASM_RISCV64", jit_disasm_riscv)
@depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
if not jit_enabled:
return
if simulator and (debug or spew):
if getattr(simulator, "arm64", None):
return True
if target.cpu == "aarch64" and (debug or spew):
return True
set_config("JS_DISASM_ARM64", jit_disasm_arm64)
set_define("JS_DISASM_ARM64", jit_disasm_arm64)
# When enabled, masm will generate assumeUnreachable calls that act as
# assertions in the generated code. This option is worth disabling when you
# have to track mutated values through the generated code, to avoid constantly
# dumping registers on and off the stack.
option(
"--enable-masm-verbose",
default=depends(when=moz_debug)(lambda: True),
help="{Enable|Disable} MacroAssembler verbosity of generated code.",
)
set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
# Architecture feature flags
# =======================================================
# Apple silicon does not seem to have any way to query the OS for the JSCVT
# flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
# hard code the value of the JSCVT flag which guards the implementation of
# FJCVTZS instruction as part of ARMv8.3-JSConv.
@depends(target)
def is_apple_silicon(target):
return target.kernel == "Darwin" and target.cpu == "aarch64"
option(
"--enable-arm64-fjcvtzs",
default=is_apple_silicon,
help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
)
# The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
# being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
# (D12.1.4).
#
# The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
@depends("--enable-arm64-fjcvtzs", target, simulator)
def aarch64_jscvt(fjcvtzs, target, simulator):
if target.cpu == "aarch64" and fjcvtzs:
return 1
if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
return 1
return 0
set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
@depends(target)
def has_apple_fast_wx(target):
return target.kernel == "Darwin" and target.cpu == "aarch64"
# On Apple Silicon macOS we use MAP_JIT with pthread_jit_write_protect_np to
# implement JIT code write protection, while on iOS we use MAP_JIT with
# be_memory_inline_jit_restrict_*.
set_define("JS_USE_APPLE_FAST_WX", True, when=has_apple_fast_wx)
# CTypes
# =======================================================
@depends(js_standalone)
def ctypes_default(js_standalone):
return not js_standalone
option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
set_config("BUILD_CTYPES", build_ctypes)
set_define("BUILD_CTYPES", build_ctypes)
set_config("JS_HAS_CTYPES", build_ctypes)
set_define("JS_HAS_CTYPES", build_ctypes)
@depends("--enable-ctypes", "--enable-compile-environment")
def ctypes_and_compile_environment(ctypes, compile_environment):
return ctypes and compile_environment
include("ffi.configure", when=ctypes_and_compile_environment)
# Enable pipeline operator
# ===================================================
option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
@depends("--enable-pipeline-operator")
def enable_pipeline_operator(value):
if value:
return True
set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
# SIMD acceleration for encoding_rs
# ==============================================================
option(
"--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
)
@depends("--enable-rust-simd", target)
def rust_simd(value, target):
# As of 2019-09-17, the simd-accel feature of encoding_rs has not
# been properly set up outside aarch64, armv7, x86 and x86_64.
if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
return True
set_config("MOZ_RUST_SIMD", rust_simd)
set_define("MOZ_RUST_SIMD", rust_simd)
# Telemetry to measure compile time and generated-code runtime
# ============================================================
option(
"--enable-spidermonkey-telemetry",
default=milestone.is_nightly,
help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
)
set_define(
"ENABLE_SPIDERMONKEY_TELEMETRY",
depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
)
# Support for debugging code generated by wasm backends
# =====================================================
option(
"--enable-wasm-codegen-debug",
default=depends(when=moz_debug)(lambda: True),
help="{Enable|Disable} debugging for wasm codegen",
)
set_config(
"WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
)
set_define(
"WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
)
# WebAssembly feature flags
# ==================================================
option(
"--wasm-no-experimental",
default=False,
help="Force disable all wasm experimental features for testing.",
)
# Support for WebAssembly tail-calls.
# ===========================
@depends(target)
def default_wasm_tail_calls(target):
if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
return True
option(
"--enable-wasm-tail-calls",
default=default_wasm_tail_calls,
help="{Enable|Disable} WebAssembly tail-calls",
)
@depends("--enable-wasm-tail-calls", target)
def wasm_tail_calls(value, target):
if not value:
return
if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
return True
die(
"--enable-wasm-tail-calls only possible when targeting the x86_64/x86/arm64/arm/loongarch64/mips64 jits"
)
set_config("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
set_define("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
# Support for WebAssembly GC.
# ===========================
option("--disable-wasm-gc", default=True, help="{Enable|Disable} WebAssembly GC")
@depends("--disable-wasm-gc")
def wasm_gc(value):
if not value:
return
return True
set_config("ENABLE_WASM_GC", wasm_gc)
set_define("ENABLE_WASM_GC", wasm_gc)
# Support for JS PI spec.
# ===========================
@depends(
milestone.is_nightly,
"--enable-jit",
"--enable-simulator",
"--enable-wasm-gc",
"--enable-wasm-tail-calls",
target,
)
def default_wasm_jspi(
is_nightly,
jit_enabled,
simulator,
gc,
tail_calls,
target,
):
if not jit_enabled or simulator:
return
if not gc or not tail_calls:
return
if not is_nightly:
return
if target.cpu in ("x86_64", "aarch64"):
return True
option(
"--enable-wasm-jspi",
default=default_wasm_jspi,
help="{Enable|Disable} WebAssembly JS PI",
)
@depends(
"--enable-wasm-jspi",
"--enable-jit",
"--enable-simulator",
"--enable-wasm-gc",
"--enable-wasm-tail-calls",
"--wasm-no-experimental",
target,
)
def wasm_jspi(value, jit_enabled, simulator, gc, tail_calls, no_experimental, target):
if no_experimental or not value:
return
if not jit_enabled:
die("--enable-wasm-jspi requires --enable-jit")
if not gc:
die("--enable-wasm-jspi requires --enable-wasm-gc")
if not tail_calls:
die("--enable-wasm-jspi requires --enable-wasm-tail-calls")
if simulator:
die("--enable-wasm-jspi is not supported for simulators")
if target.cpu in ("x86_64", "aarch64"):
return True
die("--enable-wasm-jspi only possible when targeting the x86_64/arm64 jits")
set_config("ENABLE_WASM_JSPI", wasm_jspi)
set_define("ENABLE_WASM_JSPI", wasm_jspi)
# Support for WebAssembly JS String Builtins
# ==========================================
option(
"--disable-wasm-js-string-builtins",
default=True,
help="{Enable|Disable} WebAssembly JS String Builtins",
)
@depends("--disable-wasm-js-string-builtins", "--wasm-no-experimental")
def wasm_js_string_builtins(value, no_experimental):
if no_experimental or not value:
return
return True
set_config("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
set_define("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
# Support for WebAssembly shared memory and atomics.
#
# This affects the JS shell only.
# =====================================================
option(
"--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
)
@depends("--disable-shared-memory")
def enable_shared_memory(value):
if value:
return True
set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
# Support for WebAssembly SIMD
# =====================================================
@depends("--enable-jit", "--enable-simulator", target)
def default_wasm_simd(jit_enabled, simulator, target):
if not jit_enabled:
return
if simulator and (simulator[0] != "arm64"):
return
if target.cpu in ("x86_64", "x86", "aarch64"):
return True
option(
"--enable-wasm-simd",
default=default_wasm_simd,
help="{Enable|Disable} WebAssembly SIMD",
)
@depends(
"--enable-wasm-simd",
"--enable-jit",
"--enable-simulator",
target,
"--wasm-no-experimental",
)
def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
if no_experimental or not value:
return
if not jit_enabled:
die("--enable-wasm-simd requires --enable-jit")
if simulator and (simulator[0] != "arm64"):
die("--enable-wasm-simd is not supported for simulators, except arm64")
if target.cpu in ("x86_64", "x86", "aarch64"):
return True
die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
set_config("ENABLE_WASM_SIMD", wasm_simd)
set_define("ENABLE_WASM_SIMD", wasm_simd)
# Whether to check for field changes in WebAssembly serialization
#
# See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
# for more background.
# =====================================================================
@depends(
target,
c_compiler,
moz_debug,
milestone,
"--wasm-no-experimental",
)
def wasm_verify_serialization_for_size(
target, c_compiler, debug, milestone, no_experimental
):
if (
debug == True
and target.kernel == "Linux"
and target.cpu == "x86_64"
and c_compiler
and c_compiler.type == "clang"
and milestone.is_nightly
and not no_experimental
):
return True
return
set_define(
"ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
)
# Support for Intel AVX instruction.
#
# AVX is exclusively used in WebAssembly SIMD instructions at the moment:
# set direct dependency on "--enable-wasm-simd".
# =====================================================
@depends("--enable-wasm-simd", "--enable-simulator", target)
def default_wasm_avx(wasm_simd_enabled, simulator, target):
if not wasm_simd_enabled:
return
if simulator:
return
if target.cpu in ("x86_64", "x86"):
return True
option(
"--enable-wasm-avx",
default=default_wasm_avx,
help="{Enable|Disable} AVX support for WebAssembly SIMD",
)
@depends(
"--enable-wasm-avx",
"--enable-wasm-simd",
"--enable-simulator",
target,
"--wasm-no-experimental",
)
def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
if no_experimental or not value:
return
if not wasm_simd_enabled:
die("--enable-wasm-avx requires --enable-wasm-simd")
if simulator:
die("--enable-wasm-avx is not supported for simulators")
if target.cpu in ("x86_64", "x86"):
return True
die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
set_config("ENABLE_WASM_AVX", wasm_avx)
set_define("ENABLE_WASM_AVX", wasm_avx)
# Support for WebAssembly relaxed SIMD
# =====================================================
@depends(milestone.is_nightly, "--enable-wasm-simd")
def default_wasm_relaxed_simd(is_nightly, wasm_simd):
if is_nightly and wasm_simd:
return True
option(
"--enable-wasm-relaxed-simd",
default=default_wasm_relaxed_simd,
help="{Enable|Disable} WebAssembly relaxed SIMD",
)
@depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd", "--wasm-no-experimental")
def wasm_relaxed_simd(value, wasm_simd, no_experimental):
if no_experimental or not value:
return
if not wasm_simd:
die("relaxed SIMD requires SIMD")
return True
set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
# Support for WebAssembly intgemm private intrinsics
# =====================================================
@depends(target)
def default_wasm_moz_intgemm(target):
return target.cpu in ("x86", "x86_64", "aarch64")
option(
"--enable-wasm-moz-intgemm",
default=default_wasm_moz_intgemm,
help="{Enable|Disable} WebAssembly intgemm private intrinsics",
)
@depends("--enable-wasm-moz-intgemm", "--wasm-no-experimental")
def wasm_moz_intgemm(value, no_experimental):
if no_experimental:
return
if value:
return True
set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
# Support for WebAssembly Memory64.
# ===========================
@depends(milestone.is_nightly, "--enable-simulator", target)
def default_wasm_memory64(is_nightly, simulator, target):
if target.cpu == "mips32":
return
if simulator and simulator[0] == "mips32":
return
if is_nightly:
return True
option(
"--enable-wasm-memory64",
default=default_wasm_memory64,
help="{Enable|Disable} WebAssembly Memory64",
)
@depends(
"--enable-wasm-memory64", "--enable-simulator", target, "--wasm-no-experimental"
)
def wasm_memory64(value, simulator, target, no_experimental):
if no_experimental or not value:
return
if target.cpu == "mips32":
die("Memory64 is incompatible with MIPS32 target")
if simulator and simulator[0] == "mips32":
die("Memory64 is incompatible with MIPS32 simulator")
return True
set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
# Support for WebAssembly memory control.
# ===========================
@depends(milestone.is_nightly)
def default_wasm_memory_control(is_nightly):
if is_nightly:
return True
option(
"--enable-wasm-memory-control",
default=default_wasm_memory_control,
help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
)
@depends("--enable-wasm-memory-control", "--wasm-no-experimental")
def wasm_memory_control(value, no_experimental):
if no_experimental or not value:
return
return True
set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
# Support for WebAssembly Multi Memory.
# =====================================
option(
"--disable-wasm-multi-memory",
help="{Enable|Disable} WebAssembly multi-memory",
)
@depends("--disable-wasm-multi-memory")
def wasm_multi_memory(value):
if value:
return True
set_config("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
set_define("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
# Support for WebAssembly Branch-hinting.
# ===========================
@depends(milestone.is_nightly)
def default_wasm_branch_hinting(is_nightly):
if is_nightly:
return True
option(
"--enable-wasm-branch-hinting",
default=default_wasm_branch_hinting,
help="{Enable|Disable} WebAssembly Branch hints",
)
@depends("--enable-wasm-branch-hinting", "--wasm-no-experimental")
def wasm_branch_hinting(value, no_experimental):
if no_experimental or not value:
return
return True
set_config("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
set_define("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
# Options for generating the shell as a script
# ============================================
option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
option(
"--with-cross-lib",
nargs=1,
default=depends(target.alias)(lambda x: "/usr/%s" % x),
help="Use dir as the location for arm libraries",
)
set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
# Enable static checking using sixgill
# ====================================
option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
@depends_if("--with-sixgill")
@imports("os")
def sixgill(value):
for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
if not os.path.exists(os.path.join(value[0], f)):
die("The sixgill plugin and binaries are not at the specified path")
return value[0]
set_config("SIXGILL_PATH", sixgill)
# Support for readline
# =====================================================
@depends("--enable-js-shell", target_is_windows, compile_environment, target)
def editline(js_shell, is_windows, compile_environment, target):
return js_shell and not is_windows and compile_environment and (target.os != "WASI")
option(
"--enable-readline", help="Link js shell to system readline library", when=editline
)
has_readline = check_symbol(
"readline",
flags=["-lreadline"],
when="--enable-readline",
onerror=lambda: die("No system readline library found"),
)
set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
@depends("--enable-readline", editline, when=editline)
def bundled_editline(readline, editline):
return editline and not readline
set_config("JS_BUNDLED_EDITLINE", bundled_editline)
set_define("EDITLINE", True, when=editline)
# JIT observers
# =============
option(
"--with-jitreport-granularity",
default="3",
choices=("0", "1", "2", "3"),
help="Default granularity at which to report JIT code to external tools "
"(0 - no info, 1 - code ranges for while functions only, "
"2 - per-line information, 3 - per-op information)",
)
set_define(
"JS_DEFAULT_JITREPORT_GRANULARITY",
depends_if("--with-jitreport-granularity")(lambda value: value[0]),
)
# ECMAScript Internationalization API Support (uses ICU)
# ======================================================
system_lib_option("--with-system-icu", help="Use system ICU")
system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 73.1", when="--with-system-icu")
@depends("--with-system-icu")
def in_tree_icu(system_icu):
return not system_icu
# Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
# for layout/style/extra-bindgen-flags
set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
option("--without-intl-api", help="Disable ECMAScript Internationalization API")
@depends("--with-intl-api", js_standalone)
def check_intl_api(enabled, js_standalone):
if not enabled and not js_standalone:
die("--without-intl-api is not supported")
set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
@depends(build_environment, when="--with-intl-api")
@imports(_from="__builtin__", _import="open")
@imports(_from="__builtin__", _import="ValueError")
def icu_version(build_env):
path = os.path.join(
build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
)
with open(path, encoding="utf-8") as fh:
for line in fh:
if line.startswith("#define"):
define = line.split(None, 3)
if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
try:
return str(int(define[2]))
except ValueError:
pass
die("Cannot determine ICU version number from uvernum.h header file")
set_config("MOZ_ICU_VERSION", icu_version)
# Source files that use ICU should have control over which parts of the ICU
# namespace they want to use.
set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
# We build ICU as a static library.
set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
# ECMAScript Temporal API Support (uses ICU)
# ======================================================
option("--with-temporal-api", default=False, help="Enable ECMAScript Temporal API")
set_config("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
set_define("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
@depends("--with-temporal-api", "--with-intl-api")
def check_temporal_api(temporal_enabled, intl_enabled):
if temporal_enabled and not intl_enabled:
die("Can't use both --with-temporal-api and --without-intl-api")
# Initial support for WebAssembly JS-API Type Reflections
# =======================================================
@depends(milestone.is_nightly)
def default_wasm_type_reflections(is_nightly):
return is_nightly
option(
"--enable-wasm-type-reflections",
default=default_wasm_type_reflections,
help="{Enable|Disable} type reflection in WASM JS-API",
)
set_config(
"ENABLE_WASM_TYPE_REFLECTIONS",
depends_if("--enable-wasm-type-reflections")(lambda x: True),
)
set_define(
"ENABLE_WASM_TYPE_REFLECTIONS",
depends_if("--enable-wasm-type-reflections")(lambda x: True),
)
# Wasi configuration
# ===================================================
@depends(target.os)
def is_wasi_target(os):
return os == "WASI"
set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
@depends(milestone.version)
def js_version(version):
return Version(version)
set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
set_define("MOZJS_MAJOR_VERSION", js_version.major)
set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
set_define("MOZJS_MINOR_VERSION", js_version.minor)
set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
set_config(
"MOZJS_ALPHA",
depends(js_version)(
lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
),
)
# Some platforms have HeapReg, some don't
# =====================================================
# The ARM simulator runs on x86 and might be excluded by the first test,
# so we special-case it.
@depends("--enable-simulator", target)
def wasm_has_heapreg(simulator, target):
if target.cpu != "x86":
return True
if simulator and simulator[0] == "arm":
return True
set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
# Check for tm_zone, tm_gmtoff in struct tm
# ===================================================
with only_when(compile_environment):
set_define(
"HAVE_TM_ZONE_TM_GMTOFF",
c_compiler.try_compile(
includes=["time.h"],
body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
check_msg="for tm_zone and tm_gmtoff in struct tm",
),
)
#
# Checks for library functions
# ==============================================================
with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
set_define("HAVE_GETTID", check_symbol("gettid"))
set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
set_define("HAVE_SYSCALL", check_symbol("syscall"))
set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
set_define("HAVE_STRERROR", check_symbol("strerror"))
set_config(
"HAVE_LANGINFO_CODESET",
try_link(
includes=["langinfo.h"],
body="char* cs = nl_langinfo(CODESET);",
check_msg="for nl_langinfo and CODESET",
when=building_with_gnu_cc,
),
)
@depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
def demangle_symbols(cxa_demangle, moz_debug, dmd):
# Demangle only for debug or DMD builds
if cxa_demangle and (moz_debug or dmd):
return True
set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
set_define("HAVE__UNWIND_BACKTRACE", True, when=have_unwind)
with only_when(compile_environment):
set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
set_define("HAVE_LOCALECONV", check_symbol("localeconv"))
|