no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / js / moz.configure
blob760507eee26424eebd61dad6a9c820914b784a4e
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)
176 # Enable JSON.parse with source
177 # ===================================================
178 option(
179     "--enable-json-parse-with-source",
180     default=False,
181     help="Enable experimental JS JSON.parse with source support",
185 @depends("--enable-json-parse-with-source")
186 def enable_json_parse_with_source(value):
187     if value:
188         return True
191 set_config("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
192 set_define("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
195 # Portable Baseline Intepreter
196 # =======================================================
197 option(
198     "--enable-portable-baseline-interp",
199     default=False,
200     help="{Enable|Disable} the portable baseline interpreter.",
202 set_define(
203     "ENABLE_PORTABLE_BASELINE_INTERP",
204     depends_if("--enable-portable-baseline-interp")(lambda _: True),
206 set_config(
207     "ENABLE_PORTABLE_BASELINE_INTERP",
208     depends_if("--enable-portable-baseline-interp")(lambda _: True),
211 # Option to always force PBL tier.
212 option(
213     "--enable-portable-baseline-interp-force",
214     default=False,
215     help="{Enable|Disable} forcing use of the portable baseline interpreter.",
218 set_define(
219     "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
220     depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
222 set_config(
223     "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
224     depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
228 # JIT support
229 # =======================================================
230 @depends(target, "--enable-record-tuple", "--enable-portable-baseline-interp")
231 def jit_default(target, enable_record_tuple, enable_portable_baseline_interp):
232     if enable_record_tuple:
233         return False
234     if enable_portable_baseline_interp:
235         return False
236     if target.cpu in (
237         "x86",
238         "x86_64",
239         "arm",
240         "aarch64",
241         "mips32",
242         "mips64",
243         "loongarch64",
244     ):
245         return True
246     return False
249 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
252 @deprecated_option("--enable-ion")
253 def report_deprecated(value):
254     if value:
255         die("--enable-ion is deprecated, use --enable-jit instead")
256     else:
257         die("--disable-ion is deprecated, use --disable-jit instead")
260 # JIT code simulator for cross compiles
261 # =======================================================
262 option(
263     "--enable-simulator",
264     choices=("arm", "arm64", "mips32", "mips64", "loong64", "riscv64"),
265     nargs=1,
266     help="Enable a JIT code simulator for the specified architecture",
270 @depends("--enable-jit", "--enable-simulator", target)
271 def simulator(jit_enabled, simulator_enabled, target):
272     if not jit_enabled or not simulator_enabled:
273         return
275     sim_cpu = simulator_enabled[0]
277     if sim_cpu in ("arm", "mips32"):
278         if target.cpu != "x86":
279             die("The %s simulator only works on x86." % sim_cpu)
281     if sim_cpu in ("arm64", "mips64", "loong64", "riscv64"):
282         if target.cpu != "x86_64" and target.cpu != "aarch64":
283             die("The %s simulator only works on x86-64 or arm64." % sim_cpu)
285     return namespace(**{sim_cpu: True})
288 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
289 set_config("JS_SIMULATOR_ARM", simulator.arm)
290 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
291 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
292 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
293 set_config("JS_SIMULATOR_LOONG64", simulator.loong64)
294 set_config("JS_SIMULATOR_RISCV64", simulator.riscv64)
295 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
296 set_define("JS_SIMULATOR_ARM", simulator.arm)
297 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
298 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
299 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
300 set_define("JS_SIMULATOR_LOONG64", simulator.loong64)
301 set_define("JS_SIMULATOR_RISCV64", simulator.riscv64)
304 @depends("--enable-jit", simulator, target)
305 def jit_codegen(jit_enabled, simulator, target):
306     if not jit_enabled:
307         return namespace(none=True)
309     if simulator:
310         return simulator
312     if target.cpu == "aarch64":
313         return namespace(arm64=True)
314     elif target.cpu == "x86_64":
315         return namespace(x64=True)
316     elif target.cpu == "loongarch64":
317         return namespace(loong64=True)
318     elif target.cpu == "riscv64":
319         return namespace(riscv64=True)
321     return namespace(**{str(target.cpu): True})
324 set_config("JS_CODEGEN_NONE", jit_codegen.none)
325 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
326 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
327 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
328 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
329 set_config("JS_CODEGEN_LOONG64", jit_codegen.loong64)
330 set_config("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
331 set_config("JS_CODEGEN_X86", jit_codegen.x86)
332 set_config("JS_CODEGEN_X64", jit_codegen.x64)
333 set_config("JS_CODEGEN_WASM32", jit_codegen.wasm32)
335 set_define("JS_CODEGEN_NONE", jit_codegen.none)
336 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
337 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
338 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
339 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
340 set_define("JS_CODEGEN_LOONG64", jit_codegen.loong64)
341 set_define("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
342 set_define("JS_CODEGEN_X86", jit_codegen.x86)
343 set_define("JS_CODEGEN_X64", jit_codegen.x64)
344 set_define("JS_CODEGEN_WASM32", jit_codegen.wasm32)
347 # Profiling
348 # =======================================================
349 option(
350     "--enable-instruments",
351     env="MOZ_INSTRUMENTS",
352     help="Enable instruments remote profiling",
356 @depends("--enable-instruments", target)
357 def instruments(value, target):
358     if value and target.os != "OSX":
359         die("--enable-instruments cannot be used when targeting %s", target.os)
360     if value:
361         return True
364 set_config("MOZ_INSTRUMENTS", instruments)
365 set_define("MOZ_INSTRUMENTS", instruments)
366 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
367 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
369 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
372 @depends("--enable-callgrind")
373 def callgrind(value):
374     if value:
375         return True
378 set_define("MOZ_CALLGRIND", callgrind)
379 imply_option("--enable-profiling", callgrind)
382 @depends(milestone)
383 def enable_profiling(milestone):
384     return milestone.is_nightly
387 option(
388     "--enable-profiling",
389     env="MOZ_PROFILING",
390     default=enable_profiling,
391     help="{Set|Do not set} compile flags necessary for using sampling "
392     "profilers (e.g. shark, perf)",
396 @depends("--enable-profiling")
397 def profiling(value):
398     if value:
399         return True
402 with only_when("--enable-compile-environment"):
403     imply_option("--enable-frame-pointers", True, when=profiling)
406 @depends(profiling, target)
407 def imply_vtune(value, target):
408     ok_cpu = target.cpu in ["x86", "x86_64"]
409     ok_kernel = target.kernel == "WINNT" or (
410         target.kernel == "Linux" and target.os == "GNU"
411     )
413     if value and ok_cpu and ok_kernel:
414         return True
417 set_config("MOZ_PROFILING", profiling)
418 set_define("MOZ_PROFILING", profiling)
419 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
422 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
425 @depends("--enable-vtune")
426 def vtune(value):
427     if value:
428         return True
431 set_config("MOZ_VTUNE", vtune)
432 set_define("MOZ_VTUNE", vtune)
435 option(
436     "--enable-gc-probes",
437     env="JS_GC_PROBES",
438     help="Turn on probes for allocation and finalization",
442 @depends("--enable-gc-probes")
443 def gc_probes(value):
444     if value:
445         return True
448 set_define("JS_GC_PROBES", gc_probes)
451 option(
452     "--enable-gczeal",
453     default=depends(when=moz_debug)(lambda: True),
454     help="{Enable|Disable} zealous GCing",
457 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
460 # Enable breakpoint for artificial OOMs
461 # =======================================================
462 option(
463     "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
466 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
469 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
472 @depends("--enable-perf", target)
473 def ion_perf(value, target):
474     is_linux = target.kernel == "Linux"
475     is_mac = target.kernel == "Darwin" and target.os == "OSX"
477     if value and (is_linux or is_mac):
478         return True
481 set_define("JS_ION_PERF", ion_perf)
484 option(
485     "--enable-jitspew",
486     default=depends(when=moz_debug)(lambda: True),
487     help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
490 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
491 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
493 # Also enable the structured spewer
494 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
495 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
498 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
499 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
500     if not jit_enabled:
501         return
503     if simulator and (debug or spew):
504         if getattr(simulator, "arm", None):
505             return True
507     if target.cpu == "arm" and (debug or spew):
508         return True
511 set_config("JS_DISASM_ARM", jit_disasm_arm)
512 set_define("JS_DISASM_ARM", jit_disasm_arm)
515 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
516 def jit_disasm_riscv(jit_enabled, spew, simulator, target, debug):
517     if not jit_enabled:
518         return
520     if simulator and (debug or spew):
521         if getattr(simulator, "riscv64", None):
522             return True
524     if target.cpu == "riscv64" and (debug or spew):
525         return True
528 set_config("JS_DISASM_RISCV64", jit_disasm_riscv)
529 set_define("JS_DISASM_RISCV64", jit_disasm_riscv)
532 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
533 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
534     if not jit_enabled:
535         return
537     if simulator and (debug or spew):
538         if getattr(simulator, "arm64", None):
539             return True
541     if target.cpu == "aarch64" and (debug or spew):
542         return True
545 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
546 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
548 # When enabled, masm will generate assumeUnreachable calls that act as
549 # assertions in the generated code. This option is worth disabling when you
550 # have to track mutated values through the generated code, to avoid constantly
551 # dumping registers on and off the stack.
552 option(
553     "--enable-masm-verbose",
554     default=depends(when=moz_debug)(lambda: True),
555     help="{Enable|Disable} MacroAssembler verbosity of generated code.",
557 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
558 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
560 # Architecture feature flags
561 # =======================================================
564 # Apple silicon does not seem to have any way to query the OS for the JSCVT
565 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
566 # hard code the value of the JSCVT flag which guards the implementation of
567 # FJCVTZS instruction as part of ARMv8.3-JSConv.
568 @depends(target)
569 def is_apple_silicon(target):
570     return target.os == "OSX" and target.kernel == "Darwin" and target.cpu == "aarch64"
573 option(
574     "--enable-arm64-fjcvtzs",
575     default=is_apple_silicon,
576     help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
580 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
581 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
582 # (D12.1.4).
584 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
585 @depends("--enable-arm64-fjcvtzs", target, simulator)
586 def aarch64_jscvt(fjcvtzs, target, simulator):
587     if target.cpu == "aarch64" and fjcvtzs:
588         return 1
590     if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
591         return 1
593     return 0
596 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
599 @depends(target)
600 def has_pthread_jit_write_protect_np(target):
601     return target.os == "OSX" and target.cpu == "aarch64"
604 # On Apple Silicon we use MAP_JIT with pthread_jit_write_protect_np to implement
605 # JIT code write protection.
606 set_define("JS_USE_APPLE_FAST_WX", True, when=has_pthread_jit_write_protect_np)
609 # CTypes
610 # =======================================================
611 @depends(js_standalone)
612 def ctypes_default(js_standalone):
613     return not js_standalone
616 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
618 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
620 set_config("BUILD_CTYPES", build_ctypes)
621 set_define("BUILD_CTYPES", build_ctypes)
623 set_config("JS_HAS_CTYPES", build_ctypes)
624 set_define("JS_HAS_CTYPES", build_ctypes)
627 @depends("--enable-ctypes", "--enable-compile-environment")
628 def ctypes_and_compile_environment(ctypes, compile_environment):
629     return ctypes and compile_environment
632 include("ffi.configure", when=ctypes_and_compile_environment)
635 # Enable pipeline operator
636 # ===================================================
637 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
640 @depends("--enable-pipeline-operator")
641 def enable_pipeline_operator(value):
642     if value:
643         return True
646 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
647 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
650 # SIMD acceleration for encoding_rs
651 # ==============================================================
653 option(
654     "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
658 @depends("--enable-rust-simd", target)
659 def rust_simd(value, target):
660     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
661     # been properly set up outside aarch64, armv7, x86 and x86_64.
662     if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
663         return True
666 set_config("MOZ_RUST_SIMD", rust_simd)
667 set_define("MOZ_RUST_SIMD", rust_simd)
669 # Telemetry to measure compile time and generated-code runtime
670 # ============================================================
672 option(
673     "--enable-spidermonkey-telemetry",
674     default=milestone.is_nightly,
675     help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
678 set_define(
679     "ENABLE_SPIDERMONKEY_TELEMETRY",
680     depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
683 # Support for debugging code generated by wasm backends
684 # =====================================================
686 option(
687     "--enable-wasm-codegen-debug",
688     default=depends(when=moz_debug)(lambda: True),
689     help="{Enable|Disable} debugging for wasm codegen",
692 set_config(
693     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
695 set_define(
696     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
699 # WebAssembly feature flags
700 # ==================================================
702 option(
703     "--wasm-no-experimental",
704     default=False,
705     help="Force disable all wasm experimental features for testing.",
708 # Support for WebAssembly function-references.
709 # ===========================
712 option(
713     "--disable-wasm-function-references",
714     default=True,
715     help="{Enable|Disable} WebAssembly function-references",
719 @depends("--disable-wasm-function-references", "--wasm-no-experimental")
720 def wasm_function_references(value, no_experimental):
721     if no_experimental:
722         return
724     if value:
725         return True
728 set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
729 set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
731 # Support for WebAssembly tail-calls.
732 # ===========================
735 @depends(target)
736 def default_wasm_tail_calls(target):
737     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
738         return True
741 option(
742     "--enable-wasm-tail-calls",
743     default=default_wasm_tail_calls,
744     help="{Enable|Disable} WebAssembly tail-calls",
748 @depends("--enable-wasm-tail-calls", target)
749 def wasm_tail_calls(value, target):
750     if not value:
751         return
753     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
754         return True
756     die(
757         "--enable-wasm-tail-calls only possible when targeting the x86_64/x86/arm64/arm/loongarch64/mips64 jits"
758     )
761 set_config("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
762 set_define("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
764 # Support for WebAssembly GC.
765 # ===========================
768 @depends("--disable-wasm-function-references")
769 def default_wasm_gc(function_references):
770     if function_references:
771         return True
774 option(
775     "--disable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
779 @depends(
780     "--disable-wasm-gc", "--disable-wasm-function-references", "--wasm-no-experimental"
782 def wasm_gc(value, function_references, no_experimental):
783     if no_experimental or not value:
784         return
786     if function_references:
787         return True
789     die("--disable-wasm-gc only possible with --disable-wasm-function-references")
792 set_config("ENABLE_WASM_GC", wasm_gc)
793 set_define("ENABLE_WASM_GC", wasm_gc)
795 # Support for WebAssembly JS String Builtins
796 # ==========================================
799 @depends(milestone.is_nightly)
800 def default_wasm_js_string_builtins(is_nightly):
801     if is_nightly:
802         return True
805 option(
806     "--enable-wasm-js-string-builtins",
807     default=default_wasm_js_string_builtins,
808     help="{Enable|Disable} WebAssembly JS String Builtins",
812 @depends("--enable-wasm-js-string-builtins", "--wasm-no-experimental")
813 def wasm_js_string_builtins(value, no_experimental):
814     if no_experimental or not value:
815         return
817     return True
820 set_config("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
821 set_define("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
823 # Support for WebAssembly shared memory and atomics.
825 # This affects the JS shell only.
826 # =====================================================
828 option(
829     "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
833 @depends("--disable-shared-memory")
834 def enable_shared_memory(value):
835     if value:
836         return True
839 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
840 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
842 # Support for WebAssembly extended constant expressions
843 # =====================================================
846 option(
847     "--disable-wasm-extended-const",
848     help="{Enable|Disable} WebAssembly extended constant expressions",
852 @depends("--disable-wasm-extended-const")
853 def wasm_extended_const(value):
854     if value:
855         return True
858 set_config("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
859 set_define("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
861 # Support for WebAssembly SIMD
862 # =====================================================
865 @depends("--enable-jit", "--enable-simulator", target)
866 def default_wasm_simd(jit_enabled, simulator, target):
867     if not jit_enabled:
868         return
870     if simulator and (simulator[0] != "arm64"):
871         return
873     if target.cpu in ("x86_64", "x86", "aarch64"):
874         return True
877 option(
878     "--enable-wasm-simd",
879     default=default_wasm_simd,
880     help="{Enable|Disable} WebAssembly SIMD",
884 @depends(
885     "--enable-wasm-simd",
886     "--enable-jit",
887     "--enable-simulator",
888     target,
889     "--wasm-no-experimental",
891 def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
892     if no_experimental or not value:
893         return
895     if not jit_enabled:
896         die("--enable-wasm-simd requires --enable-jit")
898     if simulator and (simulator[0] != "arm64"):
899         die("--enable-wasm-simd is not supported for simulators, except arm64")
901     if target.cpu in ("x86_64", "x86", "aarch64"):
902         return True
904     die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
907 set_config("ENABLE_WASM_SIMD", wasm_simd)
908 set_define("ENABLE_WASM_SIMD", wasm_simd)
910 # Whether to check for field changes in WebAssembly serialization
912 # See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
913 # for more background.
914 # =====================================================================
917 @depends(
918     target,
919     c_compiler,
920     moz_debug,
921     milestone,
922     "--wasm-no-experimental",
924 def wasm_verify_serialization_for_size(
925     target, c_compiler, debug, milestone, no_experimental
927     if (
928         debug == True
929         and target.kernel == "Linux"
930         and target.cpu == "x86_64"
931         and c_compiler
932         and c_compiler.type == "clang"
933         and milestone.is_nightly
934         and not no_experimental
935     ):
936         return True
937     return
940 set_define(
941     "ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
944 # Support for Intel AVX instruction.
946 # AVX is exclusively used in WebAssembly SIMD instructions at the moment:
947 # set direct dependency on "--enable-wasm-simd".
948 # =====================================================
951 @depends("--enable-wasm-simd", "--enable-simulator", target)
952 def default_wasm_avx(wasm_simd_enabled, simulator, target):
953     if not wasm_simd_enabled:
954         return
956     if simulator:
957         return
959     if target.cpu in ("x86_64", "x86"):
960         return True
963 option(
964     "--enable-wasm-avx",
965     default=default_wasm_avx,
966     help="{Enable|Disable} AVX support for WebAssembly SIMD",
970 @depends(
971     "--enable-wasm-avx",
972     "--enable-wasm-simd",
973     "--enable-simulator",
974     target,
975     "--wasm-no-experimental",
977 def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
978     if no_experimental or not value:
979         return
981     if not wasm_simd_enabled:
982         die("--enable-wasm-avx requires --enable-wasm-simd")
984     if simulator:
985         die("--enable-wasm-avx is not supported for simulators")
987     if target.cpu in ("x86_64", "x86"):
988         return True
990     die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
993 set_config("ENABLE_WASM_AVX", wasm_avx)
994 set_define("ENABLE_WASM_AVX", wasm_avx)
996 # Support for WebAssembly relaxed SIMD
997 # =====================================================
1000 @depends(milestone.is_nightly, "--enable-wasm-simd")
1001 def default_wasm_relaxed_simd(is_nightly, wasm_simd):
1002     if is_nightly and wasm_simd:
1003         return True
1006 option(
1007     "--enable-wasm-relaxed-simd",
1008     default=default_wasm_relaxed_simd,
1009     help="{Enable|Disable} WebAssembly relaxed SIMD",
1013 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd", "--wasm-no-experimental")
1014 def wasm_relaxed_simd(value, wasm_simd, no_experimental):
1015     if no_experimental or not value:
1016         return
1018     if not wasm_simd:
1019         die("relaxed SIMD requires SIMD")
1021     return True
1024 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
1025 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
1027 # Support for WebAssembly intgemm private intrinsics
1028 # =====================================================
1031 @depends(target)
1032 def default_wasm_moz_intgemm(target):
1033     return target.cpu in ("x86", "x86_64", "aarch64")
1036 option(
1037     "--enable-wasm-moz-intgemm",
1038     default=default_wasm_moz_intgemm,
1039     help="{Enable|Disable} WebAssembly intgemm private intrinsics",
1043 @depends("--enable-wasm-moz-intgemm", "--wasm-no-experimental")
1044 def wasm_moz_intgemm(value, no_experimental):
1045     if no_experimental:
1046         return
1048     if value:
1049         return True
1052 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
1053 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
1055 # Support for WebAssembly Memory64.
1056 # ===========================
1059 @depends(milestone.is_nightly, "--enable-simulator", target)
1060 def default_wasm_memory64(is_nightly, simulator, target):
1061     if target.cpu == "mips32":
1062         return
1064     if simulator and simulator[0] == "mips32":
1065         return
1067     if is_nightly:
1068         return True
1071 option(
1072     "--enable-wasm-memory64",
1073     default=default_wasm_memory64,
1074     help="{Enable|Disable} WebAssembly Memory64",
1078 @depends(
1079     "--enable-wasm-memory64", "--enable-simulator", target, "--wasm-no-experimental"
1081 def wasm_memory64(value, simulator, target, no_experimental):
1082     if no_experimental or not value:
1083         return
1085     if target.cpu == "mips32":
1086         die("Memory64 is incompatible with MIPS32 target")
1088     if simulator and simulator[0] == "mips32":
1089         die("Memory64 is incompatible with MIPS32 simulator")
1091     return True
1094 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
1095 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
1098 # Support for WebAssembly memory control.
1099 # ===========================
1102 @depends(milestone.is_nightly)
1103 def default_wasm_memory_control(is_nightly):
1104     if is_nightly:
1105         return True
1108 option(
1109     "--enable-wasm-memory-control",
1110     default=default_wasm_memory_control,
1111     help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
1115 @depends("--enable-wasm-memory-control", "--wasm-no-experimental")
1116 def wasm_memory_control(value, no_experimental):
1117     if no_experimental or not value:
1118         return
1120     return True
1123 set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1124 set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1127 # Support for WebAssembly Multi Memory.
1128 # =====================================
1131 @depends(milestone.is_nightly)
1132 def default_wasm_multi_memory(is_nightly):
1133     if is_nightly:
1134         return True
1137 option(
1138     "--enable-wasm-multi-memory",
1139     default=default_wasm_multi_memory,
1140     help="{Enable|Disable} WebAssembly multi-memory",
1144 @depends("--enable-wasm-multi-memory", "--wasm-no-experimental")
1145 def wasm_multi_memory(value, no_experimental):
1146     if no_experimental or not value:
1147         return
1149     return True
1152 set_config("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1153 set_define("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1155 # Options for generating the shell as a script
1156 # ============================================
1157 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
1158 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
1160 option(
1161     "--with-cross-lib",
1162     nargs=1,
1163     default=depends(target.alias)(lambda x: "/usr/%s" % x),
1164     help="Use dir as the location for arm libraries",
1166 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
1168 # Enable static checking using sixgill
1169 # ====================================
1171 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
1174 @depends_if("--with-sixgill")
1175 @imports("os")
1176 def sixgill(value):
1177     for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
1178         if not os.path.exists(os.path.join(value[0], f)):
1179             die("The sixgill plugin and binaries are not at the specified path")
1180     return value[0]
1183 set_config("SIXGILL_PATH", sixgill)
1186 # Support for readline
1187 # =====================================================
1190 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
1191 def editline(js_shell, is_windows, compile_environment, target):
1192     return js_shell and not is_windows and compile_environment and (target.os != "WASI")
1195 option(
1196     "--enable-readline", help="Link js shell to system readline library", when=editline
1199 has_readline = check_symbol(
1200     "readline",
1201     flags=["-lreadline"],
1202     when="--enable-readline",
1203     onerror=lambda: die("No system readline library found"),
1206 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
1209 @depends("--enable-readline", editline, when=editline)
1210 def bundled_editline(readline, editline):
1211     return editline and not readline
1214 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
1216 set_define("EDITLINE", True, when=editline)
1219 # JIT observers
1220 # =============
1222 option(
1223     "--with-jitreport-granularity",
1224     default="3",
1225     choices=("0", "1", "2", "3"),
1226     help="Default granularity at which to report JIT code to external tools "
1227     "(0 - no info, 1 - code ranges for while functions only, "
1228     "2 - per-line information, 3 - per-op information)",
1231 set_define(
1232     "JS_DEFAULT_JITREPORT_GRANULARITY",
1233     depends_if("--with-jitreport-granularity")(lambda value: value[0]),
1237 # ECMAScript Internationalization API Support (uses ICU)
1238 # ======================================================
1239 system_lib_option("--with-system-icu", help="Use system ICU")
1241 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 73.1", when="--with-system-icu")
1244 @depends("--with-system-icu")
1245 def in_tree_icu(system_icu):
1246     return not system_icu
1249 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
1250 # for layout/style/extra-bindgen-flags
1251 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
1253 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1254 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1256 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1259 @depends("--with-intl-api", js_standalone)
1260 def check_intl_api(enabled, js_standalone):
1261     if not enabled and not js_standalone:
1262         die("--without-intl-api is not supported")
1265 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1266 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1269 @depends(build_environment, when="--with-intl-api")
1270 @imports(_from="__builtin__", _import="open")
1271 @imports(_from="__builtin__", _import="ValueError")
1272 def icu_version(build_env):
1273     path = os.path.join(
1274         build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1275     )
1276     with open(path, encoding="utf-8") as fh:
1277         for line in fh:
1278             if line.startswith("#define"):
1279                 define = line.split(None, 3)
1280                 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1281                     try:
1282                         return str(int(define[2]))
1283                     except ValueError:
1284                         pass
1285     die("Cannot determine ICU version number from uvernum.h header file")
1288 set_config("MOZ_ICU_VERSION", icu_version)
1290 # Source files that use ICU should have control over which parts of the ICU
1291 # namespace they want to use.
1292 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1294 # We build ICU as a static library.
1295 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1298 # ECMAScript Temporal API Support (uses ICU)
1299 # ======================================================
1301 option("--with-temporal-api", default=False, help="Enable ECMAScript Temporal API")
1303 set_config("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1304 set_define("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1307 @depends("--with-temporal-api", "--with-intl-api")
1308 def check_temporal_api(temporal_enabled, intl_enabled):
1309     if temporal_enabled and not intl_enabled:
1310         die("Can't use both --with-temporal-api and --without-intl-api")
1313 # Initial support for WebAssembly JS-API Type Reflections
1314 # =======================================================
1317 @depends(milestone.is_nightly)
1318 def default_wasm_type_reflections(is_nightly):
1319     return is_nightly
1322 option(
1323     "--enable-wasm-type-reflections",
1324     default=default_wasm_type_reflections,
1325     help="{Enable|Disable} type reflection in WASM JS-API",
1328 set_config(
1329     "ENABLE_WASM_TYPE_REFLECTIONS",
1330     depends_if("--enable-wasm-type-reflections")(lambda x: True),
1332 set_define(
1333     "ENABLE_WASM_TYPE_REFLECTIONS",
1334     depends_if("--enable-wasm-type-reflections")(lambda x: True),
1337 # Wasi configuration
1338 # ===================================================
1341 @depends(target.os)
1342 def is_wasi_target(os):
1343     return os == "WASI"
1346 set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
1347 set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
1350 @depends(milestone.version)
1351 def js_version(version):
1352     return Version(version)
1355 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
1356 set_define("MOZJS_MAJOR_VERSION", js_version.major)
1357 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
1358 set_define("MOZJS_MINOR_VERSION", js_version.minor)
1359 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
1360 set_config(
1361     "MOZJS_ALPHA",
1362     depends(js_version)(
1363         lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
1364     ),
1368 # Some platforms have HeapReg, some don't
1369 # =====================================================
1371 # The ARM simulator runs on x86 and might be excluded by the first test,
1372 # so we special-case it.
1375 @depends("--enable-simulator", target)
1376 def wasm_has_heapreg(simulator, target):
1377     if target.cpu != "x86":
1378         return True
1380     if simulator and simulator[0] == "arm":
1381         return True
1384 set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
1386 # Check for tm_zone, tm_gmtoff in struct tm
1387 # ===================================================
1388 with only_when(compile_environment):
1389     set_define(
1390         "HAVE_TM_ZONE_TM_GMTOFF",
1391         c_compiler.try_compile(
1392             includes=["time.h"],
1393             body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
1394             check_msg="for tm_zone and tm_gmtoff in struct tm",
1395         ),
1396     )
1399 # Checks for library functions
1400 # ==============================================================
1401 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1402     set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
1403     set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
1404     set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
1405     set_define("HAVE_GETTID", check_symbol("gettid"))
1406     set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
1407     set_define("HAVE_SYSCALL", check_symbol("syscall"))
1408     set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
1409     set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
1410     set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
1411     set_define("HAVE_STRERROR", check_symbol("strerror"))
1413     @depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
1414     def demangle_symbols(cxa_demangle, moz_debug, dmd):
1415         # Demangle only for debug or DMD builds
1416         if cxa_demangle and (moz_debug or dmd):
1417             return True
1419     set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
1421     set_define("HAVE__UNWIND_BACKTRACE", True, when=have_unwind)
1423 with only_when(compile_environment):
1424     set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
1425     set_define("HAVE_LOCALECONV", check_symbol("localeconv"))