Bug 1731994: part 7) Update documentation of `nsIContentPermissionPrompt`. r=edgar...
[gecko.git] / js / moz.configure
blob65987aaa01b1879de368b8305c64c4116b465c54
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 # Branding
15 # ==============================================================
16 option(
17     "--with-app-name",
18     env="MOZ_APP_NAME",
19     nargs=1,
20     help="Used for e.g. the binary program file name. If not set, "
21     "defaults to a lowercase form of MOZ_APP_BASENAME.",
25 @depends("--with-app-name", js_standalone, moz_app_basename)
26 def moz_app_name(value, js_standalone, moz_app_basename):
27     if value:
28         return value[0]
29     if js_standalone:
30         return "js"
31     return moz_app_basename.lower()
34 set_config("MOZ_APP_NAME", moz_app_name)
36 # SmooshMonkey (new frontend)
37 # ==================================================
39 # Define here in order to use the option from bindgen.configure.
40 option(
41     "--enable-smoosh",
42     default=False,
43     help="Enable SmooshMonkey (new JS engine frontend)",
47 @depends("--enable-smoosh")
48 def enable_smoosh(value):
49     if value:
50         return True
53 set_config("JS_ENABLE_SMOOSH", enable_smoosh)
54 set_define("JS_ENABLE_SMOOSH", enable_smoosh)
56 include("../build/moz.configure/nspr.configure", when="--enable-compile-environment")
57 include("../build/moz.configure/rust.configure", when="--enable-compile-environment")
58 include("../build/moz.configure/bindgen.configure", when="--enable-compile-environment")
60 set_config("JS_STANDALONE", js_standalone)
61 set_define("JS_STANDALONE", js_standalone)
62 add_old_configure_assignment("JS_STANDALONE", js_standalone)
63 option(
64     "--enable-js-shell", default=js_standalone, help="{Build|Do not build} the JS shell"
68 @depends("--enable-js-shell")
69 def js_disable_shell(value):
70     if not value:
71         return True
74 set_config("JS_DISABLE_SHELL", js_disable_shell)
76 set_define("JS_64BIT", depends(target)(lambda t: t.bitness == 64 or None))
78 set_define("JS_PUNBOX64", depends(target)(lambda t: t.bitness == 64 or None))
79 set_define("JS_NUNBOX32", depends(target)(lambda t: t.bitness == 32 or None))
82 # SpiderMonkey as a shared library, and how its symbols are exported
83 # ==================================================================
84 option(
85     "--disable-shared-js",
86     when=js_standalone,
87     help="{Create|Do not create} a shared library",
90 option(
91     "--disable-export-js",
92     when=js_standalone,
93     help="{Mark|Do not mark} JS symbols as DLL exported/visible",
97 @depends("--disable-shared-js", "--disable-export-js", when=js_standalone)
98 def shared_js(shared_js, export_js):
99     if shared_js:
100         if not export_js:
101             die("Must export JS symbols when building a shared library.")
102         return True
105 set_config("JS_SHARED_LIBRARY", shared_js)
106 add_old_configure_assignment("JS_SHARED_LIBRARY", shared_js)
109 @depends(shared_js, "--disable-export-js", when=js_standalone)
110 def exportable_js_api(shared_js, export_js):
111     if not shared_js and export_js:
112         return True
115 set_define("STATIC_EXPORTABLE_JS_API", exportable_js_api)
118 @depends(shared_js, exportable_js_api)
119 def static_js_api(shared_js, export_js):
120     if not shared_js and not export_js:
121         return True
124 set_define("STATIC_JS_API", static_js_api)
127 @depends(shared_js)
128 def static_js(value):
129     if not value:
130         return True
133 set_define("MOZ_STATIC_JS", static_js)
136 # JIT support
137 # =======================================================
138 @depends(target)
139 def jit_default(target):
140     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "mips32", "mips64"):
141         return True
142     return False
145 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
148 @deprecated_option("--enable-ion")
149 def report_deprecated(value):
150     if value:
151         die("--enable-ion is deprecated, use --enable-jit instead")
152     else:
153         die("--disable-ion is deprecated, use --disable-jit instead")
156 # JIT code simulator for cross compiles
157 # =======================================================
158 option(
159     "--enable-simulator",
160     choices=("arm", "arm64", "mips32", "mips64"),
161     nargs=1,
162     help="Enable a JIT code simulator for the specified architecture",
166 @depends("--enable-jit", "--enable-simulator", target)
167 def simulator(jit_enabled, simulator_enabled, target):
168     if not jit_enabled or not simulator_enabled:
169         return
171     sim_cpu = simulator_enabled[0]
173     if sim_cpu in ("arm", "mips32"):
174         if target.cpu != "x86":
175             die("The %s simulator only works on x86." % sim_cpu)
177     if sim_cpu in ("arm64", "mips64"):
178         if target.cpu != "x86_64":
179             die("The %s simulator only works on x86-64." % sim_cpu)
181     return namespace(**{sim_cpu: True})
184 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
185 set_config("JS_SIMULATOR_ARM", simulator.arm)
186 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
187 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
188 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
189 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
190 set_define("JS_SIMULATOR_ARM", simulator.arm)
191 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
192 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
193 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
196 @depends("--enable-jit", simulator, target)
197 def jit_codegen(jit_enabled, simulator, target):
198     if not jit_enabled:
199         return namespace(none=True)
201     if simulator:
202         return simulator
204     if target.cpu == "aarch64":
205         return namespace(arm64=True)
206     elif target.cpu == "x86_64":
207         return namespace(x64=True)
209     return namespace(**{str(target.cpu): True})
212 set_config("JS_CODEGEN_NONE", jit_codegen.none)
213 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
214 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
215 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
216 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
217 set_config("JS_CODEGEN_X86", jit_codegen.x86)
218 set_config("JS_CODEGEN_X64", jit_codegen.x64)
219 set_define("JS_CODEGEN_NONE", jit_codegen.none)
220 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
221 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
222 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
223 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
224 set_define("JS_CODEGEN_X86", jit_codegen.x86)
225 set_define("JS_CODEGEN_X64", jit_codegen.x64)
227 # Profiling
228 # =======================================================
229 option(
230     "--enable-instruments",
231     env="MOZ_INSTRUMENTS",
232     help="Enable instruments remote profiling",
236 @depends("--enable-instruments", target)
237 def instruments(value, target):
238     if value and target.os != "OSX":
239         die("--enable-instruments cannot be used when targeting %s", target.os)
240     if value:
241         return True
244 set_config("MOZ_INSTRUMENTS", instruments)
245 set_define("MOZ_INSTRUMENTS", instruments)
246 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
247 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
249 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
252 @depends("--enable-callgrind")
253 def callgrind(value):
254     if value:
255         return True
258 set_define("MOZ_CALLGRIND", callgrind)
259 imply_option("--enable-profiling", callgrind)
262 @depends(milestone)
263 def enable_profiling(milestone):
264     return milestone.is_nightly
267 option(
268     "--enable-profiling",
269     env="MOZ_PROFILING",
270     default=enable_profiling,
271     help="{Set|Do not set} compile flags necessary for using sampling "
272     "profilers (e.g. shark, perf)",
276 @depends("--enable-profiling")
277 def profiling(value):
278     if value:
279         return True
282 add_old_configure_assignment("MOZ_PROFILING", profiling)
284 with only_when("--enable-compile-environment"):
285     imply_option("--enable-frame-pointers", True, when=profiling)
288 @depends(profiling, target)
289 def imply_vtune(value, target):
290     ok_cpu = target.cpu in ["x86", "x86_64"]
291     ok_kernel = target.kernel == "WINNT" or (
292         target.kernel == "Linux" and target.os == "GNU"
293     )
295     if value and ok_cpu and ok_kernel:
296         return True
299 set_config("MOZ_PROFILING", profiling)
300 set_define("MOZ_PROFILING", profiling)
301 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
304 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
307 @depends("--enable-vtune")
308 def vtune(value):
309     if value:
310         return True
313 set_config("MOZ_VTUNE", vtune)
314 set_define("MOZ_VTUNE", vtune)
317 option(
318     "--enable-gc-probes",
319     env="JS_GC_PROBES",
320     help="Turn on probes for allocation and finalization",
324 @depends("--enable-gc-probes")
325 def gc_probes(value):
326     if value:
327         return True
330 set_define("JS_GC_PROBES", gc_probes)
333 option(
334     "--enable-gczeal",
335     default=depends(when=moz_debug)(lambda: True),
336     help="{Enable|Disable} zealous GCing",
339 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
342 # Use a smaller chunk size for GC chunks
343 # ========================================================
344 # Use large (1MB) chunks by default.  This option can be used to give
345 # smaller (currently 256K) chunks.
346 option(
347     "--enable-small-chunk-size",
348     help="Allocate memory for JS GC things in smaller chunks",
351 set_define(
352     "JS_GC_SMALL_CHUNK_SIZE", depends(when="--enable-small-chunk-size")(lambda: True)
356 # Trace logging.
357 # =======================================================
358 @depends(milestone)
359 def default_trace_logging(milestone):
360     return milestone.is_nightly
363 option(
364     "--enable-trace-logging",
365     default=default_trace_logging,
366     help="{Enable|Disable} trace logging",
369 set_config("ENABLE_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
370 set_define("JS_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
373 # Enable breakpoint for artificial OOMs
374 # =======================================================
375 option(
376     "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
379 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
382 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
385 @depends("--enable-perf")
386 def ion_perf(value):
387     if value:
388         return True
391 set_define("JS_ION_PERF", ion_perf)
394 option(
395     "--enable-jitspew",
396     default=depends(when=moz_debug)(lambda: True),
397     help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
400 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
401 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
403 # Also enable the structured spewer
404 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
405 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
408 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
409 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
410     if not jit_enabled:
411         return
413     if simulator and (debug or spew):
414         if getattr(simulator, "arm", None):
415             return True
417     if target.cpu == "arm" and (debug or spew):
418         return True
421 set_config("JS_DISASM_ARM", jit_disasm_arm)
422 set_define("JS_DISASM_ARM", jit_disasm_arm)
425 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
426 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
427     if not jit_enabled:
428         return
430     if simulator and (debug or spew):
431         if getattr(simulator, "arm64", None):
432             return True
434     if target.cpu == "aarch64" and (debug or spew):
435         return True
438 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
439 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
441 # When enabled, masm will generate assumeUnreachable calls that act as
442 # assertions in the generated code. This option is worth disabling when you
443 # have to track mutated values through the generated code, to avoid constantly
444 # dumping registers on and off the stack.
445 option(
446     "--enable-masm-verbose",
447     default=depends(when=moz_debug)(lambda: True),
448     help="{Enable|Disable} MacroAssembler verbosity of generated code.",
450 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
451 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
453 # Architecture feature flags
454 # =======================================================
456 # Apple silicon does not seem to have any way to query the OS for the JSCVT
457 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
458 # hard code the value of the JSCVT flag which guards the implementation of
459 # FJCVTZS instruction as part of ARMv8.3-JSConv.
460 @depends(target)
461 def is_apple_silicon(target):
462     return target.os == "OSX" and target.kernel == "Darwin" and target.cpu == "aarch64"
465 option(
466     "--enable-arm64-fjcvtzs",
467     default=is_apple_silicon,
468     help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
471 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
472 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
473 # (D12.1.4).
475 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
476 @depends("--enable-arm64-fjcvtzs", target, simulator)
477 def aarch64_jscvt(fjcvtzs, target, simulator):
478     if target.cpu == "aarch64" and fjcvtzs:
479         return 1
481     if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
482         return 1
484     return 0
487 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
489 # CTypes
490 # =======================================================
491 @depends(js_standalone)
492 def ctypes_default(js_standalone):
493     return not js_standalone
496 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
498 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
500 set_config("BUILD_CTYPES", build_ctypes)
501 set_define("BUILD_CTYPES", build_ctypes)
503 set_config("JS_HAS_CTYPES", build_ctypes)
504 set_define("JS_HAS_CTYPES", build_ctypes)
507 @depends("--enable-ctypes", "--enable-compile-environment")
508 def ctypes_and_compile_environment(ctypes, compile_environment):
509     return ctypes and compile_environment
512 include("ffi.configure", when=ctypes_and_compile_environment)
515 # Enable pipeline operator
516 # ===================================================
517 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
520 @depends("--enable-pipeline-operator")
521 def enable_pipeline_operator(value):
522     if value:
523         return True
526 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
527 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
530 # SIMD acceleration for encoding_rs
531 # ==============================================================
533 option(
534     "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
538 @depends("--enable-rust-simd", target)
539 def rust_simd(value, target):
540     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
541     # been properly set up outside aarch64, armv7, x86 and x86_64.
542     if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
543         return True
546 set_config("MOZ_RUST_SIMD", rust_simd)
547 set_define("MOZ_RUST_SIMD", rust_simd)
550 # Support for wasm code generation with Cranelift
551 # ==============================================================
553 option(
554     "--enable-cranelift",
555     default=False,
556     help="{Enable|Disable} Cranelift code generator for wasm",
560 @depends(
561     "--enable-cranelift",
562     "--enable-jit",
563     "--enable-simulator",
564     target,
565     target_is_windows,
567 def enable_cranelift(value, jit_enabled, simulator, target, is_windows):
568     if not value:
569         return
571     if not jit_enabled:
572         die("--enable-cranelift requires --enable-jit")
574     if not (
575         target.cpu == "aarch64"
576         or (target.cpu == "x86_64" and simulator and simulator[0] == "arm64")
577     ):
578         die("--enable-cranelift is only supported on arm64")
580     if is_windows:
581         die("--enable-cranelift is not supported on windows")
583     return True
586 set_config("ENABLE_WASM_CRANELIFT", enable_cranelift)
587 set_define("ENABLE_WASM_CRANELIFT", enable_cranelift)
590 # Telemetry to measure compile time and generated-code runtime
591 # ============================================================
593 option(
594     "--enable-spidermonkey-telemetry",
595     default=milestone.is_nightly,
596     help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
599 set_define(
600     "ENABLE_SPIDERMONKEY_TELEMETRY",
601     depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
604 # Support for debugging code generated by wasm backends
605 # =====================================================
607 option(
608     "--enable-wasm-codegen-debug",
609     default=depends(when=moz_debug)(lambda: True),
610     help="{Enable|Disable} debugging for wasm codegen",
613 set_config(
614     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
616 set_define(
617     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
620 # Support for WebAssembly function-references.
621 # ===========================
624 @depends(milestone.is_nightly)
625 def default_wasm_function_references(is_nightly):
626     if is_nightly:
627         return True
630 option(
631     "--enable-wasm-function-references",
632     default=default_wasm_function_references,
633     help="{Enable|Disable} WebAssembly function-references",
637 @depends("--enable-wasm-function-references")
638 def wasm_function_references(value):
639     if value:
640         return True
643 set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
644 set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
646 # Support for WebAssembly GC.
647 # ===========================
650 @depends(milestone.is_nightly, "--enable-wasm-function-references")
651 def default_wasm_gc(is_nightly, function_references):
652     if is_nightly and function_references:
653         return True
656 option(
657     "--enable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
661 @depends("--enable-wasm-gc", "--enable-wasm-function-references")
662 def wasm_gc(value, function_references):
663     if not value:
664         return
666     if function_references:
667         return True
669     die("--enable-wasm-gc only possible with --enable-wasm-function-references")
672 set_config("ENABLE_WASM_GC", wasm_gc)
673 set_define("ENABLE_WASM_GC", wasm_gc)
676 # Support for WebAssembly private ref types.
677 # Prevent (ref T) types from being exposed to JS content so that wasm need do
678 # no typechecking at the JS/wasm boundary
679 # ===========================================================================
682 @depends(milestone.is_nightly, "--enable-wasm-gc")
683 def default_wasm_private_reftypes(is_nightly, gc):
684     if gc and is_nightly:
685         return True
688 option(
689     "--enable-wasm-private-reftypes",
690     default=default_wasm_private_reftypes,
691     help="{Enable|Disable} WebAssembly private reference types",
694 set_config(
695     "WASM_PRIVATE_REFTYPES",
696     depends_if("--enable-wasm-private-reftypes")(lambda x: True),
698 set_define(
699     "WASM_PRIVATE_REFTYPES",
700     depends_if("--enable-wasm-private-reftypes")(lambda x: True),
703 # Support for WebAssembly shared memory and atomics.
705 # This affects the JS shell only and here to allow the use of
706 # Cranelift in the shell.  Once Cranelift supports shared memory
707 # and atomics it can go away.
708 # =====================================================
710 option(
711     "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
715 @depends("--disable-shared-memory")
716 def enable_shared_memory(value):
717     if value:
718         return True
721 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
722 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
724 # Support for WebAssembly extended constant expressions
725 # =====================================================
728 @depends(milestone.is_nightly)
729 def default_wasm_extended_const(is_nightly):
730     if is_nightly:
731         return True
734 option(
735     "--enable-wasm-extended-const",
736     default=default_wasm_extended_const,
737     help="{Enable|Disable} WebAssembly extended constant expressions",
741 @depends("--enable-wasm-extended-const")
742 def wasm_extended_const(value):
743     if value:
744         return True
747 set_config("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
748 set_define("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
750 # Support for WebAssembly SIMD
751 # =====================================================
754 @depends("--enable-jit", "--enable-simulator", "--enable-cranelift", target)
755 def default_wasm_simd(jit_enabled, simulator, cranelift_enabled, target):
756     if not jit_enabled:
757         return
759     if cranelift_enabled:
760         return
762     if simulator and (simulator[0] != "arm64"):
763         return
765     if target.cpu in ("x86_64", "x86", "aarch64"):
766         return True
769 option(
770     "--enable-wasm-simd",
771     default=default_wasm_simd,
772     help="{Enable|Disable} WebAssembly SIMD",
776 @depends(
777     "--enable-wasm-simd",
778     "--enable-jit",
779     "--enable-simulator",
780     "--enable-cranelift",
781     target,
783 def wasm_simd(value, jit_enabled, simulator, cranelift_enabled, target):
784     if not value:
785         return
787     if not jit_enabled:
788         die("--enable-wasm-simd requires --enable-jit")
790     if cranelift_enabled:
791         die("--enable-wasm-simd is not supported for --enable-cranelift")
793     if simulator and (simulator[0] != "arm64"):
794         die("--enable-wasm-simd is not supported for simulators, except arm64")
796     if target.cpu in ("x86_64", "x86", "aarch64"):
797         return True
799     die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
802 set_config("ENABLE_WASM_SIMD", wasm_simd)
803 set_define("ENABLE_WASM_SIMD", wasm_simd)
805 # Wormhole opcodes are Intel-only.  They are private to Firefox, but we need them for some
806 # experiments on release and so they ride the trains.
809 @depends("--enable-simulator", "--enable-wasm-simd", target)
810 def default_wasm_simd_wormhole(simulator, wasm_simd, target):
811     if wasm_simd and target.cpu in ("x86", "x86_64") and not simulator:
812         return True
815 option(
816     "--enable-wasm-simd-wormhole",
817     default=default_wasm_simd_wormhole,
818     help="{Enable|Disable} WebAssembly SIMD wormhole opcodes",
822 @depends(
823     "--enable-wasm-simd-wormhole", "--enable-wasm-simd", "--enable-simulator", target
825 def wasm_simd_wormhole(value, wasm_simd, simulator, target):
826     if not value:
827         return
829     if wasm_simd and target.cpu in ("x86", "x86_64") and not simulator:
830         return True
832     die("SIMD wormhole currently supported on native x86/x64 only, with --wasm-simd")
835 set_config("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
836 set_define("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
839 # Support for WebAssembly relaxed SIMD
840 # =====================================================
843 @depends(milestone.is_nightly, "--enable-wasm-simd")
844 def default_wasm_relaxed_simd(is_nightly, wasm_simd):
845     if is_nightly and wasm_simd:
846         return True
849 option(
850     "--enable-wasm-relaxed-simd",
851     default=default_wasm_relaxed_simd,
852     help="{Enable|Disable} WebAssembly relaxed SIMD",
856 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd")
857 def wasm_relaxed_simd(value, wasm_simd):
858     if not value:
859         return
861     if not wasm_simd:
862         die("relaxed SIMD requires SIMD")
864     return True
867 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
868 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
870 # Support for WebAssembly intgemm private intrinsics
871 # =====================================================
874 @depends(milestone.is_nightly)
875 def default_wasm_moz_intgemm(is_nightly):
876     if is_nightly:
877         return True
880 option(
881     "--enable-wasm-moz-intgemm",
882     default=default_wasm_moz_intgemm,
883     help="{Enable|Disable} WebAssembly intgemm private intrinsics",
887 @depends("--enable-wasm-moz-intgemm")
888 def wasm_moz_intgemm(value):
889     if not value:
890         return
892     return True
895 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
896 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
898 # Support for WebAssembly Memory64.
899 # ===========================
901 option(
902     "--enable-wasm-memory64",
903     default=False,
904     help="{Enable|Disable} WebAssembly Memory64",
908 @depends("--enable-wasm-memory64")
909 def wasm_memory64(value):
910     if value:
911         return True
914 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
915 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
917 # Options for generating the shell as a script
918 # ============================================
919 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
920 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
922 option(
923     "--with-cross-lib",
924     nargs=1,
925     default=depends(target.alias)(lambda x: "/usr/%s" % x),
926     help="Use dir as the location for arm libraries",
928 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
930 # Enable static checking using sixgill
931 # ====================================
933 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
936 @depends_if("--with-sixgill")
937 @imports("os")
938 def sixgill(value):
939     for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
940         if not os.path.exists(os.path.join(value[0], f)):
941             die("The sixgill plugin and binaries are not at the specified path")
942     return value[0]
945 set_config("SIXGILL_PATH", sixgill)
948 # Support for readline
949 # =====================================================
952 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
953 def editline(js_shell, is_windows, compile_environment, target):
954     return js_shell and not is_windows and compile_environment and (target.os != "WASI")
957 option(
958     "--enable-readline", help="Link js shell to system readline library", when=editline
961 has_readline = check_symbol(
962     "readline",
963     flags=["-lreadline"],
964     when="--enable-readline",
965     onerror=lambda: die("No system readline library found"),
968 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
971 @depends("--enable-readline", editline, when=editline)
972 def bundled_editline(readline, editline):
973     return editline and not readline
976 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
978 set_define("EDITLINE", True, when=editline)
981 # JIT observers
982 # =============
984 option(
985     "--with-jitreport-granularity",
986     default="3",
987     choices=("0", "1", "2", "3"),
988     help="Default granularity at which to report JIT code to external tools "
989     "(0 - no info, 1 - code ranges for while functions only, "
990     "2 - per-line information, 3 - per-op information)",
993 set_define(
994     "JS_DEFAULT_JITREPORT_GRANULARITY",
995     depends_if("--with-jitreport-granularity")(lambda value: value[0]),
999 # ECMAScript Internationalization API Support (uses ICU)
1000 # ======================================================
1001 system_lib_option("--with-system-icu", help="Use system ICU")
1003 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 69.1", when="--with-system-icu")
1005 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1006 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1008 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1011 @depends("--with-intl-api", js_standalone)
1012 def check_intl_api(enabled, js_standalone):
1013     if not enabled and not js_standalone:
1014         die("--without-intl-api is not supported")
1017 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1018 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1021 @depends(check_build_environment, when="--with-intl-api")
1022 @imports(_from="__builtin__", _import="open")
1023 @imports(_from="__builtin__", _import="ValueError")
1024 def icu_version(build_env):
1025     path = os.path.join(
1026         build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1027     )
1028     with open(path, encoding="utf-8") as fh:
1029         for line in fh:
1030             if line.startswith("#define"):
1031                 define = line.split(None, 3)
1032                 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1033                     try:
1034                         return str(int(define[2]))
1035                     except ValueError:
1036                         pass
1037     die("Cannot determine ICU version number from uvernum.h header file")
1040 set_config("MOZ_ICU_VERSION", icu_version)
1042 # Source files that use ICU should have control over which parts of the ICU
1043 # namespace they want to use.
1044 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1046 # We build ICU as a static library.
1047 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1050 # Initial support for WebAssembly JS-API Type Reflections
1051 # =======================================================
1054 @depends(milestone.is_nightly)
1055 def default_wasm_type_reflections(is_nightly):
1056     return is_nightly
1059 option(
1060     "--enable-wasm-type-reflections",
1061     default=default_wasm_type_reflections,
1062     help="{Enable|Disable} type reflection in WASM JS-API",
1065 set_config(
1066     "ENABLE_WASM_TYPE_REFLECTIONS",
1067     depends_if("--enable-wasm-type-reflections")(lambda x: True),
1069 set_define(
1070     "ENABLE_WASM_TYPE_REFLECTIONS",
1071     depends_if("--enable-wasm-type-reflections")(lambda x: True),
1074 # Support for WebAssembly exceptions
1075 # ==================================
1078 @depends(milestone.is_nightly)
1079 def default_wasm_exceptions(is_nightly):
1080     if is_nightly:
1081         return True
1084 option(
1085     "--enable-wasm-exceptions",
1086     default=default_wasm_exceptions,
1087     help="{Enable|Disable} WebAssembly exceptions",
1090 set_config(
1091     "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)
1093 set_define(
1094     "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)