no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / js / moz.configure
blob44676244c3ff637e6e8ce77a6bcf6538b7008475
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/.
8 @depends(build_project)
9 def js_standalone(build_project):
10     if build_project == "js":
11         return True
14 # Debug (see Bug 939505)
15 # ==============================================================
16 set_define("JS_DEBUG", True, when=moz_debug)
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.",
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()
39 set_config("MOZ_APP_NAME", moz_app_name)
41 # SmooshMonkey (new frontend)
42 # ==================================================
44 # Define here in order to use the option from bindgen.configure.
45 option(
46     "--enable-smoosh",
47     default=False,
48     help="Enable SmooshMonkey (new JS engine frontend)",
52 @depends("--enable-smoosh")
53 def enable_smoosh(value):
54     if value:
55         return True
58 set_config("JS_ENABLE_SMOOSH", enable_smoosh)
59 set_define("JS_ENABLE_SMOOSH", enable_smoosh)
61 include("../build/moz.configure/nspr.configure", when="--enable-compile-environment")
62 include("../build/moz.configure/rust.configure", when="--enable-compile-environment")
63 include("../build/moz.configure/bindgen.configure", when="--enable-compile-environment")
65 set_config("JS_STANDALONE", js_standalone)
66 set_define("JS_STANDALONE", js_standalone)
67 add_old_configure_assignment("JS_STANDALONE", js_standalone)
68 option(
69     "--enable-js-shell", default=js_standalone, help="{Build|Do not build} the JS shell"
73 @depends("--enable-js-shell")
74 def js_disable_shell(value):
75     if not value:
76         return True
79 set_config("JS_DISABLE_SHELL", js_disable_shell)
81 set_define("JS_64BIT", depends(target)(lambda t: t.bitness == 64 or None))
83 set_define("JS_PUNBOX64", depends(target)(lambda t: t.bitness == 64 or None))
84 set_define("JS_NUNBOX32", depends(target)(lambda t: t.bitness == 32 or None))
87 # SpiderMonkey as a shared library, and how its symbols are exported
88 # ==================================================================
89 option(
90     "--disable-shared-js",
91     when=js_standalone,
92     help="{Create|Do not create} a shared library",
95 option(
96     "--disable-export-js",
97     when=js_standalone,
98     help="{Mark|Do not mark} JS symbols as DLL exported/visible",
102 @depends("--disable-shared-js", "--disable-export-js", when=js_standalone)
103 def shared_js(shared_js, export_js):
104     if shared_js:
105         if not export_js:
106             die("Must export JS symbols when building a shared library.")
107         return True
110 set_config("JS_SHARED_LIBRARY", shared_js)
113 @depends(shared_js, "--disable-export-js", when=js_standalone)
114 def exportable_js_api(shared_js, export_js):
115     if not shared_js and export_js:
116         return True
119 set_define("STATIC_EXPORTABLE_JS_API", exportable_js_api)
122 @depends(shared_js, exportable_js_api)
123 def static_js_api(shared_js, export_js):
124     if not shared_js and not export_js:
125         return True
128 set_define("STATIC_JS_API", static_js_api)
131 @depends(shared_js)
132 def static_js(value):
133     if not value:
134         return True
137 set_define("MOZ_STATIC_JS", static_js)
140 # Enable records and tuples
141 # ===================================================
142 option(
143     "--enable-record-tuple",
144     default=False,
145     help="Enable records and tuples (and disables JIT)",
149 @depends("--enable-record-tuple")
150 def enable_record_tuple(value):
151     if value:
152         return True
155 set_config("ENABLE_RECORD_TUPLE", enable_record_tuple)
156 set_define("ENABLE_RECORD_TUPLE", enable_record_tuple)
158 # Enable decorators
159 # ===================================================
160 option(
161     "--enable-decorators",
162     default=False,
163     help="Enable experimental JS Decorators support",
167 @depends("--enable-decorators")
168 def enable_decorators(value):
169     if value:
170         return True
173 set_config("ENABLE_DECORATORS", enable_decorators)
174 set_define("ENABLE_DECORATORS", enable_decorators)
177 # Enable JSON.parse with source
178 # ===================================================
179 @depends(milestone.is_nightly)
180 def enable_json_parse_with_source(is_nightly):
181     if is_nightly:
182         return True
185 set_config("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
186 set_define("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
189 # Portable Baseline Intepreter
190 # =======================================================
191 option(
192     "--enable-portable-baseline-interp",
193     default=False,
194     help="{Enable|Disable} the portable baseline interpreter.",
196 set_define(
197     "ENABLE_PORTABLE_BASELINE_INTERP",
198     depends_if("--enable-portable-baseline-interp")(lambda _: True),
200 set_config(
201     "ENABLE_PORTABLE_BASELINE_INTERP",
202     depends_if("--enable-portable-baseline-interp")(lambda _: True),
205 # Option to always force PBL tier.
206 option(
207     "--enable-portable-baseline-interp-force",
208     default=False,
209     help="{Enable|Disable} forcing use of the portable baseline interpreter.",
212 set_define(
213     "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
214     depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
216 set_config(
217     "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
218     depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
222 # JIT support
223 # =======================================================
224 @depends(target, "--enable-record-tuple", "--enable-portable-baseline-interp")
225 def jit_default(target, enable_record_tuple, enable_portable_baseline_interp):
226     if enable_record_tuple:
227         return False
228     if enable_portable_baseline_interp:
229         return False
230     if target.cpu in (
231         "x86",
232         "x86_64",
233         "arm",
234         "aarch64",
235         "mips32",
236         "mips64",
237         "loongarch64",
238     ):
239         return True
240     return False
243 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
246 @deprecated_option("--enable-ion")
247 def report_deprecated(value):
248     if value:
249         die("--enable-ion is deprecated, use --enable-jit instead")
250     else:
251         die("--disable-ion is deprecated, use --disable-jit instead")
254 # JIT code simulator for cross compiles
255 # =======================================================
256 option(
257     "--enable-simulator",
258     choices=("arm", "arm64", "mips32", "mips64", "loong64", "riscv64"),
259     nargs=1,
260     help="Enable a JIT code simulator for the specified architecture",
264 @depends("--enable-jit", "--enable-simulator", target)
265 def simulator(jit_enabled, simulator_enabled, target):
266     if not jit_enabled or not simulator_enabled:
267         return
269     sim_cpu = simulator_enabled[0]
271     if sim_cpu in ("arm", "mips32"):
272         if target.cpu != "x86":
273             die("The %s simulator only works on x86." % sim_cpu)
275     if sim_cpu in ("arm64", "mips64", "loong64", "riscv64"):
276         if target.cpu != "x86_64" and target.cpu != "aarch64":
277             die("The %s simulator only works on x86-64 or arm64." % sim_cpu)
279     return namespace(**{sim_cpu: True})
282 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
283 set_config("JS_SIMULATOR_ARM", simulator.arm)
284 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
285 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
286 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
287 set_config("JS_SIMULATOR_LOONG64", simulator.loong64)
288 set_config("JS_SIMULATOR_RISCV64", simulator.riscv64)
289 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
290 set_define("JS_SIMULATOR_ARM", simulator.arm)
291 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
292 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
293 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
294 set_define("JS_SIMULATOR_LOONG64", simulator.loong64)
295 set_define("JS_SIMULATOR_RISCV64", simulator.riscv64)
298 @depends("--enable-jit", simulator, target)
299 def jit_codegen(jit_enabled, simulator, target):
300     if not jit_enabled:
301         return namespace(none=True)
303     if simulator:
304         return simulator
306     if target.cpu == "aarch64":
307         return namespace(arm64=True)
308     elif target.cpu == "x86_64":
309         return namespace(x64=True)
310     elif target.cpu == "loongarch64":
311         return namespace(loong64=True)
312     elif target.cpu == "riscv64":
313         return namespace(riscv64=True)
315     return namespace(**{str(target.cpu): True})
318 set_config("JS_CODEGEN_NONE", jit_codegen.none)
319 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
320 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
321 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
322 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
323 set_config("JS_CODEGEN_LOONG64", jit_codegen.loong64)
324 set_config("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
325 set_config("JS_CODEGEN_X86", jit_codegen.x86)
326 set_config("JS_CODEGEN_X64", jit_codegen.x64)
327 set_config("JS_CODEGEN_WASM32", jit_codegen.wasm32)
329 set_define("JS_CODEGEN_NONE", jit_codegen.none)
330 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
331 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
332 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
333 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
334 set_define("JS_CODEGEN_LOONG64", jit_codegen.loong64)
335 set_define("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
336 set_define("JS_CODEGEN_X86", jit_codegen.x86)
337 set_define("JS_CODEGEN_X64", jit_codegen.x64)
338 set_define("JS_CODEGEN_WASM32", jit_codegen.wasm32)
341 # Profiling
342 # =======================================================
343 option(
344     "--enable-instruments",
345     env="MOZ_INSTRUMENTS",
346     help="Enable instruments remote profiling",
350 @depends("--enable-instruments", target)
351 def instruments(value, target):
352     if value and target.os != "OSX":
353         die("--enable-instruments cannot be used when targeting %s", target.os)
354     if value:
355         return True
358 set_config("MOZ_INSTRUMENTS", instruments)
359 set_define("MOZ_INSTRUMENTS", instruments)
360 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
361 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
363 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
366 @depends("--enable-callgrind")
367 def callgrind(value):
368     if value:
369         return True
372 set_define("MOZ_CALLGRIND", callgrind)
373 imply_option("--enable-profiling", callgrind)
376 @depends(milestone)
377 def enable_profiling(milestone):
378     return milestone.is_nightly
381 option(
382     "--enable-profiling",
383     env="MOZ_PROFILING",
384     default=enable_profiling,
385     help="{Set|Do not set} compile flags necessary for using sampling "
386     "profilers (e.g. shark, perf)",
390 @depends("--enable-profiling")
391 def profiling(value):
392     if value:
393         return True
396 with only_when("--enable-compile-environment"):
397     imply_option("--enable-frame-pointers", True, when=profiling)
400 @depends(profiling, target)
401 def imply_vtune(value, target):
402     ok_cpu = target.cpu in ["x86", "x86_64"]
403     ok_kernel = target.kernel == "WINNT" or (
404         target.kernel == "Linux" and target.os == "GNU"
405     )
407     if value and ok_cpu and ok_kernel:
408         return True
411 set_config("MOZ_PROFILING", profiling)
412 set_define("MOZ_PROFILING", profiling)
413 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
416 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
419 @depends("--enable-vtune")
420 def vtune(value):
421     if value:
422         return True
425 set_config("MOZ_VTUNE", vtune)
426 set_define("MOZ_VTUNE", vtune)
429 option(
430     "--enable-gc-probes",
431     env="JS_GC_PROBES",
432     help="Turn on probes for allocation and finalization",
436 @depends("--enable-gc-probes")
437 def gc_probes(value):
438     if value:
439         return True
442 set_define("JS_GC_PROBES", gc_probes)
445 option(
446     "--enable-gczeal",
447     default=depends(when=moz_debug)(lambda: True),
448     help="{Enable|Disable} zealous GCing",
451 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
454 # Enable breakpoint for artificial OOMs
455 # =======================================================
456 option(
457     "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
460 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
463 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
466 @depends("--enable-perf", target)
467 def ion_perf(value, target):
468     is_linux = target.kernel == "Linux"
469     is_mac = target.kernel == "Darwin" and target.os == "OSX"
471     if value and (is_linux or is_mac):
472         return True
475 set_define("JS_ION_PERF", ion_perf)
478 option(
479     "--enable-jitspew",
480     default=depends(when=moz_debug)(lambda: True),
481     help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
484 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
485 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
487 # Also enable the structured spewer
488 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
489 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
492 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
493 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
494     if not jit_enabled:
495         return
497     if simulator and (debug or spew):
498         if getattr(simulator, "arm", None):
499             return True
501     if target.cpu == "arm" and (debug or spew):
502         return True
505 set_config("JS_DISASM_ARM", jit_disasm_arm)
506 set_define("JS_DISASM_ARM", jit_disasm_arm)
509 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
510 def jit_disasm_riscv(jit_enabled, spew, simulator, target, debug):
511     if not jit_enabled:
512         return
514     if simulator and (debug or spew):
515         if getattr(simulator, "riscv64", None):
516             return True
518     if target.cpu == "riscv64" and (debug or spew):
519         return True
522 set_config("JS_DISASM_RISCV64", jit_disasm_riscv)
523 set_define("JS_DISASM_RISCV64", jit_disasm_riscv)
526 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
527 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
528     if not jit_enabled:
529         return
531     if simulator and (debug or spew):
532         if getattr(simulator, "arm64", None):
533             return True
535     if target.cpu == "aarch64" and (debug or spew):
536         return True
539 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
540 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
542 # When enabled, masm will generate assumeUnreachable calls that act as
543 # assertions in the generated code. This option is worth disabling when you
544 # have to track mutated values through the generated code, to avoid constantly
545 # dumping registers on and off the stack.
546 option(
547     "--enable-masm-verbose",
548     default=depends(when=moz_debug)(lambda: True),
549     help="{Enable|Disable} MacroAssembler verbosity of generated code.",
551 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
552 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
554 # Architecture feature flags
555 # =======================================================
558 # Apple silicon does not seem to have any way to query the OS for the JSCVT
559 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
560 # hard code the value of the JSCVT flag which guards the implementation of
561 # FJCVTZS instruction as part of ARMv8.3-JSConv.
562 @depends(target)
563 def is_apple_silicon(target):
564     return target.kernel == "Darwin" and target.cpu == "aarch64"
567 option(
568     "--enable-arm64-fjcvtzs",
569     default=is_apple_silicon,
570     help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
574 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
575 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
576 # (D12.1.4).
578 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
579 @depends("--enable-arm64-fjcvtzs", target, simulator)
580 def aarch64_jscvt(fjcvtzs, target, simulator):
581     if target.cpu == "aarch64" and fjcvtzs:
582         return 1
584     if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
585         return 1
587     return 0
590 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
593 @depends(target)
594 def has_apple_fast_wx(target):
595     return target.kernel == "Darwin" and target.cpu == "aarch64"
598 # On Apple Silicon macOS we use MAP_JIT with pthread_jit_write_protect_np to
599 # implement JIT code write protection, while on iOS we use MAP_JIT with
600 # be_memory_inline_jit_restrict_*.
601 set_define("JS_USE_APPLE_FAST_WX", True, when=has_apple_fast_wx)
604 # CTypes
605 # =======================================================
606 @depends(js_standalone)
607 def ctypes_default(js_standalone):
608     return not js_standalone
611 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
613 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
615 set_config("BUILD_CTYPES", build_ctypes)
616 set_define("BUILD_CTYPES", build_ctypes)
618 set_config("JS_HAS_CTYPES", build_ctypes)
619 set_define("JS_HAS_CTYPES", build_ctypes)
622 @depends("--enable-ctypes", "--enable-compile-environment")
623 def ctypes_and_compile_environment(ctypes, compile_environment):
624     return ctypes and compile_environment
627 include("ffi.configure", when=ctypes_and_compile_environment)
630 # Enable pipeline operator
631 # ===================================================
632 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
635 @depends("--enable-pipeline-operator")
636 def enable_pipeline_operator(value):
637     if value:
638         return True
641 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
642 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
645 # SIMD acceleration for encoding_rs
646 # ==============================================================
648 option(
649     "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
653 @depends("--enable-rust-simd", target)
654 def rust_simd(value, target):
655     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
656     # been properly set up outside aarch64, armv7, x86 and x86_64.
657     if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
658         return True
661 set_config("MOZ_RUST_SIMD", rust_simd)
662 set_define("MOZ_RUST_SIMD", rust_simd)
664 # Telemetry to measure compile time and generated-code runtime
665 # ============================================================
667 option(
668     "--enable-spidermonkey-telemetry",
669     default=milestone.is_nightly,
670     help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
673 set_define(
674     "ENABLE_SPIDERMONKEY_TELEMETRY",
675     depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
678 # Support for debugging code generated by wasm backends
679 # =====================================================
681 option(
682     "--enable-wasm-codegen-debug",
683     default=depends(when=moz_debug)(lambda: True),
684     help="{Enable|Disable} debugging for wasm codegen",
687 set_config(
688     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
690 set_define(
691     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
694 # WebAssembly feature flags
695 # ==================================================
697 option(
698     "--wasm-no-experimental",
699     default=False,
700     help="Force disable all wasm experimental features for testing.",
703 # Support for WebAssembly tail-calls.
704 # ===========================
707 @depends(target)
708 def default_wasm_tail_calls(target):
709     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
710         return True
713 option(
714     "--enable-wasm-tail-calls",
715     default=default_wasm_tail_calls,
716     help="{Enable|Disable} WebAssembly tail-calls",
720 @depends("--enable-wasm-tail-calls", target)
721 def wasm_tail_calls(value, target):
722     if not value:
723         return
725     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
726         return True
728     die(
729         "--enable-wasm-tail-calls only possible when targeting the x86_64/x86/arm64/arm/loongarch64/mips64 jits"
730     )
733 set_config("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
734 set_define("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
736 # Support for WebAssembly GC.
737 # ===========================
740 option("--disable-wasm-gc", default=True, help="{Enable|Disable} WebAssembly GC")
743 @depends("--disable-wasm-gc")
744 def wasm_gc(value):
745     if not value:
746         return
747     return True
750 set_config("ENABLE_WASM_GC", wasm_gc)
751 set_define("ENABLE_WASM_GC", wasm_gc)
753 # Support for WebAssembly JS String Builtins
754 # ==========================================
757 option(
758     "--disable-wasm-js-string-builtins",
759     default=True,
760     help="{Enable|Disable} WebAssembly JS String Builtins",
764 @depends("--disable-wasm-js-string-builtins", "--wasm-no-experimental")
765 def wasm_js_string_builtins(value, no_experimental):
766     if no_experimental or not value:
767         return
769     return True
772 set_config("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
773 set_define("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
775 # Support for WebAssembly shared memory and atomics.
777 # This affects the JS shell only.
778 # =====================================================
780 option(
781     "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
785 @depends("--disable-shared-memory")
786 def enable_shared_memory(value):
787     if value:
788         return True
791 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
792 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
794 # Support for WebAssembly SIMD
795 # =====================================================
798 @depends("--enable-jit", "--enable-simulator", target)
799 def default_wasm_simd(jit_enabled, simulator, target):
800     if not jit_enabled:
801         return
803     if simulator and (simulator[0] != "arm64"):
804         return
806     if target.cpu in ("x86_64", "x86", "aarch64"):
807         return True
810 option(
811     "--enable-wasm-simd",
812     default=default_wasm_simd,
813     help="{Enable|Disable} WebAssembly SIMD",
817 @depends(
818     "--enable-wasm-simd",
819     "--enable-jit",
820     "--enable-simulator",
821     target,
822     "--wasm-no-experimental",
824 def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
825     if no_experimental or not value:
826         return
828     if not jit_enabled:
829         die("--enable-wasm-simd requires --enable-jit")
831     if simulator and (simulator[0] != "arm64"):
832         die("--enable-wasm-simd is not supported for simulators, except arm64")
834     if target.cpu in ("x86_64", "x86", "aarch64"):
835         return True
837     die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
840 set_config("ENABLE_WASM_SIMD", wasm_simd)
841 set_define("ENABLE_WASM_SIMD", wasm_simd)
843 # Whether to check for field changes in WebAssembly serialization
845 # See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
846 # for more background.
847 # =====================================================================
850 @depends(
851     target,
852     c_compiler,
853     moz_debug,
854     milestone,
855     "--wasm-no-experimental",
857 def wasm_verify_serialization_for_size(
858     target, c_compiler, debug, milestone, no_experimental
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
873 set_define(
874     "ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
877 # Support for Intel AVX instruction.
879 # AVX is exclusively used in WebAssembly SIMD instructions at the moment:
880 # set direct dependency on "--enable-wasm-simd".
881 # =====================================================
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
889     if simulator:
890         return
892     if target.cpu in ("x86_64", "x86"):
893         return True
896 option(
897     "--enable-wasm-avx",
898     default=default_wasm_avx,
899     help="{Enable|Disable} AVX support for WebAssembly SIMD",
903 @depends(
904     "--enable-wasm-avx",
905     "--enable-wasm-simd",
906     "--enable-simulator",
907     target,
908     "--wasm-no-experimental",
910 def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
911     if no_experimental or not value:
912         return
914     if not wasm_simd_enabled:
915         die("--enable-wasm-avx requires --enable-wasm-simd")
917     if simulator:
918         die("--enable-wasm-avx is not supported for simulators")
920     if target.cpu in ("x86_64", "x86"):
921         return True
923     die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
926 set_config("ENABLE_WASM_AVX", wasm_avx)
927 set_define("ENABLE_WASM_AVX", wasm_avx)
929 # Support for WebAssembly relaxed SIMD
930 # =====================================================
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
939 option(
940     "--enable-wasm-relaxed-simd",
941     default=default_wasm_relaxed_simd,
942     help="{Enable|Disable} WebAssembly relaxed SIMD",
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
951     if not wasm_simd:
952         die("relaxed SIMD requires SIMD")
954     return True
957 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
958 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
960 # Support for WebAssembly intgemm private intrinsics
961 # =====================================================
964 @depends(target)
965 def default_wasm_moz_intgemm(target):
966     return target.cpu in ("x86", "x86_64", "aarch64")
969 option(
970     "--enable-wasm-moz-intgemm",
971     default=default_wasm_moz_intgemm,
972     help="{Enable|Disable} WebAssembly intgemm private intrinsics",
976 @depends("--enable-wasm-moz-intgemm", "--wasm-no-experimental")
977 def wasm_moz_intgemm(value, no_experimental):
978     if no_experimental:
979         return
981     if value:
982         return True
985 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
986 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
988 # Support for WebAssembly Memory64.
989 # ===========================
992 @depends(milestone.is_nightly, "--enable-simulator", target)
993 def default_wasm_memory64(is_nightly, simulator, target):
994     if target.cpu == "mips32":
995         return
997     if simulator and simulator[0] == "mips32":
998         return
1000     if is_nightly:
1001         return True
1004 option(
1005     "--enable-wasm-memory64",
1006     default=default_wasm_memory64,
1007     help="{Enable|Disable} WebAssembly Memory64",
1011 @depends(
1012     "--enable-wasm-memory64", "--enable-simulator", target, "--wasm-no-experimental"
1014 def wasm_memory64(value, simulator, target, no_experimental):
1015     if no_experimental or not value:
1016         return
1018     if target.cpu == "mips32":
1019         die("Memory64 is incompatible with MIPS32 target")
1021     if simulator and simulator[0] == "mips32":
1022         die("Memory64 is incompatible with MIPS32 simulator")
1024     return True
1027 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
1028 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
1031 # Support for WebAssembly memory control.
1032 # ===========================
1035 @depends(milestone.is_nightly)
1036 def default_wasm_memory_control(is_nightly):
1037     if is_nightly:
1038         return True
1041 option(
1042     "--enable-wasm-memory-control",
1043     default=default_wasm_memory_control,
1044     help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
1048 @depends("--enable-wasm-memory-control", "--wasm-no-experimental")
1049 def wasm_memory_control(value, no_experimental):
1050     if no_experimental or not value:
1051         return
1053     return True
1056 set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1057 set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1060 # Support for WebAssembly Multi Memory.
1061 # =====================================
1064 option(
1065     "--disable-wasm-multi-memory",
1066     help="{Enable|Disable} WebAssembly multi-memory",
1070 @depends("--disable-wasm-multi-memory")
1071 def wasm_multi_memory(value):
1072     if value:
1073         return True
1076 set_config("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1077 set_define("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1080 # Support for WebAssembly Branch-hinting.
1081 # ===========================
1084 @depends(milestone.is_nightly)
1085 def default_wasm_branch_hinting(is_nightly):
1086     if is_nightly:
1087         return True
1090 option(
1091     "--enable-wasm-branch-hinting",
1092     default=default_wasm_branch_hinting,
1093     help="{Enable|Disable} WebAssembly Branch hints",
1097 @depends("--enable-wasm-branch-hinting", "--wasm-no-experimental")
1098 def wasm_branch_hinting(value, no_experimental):
1099     if no_experimental or not value:
1100         return
1102     return True
1105 set_config("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
1106 set_define("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
1108 # Options for generating the shell as a script
1109 # ============================================
1110 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
1111 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
1113 option(
1114     "--with-cross-lib",
1115     nargs=1,
1116     default=depends(target.alias)(lambda x: "/usr/%s" % x),
1117     help="Use dir as the location for arm libraries",
1119 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
1121 # Enable static checking using sixgill
1122 # ====================================
1124 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
1127 @depends_if("--with-sixgill")
1128 @imports("os")
1129 def sixgill(value):
1130     for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
1131         if not os.path.exists(os.path.join(value[0], f)):
1132             die("The sixgill plugin and binaries are not at the specified path")
1133     return value[0]
1136 set_config("SIXGILL_PATH", sixgill)
1139 # Support for readline
1140 # =====================================================
1143 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
1144 def editline(js_shell, is_windows, compile_environment, target):
1145     return js_shell and not is_windows and compile_environment and (target.os != "WASI")
1148 option(
1149     "--enable-readline", help="Link js shell to system readline library", when=editline
1152 has_readline = check_symbol(
1153     "readline",
1154     flags=["-lreadline"],
1155     when="--enable-readline",
1156     onerror=lambda: die("No system readline library found"),
1159 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
1162 @depends("--enable-readline", editline, when=editline)
1163 def bundled_editline(readline, editline):
1164     return editline and not readline
1167 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
1169 set_define("EDITLINE", True, when=editline)
1172 # JIT observers
1173 # =============
1175 option(
1176     "--with-jitreport-granularity",
1177     default="3",
1178     choices=("0", "1", "2", "3"),
1179     help="Default granularity at which to report JIT code to external tools "
1180     "(0 - no info, 1 - code ranges for while functions only, "
1181     "2 - per-line information, 3 - per-op information)",
1184 set_define(
1185     "JS_DEFAULT_JITREPORT_GRANULARITY",
1186     depends_if("--with-jitreport-granularity")(lambda value: value[0]),
1190 # ECMAScript Internationalization API Support (uses ICU)
1191 # ======================================================
1192 system_lib_option("--with-system-icu", help="Use system ICU")
1194 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 73.1", when="--with-system-icu")
1197 @depends("--with-system-icu")
1198 def in_tree_icu(system_icu):
1199     return not system_icu
1202 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
1203 # for layout/style/extra-bindgen-flags
1204 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
1206 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1207 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1209 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1212 @depends("--with-intl-api", js_standalone)
1213 def check_intl_api(enabled, js_standalone):
1214     if not enabled and not js_standalone:
1215         die("--without-intl-api is not supported")
1218 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1219 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1222 @depends(build_environment, when="--with-intl-api")
1223 @imports(_from="__builtin__", _import="open")
1224 @imports(_from="__builtin__", _import="ValueError")
1225 def icu_version(build_env):
1226     path = os.path.join(
1227         build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1228     )
1229     with open(path, encoding="utf-8") as fh:
1230         for line in fh:
1231             if line.startswith("#define"):
1232                 define = line.split(None, 3)
1233                 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1234                     try:
1235                         return str(int(define[2]))
1236                     except ValueError:
1237                         pass
1238     die("Cannot determine ICU version number from uvernum.h header file")
1241 set_config("MOZ_ICU_VERSION", icu_version)
1243 # Source files that use ICU should have control over which parts of the ICU
1244 # namespace they want to use.
1245 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1247 # We build ICU as a static library.
1248 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1251 # ECMAScript Temporal API Support (uses ICU)
1252 # ======================================================
1254 option("--with-temporal-api", default=False, help="Enable ECMAScript Temporal API")
1256 set_config("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1257 set_define("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1260 @depends("--with-temporal-api", "--with-intl-api")
1261 def check_temporal_api(temporal_enabled, intl_enabled):
1262     if temporal_enabled and not intl_enabled:
1263         die("Can't use both --with-temporal-api and --without-intl-api")
1266 # Initial support for WebAssembly JS-API Type Reflections
1267 # =======================================================
1270 @depends(milestone.is_nightly)
1271 def default_wasm_type_reflections(is_nightly):
1272     return is_nightly
1275 option(
1276     "--enable-wasm-type-reflections",
1277     default=default_wasm_type_reflections,
1278     help="{Enable|Disable} type reflection in WASM JS-API",
1281 set_config(
1282     "ENABLE_WASM_TYPE_REFLECTIONS",
1283     depends_if("--enable-wasm-type-reflections")(lambda x: True),
1285 set_define(
1286     "ENABLE_WASM_TYPE_REFLECTIONS",
1287     depends_if("--enable-wasm-type-reflections")(lambda x: True),
1290 # Wasi configuration
1291 # ===================================================
1294 @depends(target.os)
1295 def is_wasi_target(os):
1296     return os == "WASI"
1299 set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
1300 set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
1303 @depends(milestone.version)
1304 def js_version(version):
1305     return Version(version)
1308 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
1309 set_define("MOZJS_MAJOR_VERSION", js_version.major)
1310 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
1311 set_define("MOZJS_MINOR_VERSION", js_version.minor)
1312 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
1313 set_config(
1314     "MOZJS_ALPHA",
1315     depends(js_version)(
1316         lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
1317     ),
1321 # Some platforms have HeapReg, some don't
1322 # =====================================================
1324 # The ARM simulator runs on x86 and might be excluded by the first test,
1325 # so we special-case it.
1328 @depends("--enable-simulator", target)
1329 def wasm_has_heapreg(simulator, target):
1330     if target.cpu != "x86":
1331         return True
1333     if simulator and simulator[0] == "arm":
1334         return True
1337 set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
1339 # Check for tm_zone, tm_gmtoff in struct tm
1340 # ===================================================
1341 with only_when(compile_environment):
1342     set_define(
1343         "HAVE_TM_ZONE_TM_GMTOFF",
1344         c_compiler.try_compile(
1345             includes=["time.h"],
1346             body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
1347             check_msg="for tm_zone and tm_gmtoff in struct tm",
1348         ),
1349     )
1352 # Checks for library functions
1353 # ==============================================================
1354 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1355     set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
1356     set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
1357     set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
1358     set_define("HAVE_GETTID", check_symbol("gettid"))
1359     set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
1360     set_define("HAVE_SYSCALL", check_symbol("syscall"))
1361     set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
1362     set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
1363     set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
1364     set_define("HAVE_STRERROR", check_symbol("strerror"))
1366     set_config(
1367         "HAVE_LANGINFO_CODESET",
1368         try_link(
1369             includes=["langinfo.h"],
1370             body="char* cs = nl_langinfo(CODESET);",
1371             check_msg="for nl_langinfo and CODESET",
1372             when=building_with_gnu_cc,
1373         ),
1374     )
1376     @depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
1377     def demangle_symbols(cxa_demangle, moz_debug, dmd):
1378         # Demangle only for debug or DMD builds
1379         if cxa_demangle and (moz_debug or dmd):
1380             return True
1382     set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
1384     set_define("HAVE__UNWIND_BACKTRACE", True, when=have_unwind)
1386 with only_when(compile_environment):
1387     set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
1388     set_define("HAVE_LOCALECONV", check_symbol("localeconv"))