Bug 1681763 [wpt PR 26839] - WPT test: referrer on navigation from opaque origin...
[gecko.git] / js / moz.configure
blob12032c793fa7279afa548b7196ba6d90ad4fa310
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 option(env="NO_RUST_PANIC_HOOK", when=js_standalone, help="Disable rust panic hook")
138 set_define("NO_RUST_PANIC_HOOK", True, when="NO_RUST_PANIC_HOOK")
141 # JIT support
142 # =======================================================
143 @depends(target)
144 def jit_default(target):
145     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "mips32", "mips64"):
146         return True
147     return False
150 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
153 @deprecated_option("--enable-ion")
154 def report_deprecated(value):
155     if value:
156         die("--enable-ion is deprecated, use --enable-jit instead")
157     else:
158         die("--disable-ion is deprecated, use --disable-jit instead")
161 # JIT code simulator for cross compiles
162 # =======================================================
163 option(
164     "--enable-simulator",
165     choices=("arm", "arm64", "mips32", "mips64"),
166     nargs=1,
167     help="Enable a JIT code simulator for the specified architecture",
171 @depends("--enable-jit", "--enable-simulator", target, "--help")
172 def simulator(jit_enabled, simulator_enabled, target, _):
173     if not jit_enabled or not simulator_enabled:
174         return
176     sim_cpu = simulator_enabled[0]
178     if sim_cpu in ("arm", "mips32"):
179         if target.cpu != "x86":
180             die("The %s simulator only works on x86." % sim_cpu)
182     if sim_cpu in ("arm64", "mips64"):
183         if target.cpu != "x86_64":
184             die("The %s simulator only works on x86-64." % sim_cpu)
186     return namespace(**{sim_cpu: True})
189 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
190 set_config("JS_SIMULATOR_ARM", simulator.arm)
191 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
192 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
193 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
194 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
195 set_define("JS_SIMULATOR_ARM", simulator.arm)
196 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
197 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
198 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
201 @depends("--enable-jit", simulator, target)
202 def jit_codegen(jit_enabled, simulator, target):
203     if not jit_enabled:
204         return namespace(none=True)
206     if simulator:
207         return simulator
209     if target.cpu == "aarch64":
210         return namespace(arm64=True)
211     elif target.cpu == "x86_64":
212         return namespace(x64=True)
214     return namespace(**{str(target.cpu): True})
217 set_config("JS_CODEGEN_NONE", jit_codegen.none)
218 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
219 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
220 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
221 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
222 set_config("JS_CODEGEN_X86", jit_codegen.x86)
223 set_config("JS_CODEGEN_X64", jit_codegen.x64)
224 set_define("JS_CODEGEN_NONE", jit_codegen.none)
225 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
226 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
227 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
228 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
229 set_define("JS_CODEGEN_X86", jit_codegen.x86)
230 set_define("JS_CODEGEN_X64", jit_codegen.x64)
232 # Profiling
233 # =======================================================
234 option(
235     "--enable-instruments",
236     env="MOZ_INSTRUMENTS",
237     help="Enable instruments remote profiling",
241 @depends("--enable-instruments", target)
242 def instruments(value, target):
243     if value and target.os != "OSX":
244         die("--enable-instruments cannot be used when targeting %s", target.os)
245     if value:
246         return True
249 set_config("MOZ_INSTRUMENTS", instruments)
250 set_define("MOZ_INSTRUMENTS", instruments)
251 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
252 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
254 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
257 @depends("--enable-callgrind")
258 def callgrind(value):
259     if value:
260         return True
263 set_define("MOZ_CALLGRIND", callgrind)
264 imply_option("--enable-profiling", callgrind)
267 @depends(milestone)
268 def enable_profiling(milestone):
269     return milestone.is_nightly
272 option(
273     "--enable-profiling",
274     env="MOZ_PROFILING",
275     default=enable_profiling,
276     help="{Set|Do not set} compile flags necessary for using sampling "
277     "profilers (e.g. shark, perf)",
281 @depends("--enable-profiling")
282 def profiling(value):
283     if value:
284         return True
287 add_old_configure_assignment("MOZ_PROFILING", profiling)
289 with only_when("--enable-compile-environment"):
290     imply_option("--enable-frame-pointers", True, when=profiling)
293 @depends(profiling, target)
294 def imply_vtune(value, target):
295     ok_cpu = target.cpu in ["x86", "x86_64"]
296     ok_kernel = target.kernel == "WINNT" or (
297         target.kernel == "Linux" and target.os == "GNU"
298     )
300     if value and ok_cpu and ok_kernel:
301         return True
304 set_config("MOZ_PROFILING", profiling)
305 set_define("MOZ_PROFILING", profiling)
306 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
309 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
312 @depends("--enable-vtune")
313 def vtune(value):
314     if value:
315         return True
318 set_config("MOZ_VTUNE", vtune)
319 set_define("MOZ_VTUNE", vtune)
322 option(
323     "--enable-gc-probes",
324     env="JS_GC_PROBES",
325     help="Turn on probes for allocation and finalization",
329 @depends("--enable-gc-probes")
330 def gc_probes(value):
331     if value:
332         return True
335 set_define("JS_GC_PROBES", gc_probes)
338 option(
339     "--enable-gczeal",
340     default=depends(when=moz_debug)(lambda: True),
341     help="{Enable|Disable} zealous GCing",
344 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
347 # Use a smaller chunk size for GC chunks
348 # ========================================================
349 # Use large (1MB) chunks by default.  This option can be used to give
350 # smaller (currently 256K) chunks.
351 option(
352     "--enable-small-chunk-size",
353     help="Allocate memory for JS GC things in smaller chunks",
356 set_define(
357     "JS_GC_SMALL_CHUNK_SIZE", depends(when="--enable-small-chunk-size")(lambda: True)
361 # Trace logging.
362 # =======================================================
363 @depends(milestone)
364 def default_trace_logging(milestone):
365     return milestone.is_nightly
368 option(
369     "--enable-trace-logging",
370     default=default_trace_logging,
371     help="{Enable|Disable} trace logging",
374 set_config("ENABLE_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
375 set_define("JS_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
378 # Enable breakpoint for artificial OOMs
379 # =======================================================
380 option(
381     "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
384 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
387 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
390 @depends("--enable-perf")
391 def ion_perf(value):
392     if value:
393         return True
396 set_define("JS_ION_PERF", ion_perf)
399 option(
400     "--enable-jitspew",
401     default=depends(when=moz_debug)(lambda: True),
402     help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
405 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
406 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
408 # Also enable the structured spewer
409 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
410 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
413 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
414 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
415     if not jit_enabled:
416         return
418     if simulator and (debug or spew):
419         if getattr(simulator, "arm", None):
420             return True
422     if target.cpu == "arm" and (debug or spew):
423         return True
426 set_config("JS_DISASM_ARM", jit_disasm_arm)
427 set_define("JS_DISASM_ARM", jit_disasm_arm)
430 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
431 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
432     if not jit_enabled:
433         return
435     if simulator and (debug or spew):
436         if getattr(simulator, "arm64", None):
437             return True
439     if target.cpu == "aarch64" and (debug or spew):
440         return True
443 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
444 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
446 # When enabled, masm will generate assumeUnreachable calls that act as
447 # assertions in the generated code. This option is worth disabling when you
448 # have to track mutated values through the generated code, to avoid constantly
449 # dumping registers on and off the stack.
450 option(
451     "--enable-masm-verbose",
452     default=depends(when=moz_debug)(lambda: True),
453     help="{Enable|Disable} MacroAssembler verbosity of generated code.",
455 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
456 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
459 # CTypes
460 # =======================================================
461 @depends(js_standalone)
462 def ctypes_default(js_standalone):
463     return not js_standalone
466 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
468 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
470 set_config("BUILD_CTYPES", build_ctypes)
471 set_define("BUILD_CTYPES", build_ctypes)
473 set_config("JS_HAS_CTYPES", build_ctypes)
474 set_define("JS_HAS_CTYPES", build_ctypes)
477 @depends("--enable-ctypes", "--enable-compile-environment")
478 def ctypes_and_compile_environment(ctypes, compile_environment):
479     return ctypes and compile_environment
482 include("ffi.configure", when=ctypes_and_compile_environment)
485 # Enable pipeline operator
486 # ===================================================
487 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
490 @depends("--enable-pipeline-operator")
491 def enable_pipeline_operator(value):
492     if value:
493         return True
496 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
497 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
500 # SIMD acceleration for encoding_rs
501 # ==============================================================
503 option(
504     "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
508 @depends("--enable-rust-simd", target)
509 def rust_simd(value, target):
510     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
511     # been properly set up outside aarch64, armv7, x86 and x86_64.
512     if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
513         return True
516 set_config("MOZ_RUST_SIMD", rust_simd)
517 set_define("MOZ_RUST_SIMD", rust_simd)
520 # Support for wasm code generation with Cranelift
521 # ==============================================================
524 @depends(
525     milestone.is_nightly,
526     "--enable-jit",
527     "--enable-simulator",
528     target,
529     target_is_windows,
531 def cranelift_default(is_nightly, jit_enabled, simulator, target, is_windows):
532     if is_nightly and jit_enabled and not is_windows:
533         if target.cpu == "aarch64":
534             return True
535         if simulator and simulator[0] == "arm64":
536             return True
539 option(
540     "--enable-cranelift",
541     default=cranelift_default,
542     help="{Enable|Disable} Cranelift code generator for wasm",
545 set_config("ENABLE_WASM_CRANELIFT", depends_if("--enable-cranelift")(lambda x: True))
546 set_define("ENABLE_WASM_CRANELIFT", depends_if("--enable-cranelift")(lambda x: True))
548 # Telemetry to measure compile time and generated-code runtime
549 # ============================================================
551 option(
552     "--enable-spidermonkey-telemetry",
553     default=milestone.is_nightly,
554     help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
557 set_define(
558     "ENABLE_SPIDERMONKEY_TELEMETRY",
559     depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
562 # Support for debugging code generated by wasm backends
563 # =====================================================
565 option(
566     "--enable-wasm-codegen-debug",
567     default=depends(when=moz_debug)(lambda: True),
568     help="{Enable|Disable} debugging for wasm codegen",
571 set_config(
572     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
574 set_define(
575     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
578 # Support for WebAssembly reference types.
579 # =====================================================
581 option("--disable-wasm-reftypes", help="Disable WebAssembly reference types")
584 @depends("--disable-wasm-reftypes")
585 def enable_wasm_reftypes(value):
586     if value:
587         return True
590 set_config("ENABLE_WASM_REFTYPES", enable_wasm_reftypes)
591 set_define("ENABLE_WASM_REFTYPES", enable_wasm_reftypes)
593 # Support for WebAssembly function-references.
594 # ===========================
597 @depends(milestone.is_nightly, "--disable-wasm-reftypes")
598 def default_wasm_function_references(is_nightly, reftypes):
599     if is_nightly and reftypes:
600         return True
603 option(
604     "--enable-wasm-function-references",
605     default=default_wasm_function_references,
606     help="{Enable|Disable} WebAssembly function-references",
610 @depends("--enable-wasm-function-references", "--disable-wasm-reftypes")
611 def wasm_function_references(value, reftypes):
612     if not value:
613         return
615     if reftypes:
616         return True
618     die(
619         "--enable-wasm-function-references only possible without --disable-wasm-reftypes"
620     )
623 set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
624 set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
626 # Support for WebAssembly GC.
627 # ===========================
630 @depends(milestone.is_nightly, "--enable-wasm-function-references")
631 def default_wasm_gc(is_nightly, function_references):
632     if is_nightly and function_references:
633         return True
636 option(
637     "--enable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
641 @depends("--enable-wasm-gc", "--enable-wasm-function-references")
642 def wasm_gc(value, function_references):
643     if not value:
644         return
646     if function_references:
647         return True
649     die("--enable-wasm-gc only possible with --enable-wasm-function-references")
652 set_config("ENABLE_WASM_GC", wasm_gc)
653 set_define("ENABLE_WASM_GC", wasm_gc)
656 # Support for WebAssembly private ref types.
657 # Prevent (ref T) types from being exposed to JS content so that wasm need do
658 # no typechecking at the JS/wasm boundary
659 # ===========================================================================
662 @depends(milestone.is_nightly, "--enable-wasm-gc")
663 def default_wasm_private_reftypes(is_nightly, gc):
664     if gc and is_nightly:
665         return True
668 option(
669     "--enable-wasm-private-reftypes",
670     default=default_wasm_private_reftypes,
671     help="{Enable|Disable} WebAssembly private reference types",
674 set_config(
675     "WASM_PRIVATE_REFTYPES",
676     depends_if("--enable-wasm-private-reftypes")(lambda x: True),
678 set_define(
679     "WASM_PRIVATE_REFTYPES",
680     depends_if("--enable-wasm-private-reftypes")(lambda x: True),
684 # Support for the WebAssembly multi-value proposal.
685 # Do not remove until Cranelift supports multi-value.
686 # =====================================================
688 option(
689     "--disable-wasm-multi-value",
690     help="Disable WebAssembly multi-value blocks and function calls",
694 @depends("--disable-wasm-multi-value")
695 def enable_wasm_multi_value(value):
696     if value:
697         return True
700 set_config("ENABLE_WASM_MULTI_VALUE", enable_wasm_multi_value)
701 set_define("ENABLE_WASM_MULTI_VALUE", enable_wasm_multi_value)
704 # Support for WebAssembly shared memory and atomics.
706 # This affects the JS shell only and here to allow the use of
707 # Cranelift in the shell.  Once Cranelift supports shared memory
708 # and atomics it can go away.
709 # =====================================================
711 option(
712     "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
716 @depends("--disable-shared-memory")
717 def enable_shared_memory(value):
718     if value:
719         return True
722 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
723 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
726 # Support for WebAssembly SIMD
727 # =====================================================
730 @depends("--enable-jit", "--enable-simulator", target)
731 def default_wasm_simd(jit_enabled, simulator, target):
732     if not jit_enabled or simulator:
733         return
735     if target.cpu in ("x86_64", "x86", "aarch64"):
736         return True
739 option(
740     "--enable-wasm-simd",
741     default=default_wasm_simd,
742     help="{Enable|Disable} WebAssembly SIMD",
746 @depends("--enable-wasm-simd", "--enable-jit", "--enable-simulator", target)
747 def wasm_simd(value, jit_enabled, simulator, target):
748     if not value:
749         return
751     if jit_enabled and not simulator:
752         if target.cpu in ("x86_64", "x86", "aarch64"):
753             return True
755     if jit_enabled and simulator and simulator[0] == "arm64":
756         return True
758     die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
761 set_config("ENABLE_WASM_SIMD", wasm_simd)
762 set_define("ENABLE_WASM_SIMD", wasm_simd)
764 # Experimental SIMD opcodes are Nightly-only by default
767 @depends(milestone.is_nightly, "--enable-wasm-simd")
768 def default_wasm_simd_experimental(is_nightly, wasm_simd):
769     if is_nightly and wasm_simd:
770         return True
773 option(
774     "--enable-wasm-simd-experimental",
775     default=default_wasm_simd_experimental,
776     help="{Enable|Disable} WebAssembly SIMD experimental opcodes",
780 @depends("--enable-wasm-simd-experimental", "--enable-wasm-simd")
781 def wasm_simd_experimental(value, wasm_simd):
782     if not value:
783         return
785     if wasm_simd:
786         return True
788     die("--enable-wasm-simd-experimental only possible with --enable-wasm-simd")
791 set_config("ENABLE_WASM_SIMD_EXPERIMENTAL", wasm_simd_experimental)
792 set_define("ENABLE_WASM_SIMD_EXPERIMENTAL", wasm_simd_experimental)
794 # Wormhole opcodes are experimental *and* x64-only
797 @depends("--enable-wasm-simd-experimental", target)
798 def default_wasm_simd_wormhole(wasm_simd_experimental, target):
799     if wasm_simd_experimental and target.cpu == "x86_64":
800         return True
803 option(
804     "--enable-wasm-simd-wormhole",
805     default=default_wasm_simd_wormhole,
806     help="{Enable|Disable} WebAssembly SIMD wormhole opcodes",
810 @depends("--enable-wasm-simd-wormhole", "--enable-wasm-simd-experimental", target)
811 def wasm_simd_wormhole(value, wasm_simd_experimental, target):
812     if not value:
813         return
815     if not wasm_simd_experimental:
816         die("SIMD wormhole also requires --enable-wasm-simd-experimental.")
818     if target.cpu != "x86_64":
819         die("SIMD wormhole is only available on x86_64.")
821     return True
824 set_config("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
825 set_define("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
828 # Options for generating the shell as a script
829 # ============================================
830 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
831 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
833 option(
834     "--with-cross-lib",
835     nargs=1,
836     default=depends(target.alias)(lambda x: "/usr/%s" % x),
837     help="Use dir as the location for arm libraries",
839 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
841 # Enable static checking using sixgill
842 # ====================================
844 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
847 @depends_if("--with-sixgill")
848 @imports("os")
849 def sixgill(value):
850     for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
851         if not os.path.exists(os.path.join(value[0], f)):
852             die("The sixgill plugin and binaries are not at the specified path")
853     return value[0]
856 set_config("SIXGILL_PATH", sixgill)
859 # Support for readline
860 # =====================================================
861 @depends("--enable-js-shell", target_is_windows, compile_environment)
862 def editline(js_shell, is_windows, compile_environment):
863     return js_shell and not is_windows and compile_environment
866 option(
867     "--enable-readline", help="Link js shell to system readline library", when=editline
870 has_readline = check_symbol(
871     "readline",
872     flags=["-lreadline"],
873     when="--enable-readline",
874     onerror=lambda: die("No system readline library found"),
877 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
880 @depends("--enable-readline", editline, when=editline)
881 def bundled_editline(readline, editline):
882     return editline and not readline
885 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
887 set_define("EDITLINE", True, when=editline)
890 # JIT observers
891 # =============
893 option(
894     "--with-jitreport-granularity",
895     default="3",
896     choices=("0", "1", "2", "3"),
897     help="Default granularity at which to report JIT code to external tools "
898     "(0 - no info, 1 - code ranges for while functions only, "
899     "2 - per-line information, 3 - per-op information)",
902 set_define(
903     "JS_DEFAULT_JITREPORT_GRANULARITY",
904     depends_if("--with-jitreport-granularity")(lambda value: value[0]),
908 # ECMAScript Internationalization API Support (uses ICU)
909 # ======================================================
910 option("--with-system-icu", help="Use system ICU")
912 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 67.1", when="--with-system-icu")
914 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
915 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
917 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
920 @depends("--with-intl-api", js_standalone)
921 def check_intl_api(enabled, js_standalone):
922     if not enabled and not js_standalone:
923         die("--without-intl-api is not supported")
926 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
927 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
930 @depends(check_build_environment, when="--with-intl-api")
931 @imports(_from="__builtin__", _import="open")
932 @imports(_from="__builtin__", _import="ValueError")
933 def icu_version(build_env):
934     path = os.path.join(
935         build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
936     )
937     with open(path, encoding="utf-8") as fh:
938         for line in fh:
939             if line.startswith("#define"):
940                 define = line.split(None, 3)
941                 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
942                     try:
943                         return str(int(define[2]))
944                     except ValueError:
945                         pass
946     die("Cannot determine ICU version number from uvernum.h header file")
949 set_config("MOZ_ICU_VERSION", icu_version)
951 # Source files that use ICU should have control over which parts of the ICU
952 # namespace they want to use.
953 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
955 # We build ICU as a static library.
956 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
959 @depends(yasm, gnu_as, target, compile_environment)
960 def can_build_data_file(yasm, gnu_as, target, compile_environment):
961     if not compile_environment or (
962         target.kernel == "WINNT" and target.cpu == "aarch64"
963     ):
964         return
965     if not yasm and not gnu_as:
966         die(
967             "Building ICU requires either yasm or a GNU assembler. If you do not have "
968             "either of those available for this platform you must use --without-intl-api"
969         )
972 # Initial support for WebAssembly JS-API Type Reflections
973 # =======================================================
976 @depends(milestone.is_nightly)
977 def default_wasm_type_reflections(is_nightly):
978     return is_nightly
981 option(
982     "--enable-wasm-type-reflections",
983     default=default_wasm_type_reflections,
984     help="{Enable|Disable} type reflection in WASM JS-API",
987 set_config(
988     "ENABLE_WASM_TYPE_REFLECTIONS",
989     depends_if("--enable-wasm-type-reflections")(lambda x: True),
991 set_define(
992     "ENABLE_WASM_TYPE_REFLECTIONS",
993     depends_if("--enable-wasm-type-reflections")(lambda x: True),
996 # Support for WebAssembly exceptions
997 # ==================================
1000 @depends(milestone.is_nightly, "--enable-wasm-multi-value")
1001 def default_wasm_exceptions(is_nightly, multi_value):
1002     if multi_value and is_nightly:
1003         return True
1006 option(
1007     "--enable-wasm-exceptions",
1008     default=default_wasm_exceptions,
1009     help="{Enable|Disable} WebAssembly exceptions",
1012 set_config(
1013     "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)
1015 set_define(
1016     "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)