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":
15 # ==============================================================
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):
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.
43 help="Enable SmooshMonkey (new JS engine frontend)",
47 @depends("--enable-smoosh")
48 def enable_smoosh(value):
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)
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):
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 # ==================================================================
85 "--disable-shared-js",
87 help="{Create|Do not create} a shared library",
91 "--disable-export-js",
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):
101 die("Must export JS symbols when building a shared library.")
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:
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:
124 set_define("STATIC_JS_API", static_js_api)
128 def static_js(value):
133 set_define("MOZ_STATIC_JS", static_js)
136 # Enable records and tuples
137 # ===================================================
139 "--enable-record-tuple",
141 help="Enable records and tuples (and disables JIT)",
145 @depends("--enable-record-tuple")
146 def enable_record_tuple(value):
151 set_config("ENABLE_RECORD_TUPLE", enable_record_tuple)
152 set_define("ENABLE_RECORD_TUPLE", enable_record_tuple)
155 # =======================================================
156 @depends(target, "--enable-record-tuple")
157 def jit_default(target, enable_record_tuple):
158 if enable_record_tuple:
160 if target.cpu in ("x86", "x86_64", "arm", "aarch64", "mips32", "mips64"):
165 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
168 @deprecated_option("--enable-ion")
169 def report_deprecated(value):
171 die("--enable-ion is deprecated, use --enable-jit instead")
173 die("--disable-ion is deprecated, use --disable-jit instead")
176 # JIT code simulator for cross compiles
177 # =======================================================
179 "--enable-simulator",
180 choices=("arm", "arm64", "mips32", "mips64"),
182 help="Enable a JIT code simulator for the specified architecture",
186 @depends("--enable-jit", "--enable-simulator", target)
187 def simulator(jit_enabled, simulator_enabled, target):
188 if not jit_enabled or not simulator_enabled:
191 sim_cpu = simulator_enabled[0]
193 if sim_cpu in ("arm", "mips32"):
194 if target.cpu != "x86":
195 die("The %s simulator only works on x86." % sim_cpu)
197 if sim_cpu in ("arm64", "mips64"):
198 if target.cpu != "x86_64":
199 die("The %s simulator only works on x86-64." % sim_cpu)
201 return namespace(**{sim_cpu: True})
204 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
205 set_config("JS_SIMULATOR_ARM", simulator.arm)
206 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
207 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
208 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
209 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
210 set_define("JS_SIMULATOR_ARM", simulator.arm)
211 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
212 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
213 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
216 @depends("--enable-jit", simulator, target)
217 def jit_codegen(jit_enabled, simulator, target):
219 return namespace(none=True)
224 if target.cpu == "aarch64":
225 return namespace(arm64=True)
226 elif target.cpu == "x86_64":
227 return namespace(x64=True)
229 return namespace(**{str(target.cpu): True})
232 set_config("JS_CODEGEN_NONE", jit_codegen.none)
233 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
234 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
235 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
236 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
237 set_config("JS_CODEGEN_X86", jit_codegen.x86)
238 set_config("JS_CODEGEN_X64", jit_codegen.x64)
239 set_define("JS_CODEGEN_NONE", jit_codegen.none)
240 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
241 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
242 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
243 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
244 set_define("JS_CODEGEN_X86", jit_codegen.x86)
245 set_define("JS_CODEGEN_X64", jit_codegen.x64)
248 # =======================================================
250 "--enable-instruments",
251 env="MOZ_INSTRUMENTS",
252 help="Enable instruments remote profiling",
256 @depends("--enable-instruments", target)
257 def instruments(value, target):
258 if value and target.os != "OSX":
259 die("--enable-instruments cannot be used when targeting %s", target.os)
264 set_config("MOZ_INSTRUMENTS", instruments)
265 set_define("MOZ_INSTRUMENTS", instruments)
266 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
267 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
269 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
272 @depends("--enable-callgrind")
273 def callgrind(value):
278 set_define("MOZ_CALLGRIND", callgrind)
279 imply_option("--enable-profiling", callgrind)
283 def enable_profiling(milestone):
284 return milestone.is_nightly
288 "--enable-profiling",
290 default=enable_profiling,
291 help="{Set|Do not set} compile flags necessary for using sampling "
292 "profilers (e.g. shark, perf)",
296 @depends("--enable-profiling")
297 def profiling(value):
302 add_old_configure_assignment("MOZ_PROFILING", profiling)
304 with only_when("--enable-compile-environment"):
305 imply_option("--enable-frame-pointers", True, when=profiling)
308 @depends(profiling, target)
309 def imply_vtune(value, target):
310 ok_cpu = target.cpu in ["x86", "x86_64"]
311 ok_kernel = target.kernel == "WINNT" or (
312 target.kernel == "Linux" and target.os == "GNU"
315 if value and ok_cpu and ok_kernel:
319 set_config("MOZ_PROFILING", profiling)
320 set_define("MOZ_PROFILING", profiling)
321 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
324 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
327 @depends("--enable-vtune")
333 set_config("MOZ_VTUNE", vtune)
334 set_define("MOZ_VTUNE", vtune)
338 "--enable-gc-probes",
340 help="Turn on probes for allocation and finalization",
344 @depends("--enable-gc-probes")
345 def gc_probes(value):
350 set_define("JS_GC_PROBES", gc_probes)
355 default=depends(when=moz_debug)(lambda: True),
356 help="{Enable|Disable} zealous GCing",
359 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
362 # Use a smaller chunk size for GC chunks
363 # ========================================================
364 # Use large (1MB) chunks by default. This option can be used to give
365 # smaller (currently 256K) chunks.
367 "--enable-small-chunk-size",
368 help="Allocate memory for JS GC things in smaller chunks",
372 "JS_GC_SMALL_CHUNK_SIZE", depends(when="--enable-small-chunk-size")(lambda: True)
377 # =======================================================
379 def default_trace_logging(milestone):
380 return milestone.is_nightly
384 "--enable-trace-logging",
385 default=default_trace_logging,
386 help="{Enable|Disable} trace logging",
389 set_config("ENABLE_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
390 set_define("JS_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
393 # Enable breakpoint for artificial OOMs
394 # =======================================================
396 "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
399 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
402 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
405 @depends("--enable-perf")
411 set_define("JS_ION_PERF", ion_perf)
416 default=depends(when=moz_debug)(lambda: True),
417 help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
420 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
421 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
423 # Also enable the structured spewer
424 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
425 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
428 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
429 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
433 if simulator and (debug or spew):
434 if getattr(simulator, "arm", None):
437 if target.cpu == "arm" and (debug or spew):
441 set_config("JS_DISASM_ARM", jit_disasm_arm)
442 set_define("JS_DISASM_ARM", jit_disasm_arm)
445 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
446 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
450 if simulator and (debug or spew):
451 if getattr(simulator, "arm64", None):
454 if target.cpu == "aarch64" and (debug or spew):
458 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
459 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
461 # When enabled, masm will generate assumeUnreachable calls that act as
462 # assertions in the generated code. This option is worth disabling when you
463 # have to track mutated values through the generated code, to avoid constantly
464 # dumping registers on and off the stack.
466 "--enable-masm-verbose",
467 default=depends(when=moz_debug)(lambda: True),
468 help="{Enable|Disable} MacroAssembler verbosity of generated code.",
470 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
471 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
473 # Architecture feature flags
474 # =======================================================
476 # Apple silicon does not seem to have any way to query the OS for the JSCVT
477 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
478 # hard code the value of the JSCVT flag which guards the implementation of
479 # FJCVTZS instruction as part of ARMv8.3-JSConv.
481 def is_apple_silicon(target):
482 return target.os == "OSX" and target.kernel == "Darwin" and target.cpu == "aarch64"
486 "--enable-arm64-fjcvtzs",
487 default=is_apple_silicon,
488 help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
491 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
492 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
495 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
496 @depends("--enable-arm64-fjcvtzs", target, simulator)
497 def aarch64_jscvt(fjcvtzs, target, simulator):
498 if target.cpu == "aarch64" and fjcvtzs:
501 if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
507 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
510 # =======================================================
511 @depends(js_standalone)
512 def ctypes_default(js_standalone):
513 return not js_standalone
516 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
518 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
520 set_config("BUILD_CTYPES", build_ctypes)
521 set_define("BUILD_CTYPES", build_ctypes)
523 set_config("JS_HAS_CTYPES", build_ctypes)
524 set_define("JS_HAS_CTYPES", build_ctypes)
527 @depends("--enable-ctypes", "--enable-compile-environment")
528 def ctypes_and_compile_environment(ctypes, compile_environment):
529 return ctypes and compile_environment
532 include("ffi.configure", when=ctypes_and_compile_environment)
535 # Enable pipeline operator
536 # ===================================================
537 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
540 @depends("--enable-pipeline-operator")
541 def enable_pipeline_operator(value):
546 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
547 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
550 # SIMD acceleration for encoding_rs
551 # ==============================================================
554 "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
558 @depends("--enable-rust-simd", target)
559 def rust_simd(value, target):
560 # As of 2019-09-17, the simd-accel feature of encoding_rs has not
561 # been properly set up outside aarch64, armv7, x86 and x86_64.
562 if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
566 set_config("MOZ_RUST_SIMD", rust_simd)
567 set_define("MOZ_RUST_SIMD", rust_simd)
570 # Support for wasm code generation with Cranelift
571 # ==============================================================
574 "--enable-cranelift",
576 help="{Enable|Disable} Cranelift code generator for wasm",
581 "--enable-cranelift",
583 "--enable-simulator",
587 def enable_cranelift(value, jit_enabled, simulator, target, is_windows):
592 die("--enable-cranelift requires --enable-jit")
595 target.cpu == "aarch64"
596 or (target.cpu == "x86_64" and simulator and simulator[0] == "arm64")
598 die("--enable-cranelift is only supported on arm64")
601 die("--enable-cranelift is not supported on windows")
606 set_config("ENABLE_WASM_CRANELIFT", enable_cranelift)
607 set_define("ENABLE_WASM_CRANELIFT", enable_cranelift)
610 # Telemetry to measure compile time and generated-code runtime
611 # ============================================================
614 "--enable-spidermonkey-telemetry",
615 default=milestone.is_nightly,
616 help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
620 "ENABLE_SPIDERMONKEY_TELEMETRY",
621 depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
624 # Support for debugging code generated by wasm backends
625 # =====================================================
628 "--enable-wasm-codegen-debug",
629 default=depends(when=moz_debug)(lambda: True),
630 help="{Enable|Disable} debugging for wasm codegen",
634 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
637 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
640 # Support for WebAssembly function-references.
641 # ===========================
644 @depends(milestone.is_nightly)
645 def default_wasm_function_references(is_nightly):
651 "--enable-wasm-function-references",
652 default=default_wasm_function_references,
653 help="{Enable|Disable} WebAssembly function-references",
657 @depends("--enable-wasm-function-references")
658 def wasm_function_references(value):
663 set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
664 set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
666 # Support for WebAssembly GC.
667 # ===========================
670 @depends(milestone.is_nightly, "--enable-wasm-function-references")
671 def default_wasm_gc(is_nightly, function_references):
672 if is_nightly and function_references:
677 "--enable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
681 @depends("--enable-wasm-gc", "--enable-wasm-function-references")
682 def wasm_gc(value, function_references):
686 if function_references:
689 die("--enable-wasm-gc only possible with --enable-wasm-function-references")
692 set_config("ENABLE_WASM_GC", wasm_gc)
693 set_define("ENABLE_WASM_GC", wasm_gc)
696 # Support for WebAssembly private ref types.
697 # Prevent (ref T) types from being exposed to JS content so that wasm need do
698 # no typechecking at the JS/wasm boundary
699 # ===========================================================================
702 @depends(milestone.is_nightly, "--enable-wasm-gc")
703 def default_wasm_private_reftypes(is_nightly, gc):
704 if gc and is_nightly:
709 "--enable-wasm-private-reftypes",
710 default=default_wasm_private_reftypes,
711 help="{Enable|Disable} WebAssembly private reference types",
715 "WASM_PRIVATE_REFTYPES",
716 depends_if("--enable-wasm-private-reftypes")(lambda x: True),
719 "WASM_PRIVATE_REFTYPES",
720 depends_if("--enable-wasm-private-reftypes")(lambda x: True),
723 # Support for WebAssembly shared memory and atomics.
725 # This affects the JS shell only and here to allow the use of
726 # Cranelift in the shell. Once Cranelift supports shared memory
727 # and atomics it can go away.
728 # =====================================================
731 "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
735 @depends("--disable-shared-memory")
736 def enable_shared_memory(value):
741 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
742 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
744 # Support for WebAssembly extended constant expressions
745 # =====================================================
748 @depends(milestone.is_nightly)
749 def default_wasm_extended_const(is_nightly):
755 "--enable-wasm-extended-const",
756 default=default_wasm_extended_const,
757 help="{Enable|Disable} WebAssembly extended constant expressions",
761 @depends("--enable-wasm-extended-const")
762 def wasm_extended_const(value):
767 set_config("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
768 set_define("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
770 # Support for WebAssembly SIMD
771 # =====================================================
774 @depends("--enable-jit", "--enable-simulator", "--enable-cranelift", target)
775 def default_wasm_simd(jit_enabled, simulator, cranelift_enabled, target):
779 if cranelift_enabled:
782 if simulator and (simulator[0] != "arm64"):
785 if target.cpu in ("x86_64", "x86", "aarch64"):
790 "--enable-wasm-simd",
791 default=default_wasm_simd,
792 help="{Enable|Disable} WebAssembly SIMD",
797 "--enable-wasm-simd",
799 "--enable-simulator",
800 "--enable-cranelift",
803 def wasm_simd(value, jit_enabled, simulator, cranelift_enabled, target):
808 die("--enable-wasm-simd requires --enable-jit")
810 if cranelift_enabled:
811 die("--enable-wasm-simd is not supported for --enable-cranelift")
813 if simulator and (simulator[0] != "arm64"):
814 die("--enable-wasm-simd is not supported for simulators, except arm64")
816 if target.cpu in ("x86_64", "x86", "aarch64"):
819 die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
822 set_config("ENABLE_WASM_SIMD", wasm_simd)
823 set_define("ENABLE_WASM_SIMD", wasm_simd)
825 # Wormhole opcodes are Intel-only. They are private to Firefox, but we need them for some
826 # experiments on release and so they ride the trains.
829 @depends("--enable-simulator", "--enable-wasm-simd", target)
830 def default_wasm_simd_wormhole(simulator, wasm_simd, target):
831 if wasm_simd and target.cpu in ("x86", "x86_64") and not simulator:
836 "--enable-wasm-simd-wormhole",
837 default=default_wasm_simd_wormhole,
838 help="{Enable|Disable} WebAssembly SIMD wormhole opcodes",
843 "--enable-wasm-simd-wormhole", "--enable-wasm-simd", "--enable-simulator", target
845 def wasm_simd_wormhole(value, wasm_simd, simulator, target):
849 if wasm_simd and target.cpu in ("x86", "x86_64") and not simulator:
852 die("SIMD wormhole currently supported on native x86/x64 only, with --wasm-simd")
855 set_config("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
856 set_define("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
859 # Support for WebAssembly relaxed SIMD
860 # =====================================================
863 @depends(milestone.is_nightly, "--enable-wasm-simd")
864 def default_wasm_relaxed_simd(is_nightly, wasm_simd):
865 if is_nightly and wasm_simd:
870 "--enable-wasm-relaxed-simd",
871 default=default_wasm_relaxed_simd,
872 help="{Enable|Disable} WebAssembly relaxed SIMD",
876 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd")
877 def wasm_relaxed_simd(value, wasm_simd):
882 die("relaxed SIMD requires SIMD")
887 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
888 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
890 # Support for WebAssembly intgemm private intrinsics
891 # =====================================================
894 @depends(milestone.is_nightly)
895 def default_wasm_moz_intgemm(is_nightly):
901 "--enable-wasm-moz-intgemm",
902 default=default_wasm_moz_intgemm,
903 help="{Enable|Disable} WebAssembly intgemm private intrinsics",
907 @depends("--enable-wasm-moz-intgemm")
908 def wasm_moz_intgemm(value):
915 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
916 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
918 # Support for WebAssembly Memory64.
919 # ===========================
922 @depends(milestone.is_nightly, "--enable-cranelift", "--enable-simulator", target)
923 def default_wasm_memory64(is_nightly, cranelift, simulator, target):
927 if target.cpu == "mips32":
930 if simulator and simulator[0] == "mips32":
938 "--enable-wasm-memory64",
939 default=default_wasm_memory64,
940 help="{Enable|Disable} WebAssembly Memory64",
944 @depends("--enable-wasm-memory64", "--enable-cranelift", "--enable-simulator", target)
945 def wasm_memory64(value, cranelift, simulator, target):
950 die("Memory64 is incompatible with Cranelift")
952 if target.cpu == "mips32":
953 die("Memory64 is incompatible with MIPS32 target")
955 if simulator and simulator[0] == "mips32":
956 die("Memory64 is incompatible with MIPS32 simulator")
961 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
962 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
964 # Support for checking for indirect call to null via traps
965 # =====================================================
968 @depends(milestone.is_nightly, "--enable-jit", "--enable-simulator")
969 def default_wasm_call_indirect_null(is_nightly, enable_jit, simulator):
981 "--enable-wasm-call-indirect-null",
982 default=default_wasm_call_indirect_null,
983 help="{Enable|Disable} WebAssembly call-indirect-to-null optimization",
987 @depends("--enable-wasm-call-indirect-null", "--enable-jit", "--enable-simulator")
988 def wasm_call_indirect_null(value, enable_jit, simulator):
1001 set_config("ENABLE_WASM_CALL_INDIRECT_NULL", wasm_call_indirect_null)
1002 set_define("ENABLE_WASM_CALL_INDIRECT_NULL", wasm_call_indirect_null)
1004 # Options for generating the shell as a script
1005 # ============================================
1006 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
1007 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
1012 default=depends(target.alias)(lambda x: "/usr/%s" % x),
1013 help="Use dir as the location for arm libraries",
1015 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
1017 # Enable static checking using sixgill
1018 # ====================================
1020 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
1023 @depends_if("--with-sixgill")
1026 for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
1027 if not os.path.exists(os.path.join(value[0], f)):
1028 die("The sixgill plugin and binaries are not at the specified path")
1032 set_config("SIXGILL_PATH", sixgill)
1035 # Support for readline
1036 # =====================================================
1039 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
1040 def editline(js_shell, is_windows, compile_environment, target):
1041 return js_shell and not is_windows and compile_environment and (target.os != "WASI")
1045 "--enable-readline", help="Link js shell to system readline library", when=editline
1048 has_readline = check_symbol(
1050 flags=["-lreadline"],
1051 when="--enable-readline",
1052 onerror=lambda: die("No system readline library found"),
1055 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
1058 @depends("--enable-readline", editline, when=editline)
1059 def bundled_editline(readline, editline):
1060 return editline and not readline
1063 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
1065 set_define("EDITLINE", True, when=editline)
1072 "--with-jitreport-granularity",
1074 choices=("0", "1", "2", "3"),
1075 help="Default granularity at which to report JIT code to external tools "
1076 "(0 - no info, 1 - code ranges for while functions only, "
1077 "2 - per-line information, 3 - per-op information)",
1081 "JS_DEFAULT_JITREPORT_GRANULARITY",
1082 depends_if("--with-jitreport-granularity")(lambda value: value[0]),
1086 # ECMAScript Internationalization API Support (uses ICU)
1087 # ======================================================
1088 system_lib_option("--with-system-icu", help="Use system ICU")
1090 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 70.1", when="--with-system-icu")
1093 @depends("--with-system-icu")
1094 def in_tree_icu(system_icu):
1095 return not system_icu
1098 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
1099 # for layout/style/extra-bindgen-flags
1100 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
1102 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1103 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1105 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1108 @depends("--with-intl-api", js_standalone)
1109 def check_intl_api(enabled, js_standalone):
1110 if not enabled and not js_standalone:
1111 die("--without-intl-api is not supported")
1114 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1115 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1118 @depends(build_environment, when="--with-intl-api")
1119 @imports(_from="__builtin__", _import="open")
1120 @imports(_from="__builtin__", _import="ValueError")
1121 def icu_version(build_env):
1122 path = os.path.join(
1123 build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1125 with open(path, encoding="utf-8") as fh:
1127 if line.startswith("#define"):
1128 define = line.split(None, 3)
1129 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1131 return str(int(define[2]))
1134 die("Cannot determine ICU version number from uvernum.h header file")
1137 set_config("MOZ_ICU_VERSION", icu_version)
1139 # Source files that use ICU should have control over which parts of the ICU
1140 # namespace they want to use.
1141 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1143 # We build ICU as a static library.
1144 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1147 # Initial support for WebAssembly JS-API Type Reflections
1148 # =======================================================
1151 @depends(milestone.is_nightly)
1152 def default_wasm_type_reflections(is_nightly):
1157 "--enable-wasm-type-reflections",
1158 default=default_wasm_type_reflections,
1159 help="{Enable|Disable} type reflection in WASM JS-API",
1163 "ENABLE_WASM_TYPE_REFLECTIONS",
1164 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1167 "ENABLE_WASM_TYPE_REFLECTIONS",
1168 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1171 # Support for WebAssembly exceptions
1172 # ==================================
1175 @depends(milestone.is_nightly)
1176 def default_wasm_exceptions(is_nightly):
1182 "--enable-wasm-exceptions",
1183 default=default_wasm_exceptions,
1184 help="{Enable|Disable} WebAssembly exceptions",
1188 "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)
1191 "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)
1195 "_WASI_EMULATED_PROCESS_CLOCKS",
1197 when=depends(target)(lambda t: t.os == "WASI"),
1200 # Enable change-array-by-copy
1201 # ===================================================
1202 def use_change_array_by_copy():
1207 "--enable-change-array-by-copy",
1208 default=use_change_array_by_copy(),
1209 help="{Enable|Disable} change-array-by-copy method pref/command-line option (disabled by default)",
1213 @depends("--enable-change-array-by-copy")
1214 def enable_change_array_by_copy(value):
1219 set_config("ENABLE_CHANGE_ARRAY_BY_COPY", enable_change_array_by_copy)
1220 set_define("ENABLE_CHANGE_ARRAY_BY_COPY", enable_change_array_by_copy)
1222 # Enable New Set methods
1223 # ===================================================
1224 def use_new_set_methods():
1229 "--enable-new-set-methods",
1230 default=use_new_set_methods(),
1231 help="{Enable|Disable} New Set methods pref/command-line option (disabled by default)",
1235 @depends("--enable-new-set-methods")
1236 def enable_new_set_methods(value):
1241 set_config("ENABLE_NEW_SET_METHODS", enable_new_set_methods)
1242 set_define("ENABLE_NEW_SET_METHODS", enable_new_set_methods)
1245 @depends(milestone.version)
1246 def js_version(version):
1247 return Version(version)
1250 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
1251 set_define("MOZJS_MAJOR_VERSION", js_version.major)
1252 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
1253 set_define("MOZJS_MINOR_VERSION", js_version.minor)
1254 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
1257 depends(js_version)(
1258 lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
1263 # Check for tm_zone, tm_gmtoff in struct tm
1264 # ===================================================
1265 with only_when(compile_environment):
1267 "HAVE_TM_ZONE_TM_GMTOFF",
1268 c_compiler.try_compile(
1269 includes=["time.h"],
1270 body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
1271 check_msg="for tm_zone and tm_gmtoff in struct tm",