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