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":
14 # Debug (see Bug 939505)
15 # ==============================================================
16 set_define("JS_DEBUG", True, when=moz_debug)
20 # ==============================================================
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):
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.
48 help="Enable SmooshMonkey (new JS engine frontend)",
52 @depends("--enable-smoosh")
53 def enable_smoosh(value):
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)
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):
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 # ==================================================================
90 "--disable-shared-js",
92 help="{Create|Do not create} a shared library",
96 "--disable-export-js",
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):
106 die("Must export JS symbols when building a shared library.")
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:
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:
128 set_define("STATIC_JS_API", static_js_api)
132 def static_js(value):
137 set_define("MOZ_STATIC_JS", static_js)
140 # Enable records and tuples
141 # ===================================================
143 "--enable-record-tuple",
145 help="Enable records and tuples (and disables JIT)",
149 @depends("--enable-record-tuple")
150 def enable_record_tuple(value):
155 set_config("ENABLE_RECORD_TUPLE", enable_record_tuple)
156 set_define("ENABLE_RECORD_TUPLE", enable_record_tuple)
159 # ===================================================
161 "--enable-decorators",
163 help="Enable experimental JS Decorators support",
167 @depends("--enable-decorators")
168 def enable_decorators(value):
173 set_config("ENABLE_DECORATORS", enable_decorators)
174 set_define("ENABLE_DECORATORS", enable_decorators)
176 # Enable JSON.parse with source
177 # ===================================================
179 "--enable-json-parse-with-source",
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):
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 # =======================================================
198 "--enable-portable-baseline-interp",
200 help="{Enable|Disable} the portable baseline interpreter.",
203 "ENABLE_PORTABLE_BASELINE_INTERP",
204 depends_if("--enable-portable-baseline-interp")(lambda _: True),
207 "ENABLE_PORTABLE_BASELINE_INTERP",
208 depends_if("--enable-portable-baseline-interp")(lambda _: True),
211 # Option to always force PBL tier.
213 "--enable-portable-baseline-interp-force",
215 help="{Enable|Disable} forcing use of the portable baseline interpreter.",
219 "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
220 depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
223 "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
224 depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
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:
234 if enable_portable_baseline_interp:
249 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
252 @deprecated_option("--enable-ion")
253 def report_deprecated(value):
255 die("--enable-ion is deprecated, use --enable-jit instead")
257 die("--disable-ion is deprecated, use --disable-jit instead")
260 # JIT code simulator for cross compiles
261 # =======================================================
263 "--enable-simulator",
264 choices=("arm", "arm64", "mips32", "mips64", "loong64", "riscv64"),
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:
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):
307 return namespace(none=True)
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)
348 # =======================================================
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)
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):
378 set_define("MOZ_CALLGRIND", callgrind)
379 imply_option("--enable-profiling", callgrind)
383 def enable_profiling(milestone):
384 return milestone.is_nightly
388 "--enable-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):
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"
413 if value and ok_cpu and ok_kernel:
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")
431 set_config("MOZ_VTUNE", vtune)
432 set_define("MOZ_VTUNE", vtune)
436 "--enable-gc-probes",
438 help="Turn on probes for allocation and finalization",
442 @depends("--enable-gc-probes")
443 def gc_probes(value):
448 set_define("JS_GC_PROBES", gc_probes)
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 # =======================================================
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):
481 set_define("JS_ION_PERF", ion_perf)
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):
503 if simulator and (debug or spew):
504 if getattr(simulator, "arm", None):
507 if target.cpu == "arm" and (debug or spew):
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):
520 if simulator and (debug or spew):
521 if getattr(simulator, "riscv64", None):
524 if target.cpu == "riscv64" and (debug or spew):
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):
537 if simulator and (debug or spew):
538 if getattr(simulator, "arm64", None):
541 if target.cpu == "aarch64" and (debug or spew):
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.
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.
569 def is_apple_silicon(target):
570 return target.kernel == "Darwin" and target.cpu == "aarch64"
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
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:
590 if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
596 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
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)
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):
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 # ==============================================================
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:
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 # ============================================================
673 "--enable-spidermonkey-telemetry",
674 default=milestone.is_nightly,
675 help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
679 "ENABLE_SPIDERMONKEY_TELEMETRY",
680 depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
683 # Support for debugging code generated by wasm backends
684 # =====================================================
687 "--enable-wasm-codegen-debug",
688 default=depends(when=moz_debug)(lambda: True),
689 help="{Enable|Disable} debugging for wasm codegen",
693 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
696 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
699 # WebAssembly feature flags
700 # ==================================================
703 "--wasm-no-experimental",
705 help="Force disable all wasm experimental features for testing.",
708 # Support for WebAssembly tail-calls.
709 # ===========================
713 def default_wasm_tail_calls(target):
714 if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
719 "--enable-wasm-tail-calls",
720 default=default_wasm_tail_calls,
721 help="{Enable|Disable} WebAssembly tail-calls",
725 @depends("--enable-wasm-tail-calls", target)
726 def wasm_tail_calls(value, target):
730 if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
734 "--enable-wasm-tail-calls only possible when targeting the x86_64/x86/arm64/arm/loongarch64/mips64 jits"
738 set_config("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
739 set_define("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
741 # Support for WebAssembly GC.
742 # ===========================
745 option("--disable-wasm-gc", default=True, help="{Enable|Disable} WebAssembly GC")
748 @depends("--disable-wasm-gc")
755 set_config("ENABLE_WASM_GC", wasm_gc)
756 set_define("ENABLE_WASM_GC", wasm_gc)
758 # Support for WebAssembly JS String Builtins
759 # ==========================================
762 @depends(milestone.is_nightly)
763 def default_wasm_js_string_builtins(is_nightly):
769 "--enable-wasm-js-string-builtins",
770 default=default_wasm_js_string_builtins,
771 help="{Enable|Disable} WebAssembly JS String Builtins",
775 @depends("--enable-wasm-js-string-builtins", "--wasm-no-experimental")
776 def wasm_js_string_builtins(value, no_experimental):
777 if no_experimental or not value:
783 set_config("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
784 set_define("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
786 # Support for WebAssembly shared memory and atomics.
788 # This affects the JS shell only.
789 # =====================================================
792 "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
796 @depends("--disable-shared-memory")
797 def enable_shared_memory(value):
802 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
803 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
805 # Support for WebAssembly SIMD
806 # =====================================================
809 @depends("--enable-jit", "--enable-simulator", target)
810 def default_wasm_simd(jit_enabled, simulator, target):
814 if simulator and (simulator[0] != "arm64"):
817 if target.cpu in ("x86_64", "x86", "aarch64"):
822 "--enable-wasm-simd",
823 default=default_wasm_simd,
824 help="{Enable|Disable} WebAssembly SIMD",
829 "--enable-wasm-simd",
831 "--enable-simulator",
833 "--wasm-no-experimental",
835 def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
836 if no_experimental or not value:
840 die("--enable-wasm-simd requires --enable-jit")
842 if simulator and (simulator[0] != "arm64"):
843 die("--enable-wasm-simd is not supported for simulators, except arm64")
845 if target.cpu in ("x86_64", "x86", "aarch64"):
848 die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
851 set_config("ENABLE_WASM_SIMD", wasm_simd)
852 set_define("ENABLE_WASM_SIMD", wasm_simd)
854 # Whether to check for field changes in WebAssembly serialization
856 # See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
857 # for more background.
858 # =====================================================================
866 "--wasm-no-experimental",
868 def wasm_verify_serialization_for_size(
869 target, c_compiler, debug, milestone, no_experimental
873 and target.kernel == "Linux"
874 and target.cpu == "x86_64"
876 and c_compiler.type == "clang"
877 and milestone.is_nightly
878 and not no_experimental
885 "ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
888 # Support for Intel AVX instruction.
890 # AVX is exclusively used in WebAssembly SIMD instructions at the moment:
891 # set direct dependency on "--enable-wasm-simd".
892 # =====================================================
895 @depends("--enable-wasm-simd", "--enable-simulator", target)
896 def default_wasm_avx(wasm_simd_enabled, simulator, target):
897 if not wasm_simd_enabled:
903 if target.cpu in ("x86_64", "x86"):
909 default=default_wasm_avx,
910 help="{Enable|Disable} AVX support for WebAssembly SIMD",
916 "--enable-wasm-simd",
917 "--enable-simulator",
919 "--wasm-no-experimental",
921 def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
922 if no_experimental or not value:
925 if not wasm_simd_enabled:
926 die("--enable-wasm-avx requires --enable-wasm-simd")
929 die("--enable-wasm-avx is not supported for simulators")
931 if target.cpu in ("x86_64", "x86"):
934 die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
937 set_config("ENABLE_WASM_AVX", wasm_avx)
938 set_define("ENABLE_WASM_AVX", wasm_avx)
940 # Support for WebAssembly relaxed SIMD
941 # =====================================================
944 @depends(milestone.is_nightly, "--enable-wasm-simd")
945 def default_wasm_relaxed_simd(is_nightly, wasm_simd):
946 if is_nightly and wasm_simd:
951 "--enable-wasm-relaxed-simd",
952 default=default_wasm_relaxed_simd,
953 help="{Enable|Disable} WebAssembly relaxed SIMD",
957 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd", "--wasm-no-experimental")
958 def wasm_relaxed_simd(value, wasm_simd, no_experimental):
959 if no_experimental or not value:
963 die("relaxed SIMD requires SIMD")
968 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
969 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
971 # Support for WebAssembly intgemm private intrinsics
972 # =====================================================
976 def default_wasm_moz_intgemm(target):
977 return target.cpu in ("x86", "x86_64", "aarch64")
981 "--enable-wasm-moz-intgemm",
982 default=default_wasm_moz_intgemm,
983 help="{Enable|Disable} WebAssembly intgemm private intrinsics",
987 @depends("--enable-wasm-moz-intgemm", "--wasm-no-experimental")
988 def wasm_moz_intgemm(value, no_experimental):
996 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
997 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
999 # Support for WebAssembly Memory64.
1000 # ===========================
1003 @depends(milestone.is_nightly, "--enable-simulator", target)
1004 def default_wasm_memory64(is_nightly, simulator, target):
1005 if target.cpu == "mips32":
1008 if simulator and simulator[0] == "mips32":
1016 "--enable-wasm-memory64",
1017 default=default_wasm_memory64,
1018 help="{Enable|Disable} WebAssembly Memory64",
1023 "--enable-wasm-memory64", "--enable-simulator", target, "--wasm-no-experimental"
1025 def wasm_memory64(value, simulator, target, no_experimental):
1026 if no_experimental or not value:
1029 if target.cpu == "mips32":
1030 die("Memory64 is incompatible with MIPS32 target")
1032 if simulator and simulator[0] == "mips32":
1033 die("Memory64 is incompatible with MIPS32 simulator")
1038 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
1039 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
1042 # Support for WebAssembly memory control.
1043 # ===========================
1046 @depends(milestone.is_nightly)
1047 def default_wasm_memory_control(is_nightly):
1053 "--enable-wasm-memory-control",
1054 default=default_wasm_memory_control,
1055 help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
1059 @depends("--enable-wasm-memory-control", "--wasm-no-experimental")
1060 def wasm_memory_control(value, no_experimental):
1061 if no_experimental or not value:
1067 set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1068 set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1071 # Support for WebAssembly Multi Memory.
1072 # =====================================
1076 "--disable-wasm-multi-memory",
1077 help="{Enable|Disable} WebAssembly multi-memory",
1081 @depends("--disable-wasm-multi-memory")
1082 def wasm_multi_memory(value):
1087 set_config("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1088 set_define("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1090 # Options for generating the shell as a script
1091 # ============================================
1092 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
1093 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
1098 default=depends(target.alias)(lambda x: "/usr/%s" % x),
1099 help="Use dir as the location for arm libraries",
1101 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
1103 # Enable static checking using sixgill
1104 # ====================================
1106 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
1109 @depends_if("--with-sixgill")
1112 for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
1113 if not os.path.exists(os.path.join(value[0], f)):
1114 die("The sixgill plugin and binaries are not at the specified path")
1118 set_config("SIXGILL_PATH", sixgill)
1121 # Support for readline
1122 # =====================================================
1125 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
1126 def editline(js_shell, is_windows, compile_environment, target):
1127 return js_shell and not is_windows and compile_environment and (target.os != "WASI")
1131 "--enable-readline", help="Link js shell to system readline library", when=editline
1134 has_readline = check_symbol(
1136 flags=["-lreadline"],
1137 when="--enable-readline",
1138 onerror=lambda: die("No system readline library found"),
1141 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
1144 @depends("--enable-readline", editline, when=editline)
1145 def bundled_editline(readline, editline):
1146 return editline and not readline
1149 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
1151 set_define("EDITLINE", True, when=editline)
1158 "--with-jitreport-granularity",
1160 choices=("0", "1", "2", "3"),
1161 help="Default granularity at which to report JIT code to external tools "
1162 "(0 - no info, 1 - code ranges for while functions only, "
1163 "2 - per-line information, 3 - per-op information)",
1167 "JS_DEFAULT_JITREPORT_GRANULARITY",
1168 depends_if("--with-jitreport-granularity")(lambda value: value[0]),
1172 # ECMAScript Internationalization API Support (uses ICU)
1173 # ======================================================
1174 system_lib_option("--with-system-icu", help="Use system ICU")
1176 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 73.1", when="--with-system-icu")
1179 @depends("--with-system-icu")
1180 def in_tree_icu(system_icu):
1181 return not system_icu
1184 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
1185 # for layout/style/extra-bindgen-flags
1186 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
1188 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1189 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1191 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1194 @depends("--with-intl-api", js_standalone)
1195 def check_intl_api(enabled, js_standalone):
1196 if not enabled and not js_standalone:
1197 die("--without-intl-api is not supported")
1200 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1201 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1204 @depends(build_environment, when="--with-intl-api")
1205 @imports(_from="__builtin__", _import="open")
1206 @imports(_from="__builtin__", _import="ValueError")
1207 def icu_version(build_env):
1208 path = os.path.join(
1209 build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1211 with open(path, encoding="utf-8") as fh:
1213 if line.startswith("#define"):
1214 define = line.split(None, 3)
1215 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1217 return str(int(define[2]))
1220 die("Cannot determine ICU version number from uvernum.h header file")
1223 set_config("MOZ_ICU_VERSION", icu_version)
1225 # Source files that use ICU should have control over which parts of the ICU
1226 # namespace they want to use.
1227 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1229 # We build ICU as a static library.
1230 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1233 # ECMAScript Temporal API Support (uses ICU)
1234 # ======================================================
1236 option("--with-temporal-api", default=False, help="Enable ECMAScript Temporal API")
1238 set_config("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1239 set_define("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1242 @depends("--with-temporal-api", "--with-intl-api")
1243 def check_temporal_api(temporal_enabled, intl_enabled):
1244 if temporal_enabled and not intl_enabled:
1245 die("Can't use both --with-temporal-api and --without-intl-api")
1248 # Initial support for WebAssembly JS-API Type Reflections
1249 # =======================================================
1252 @depends(milestone.is_nightly)
1253 def default_wasm_type_reflections(is_nightly):
1258 "--enable-wasm-type-reflections",
1259 default=default_wasm_type_reflections,
1260 help="{Enable|Disable} type reflection in WASM JS-API",
1264 "ENABLE_WASM_TYPE_REFLECTIONS",
1265 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1268 "ENABLE_WASM_TYPE_REFLECTIONS",
1269 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1272 # Wasi configuration
1273 # ===================================================
1277 def is_wasi_target(os):
1281 set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
1282 set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
1285 @depends(milestone.version)
1286 def js_version(version):
1287 return Version(version)
1290 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
1291 set_define("MOZJS_MAJOR_VERSION", js_version.major)
1292 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
1293 set_define("MOZJS_MINOR_VERSION", js_version.minor)
1294 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
1297 depends(js_version)(
1298 lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
1303 # Some platforms have HeapReg, some don't
1304 # =====================================================
1306 # The ARM simulator runs on x86 and might be excluded by the first test,
1307 # so we special-case it.
1310 @depends("--enable-simulator", target)
1311 def wasm_has_heapreg(simulator, target):
1312 if target.cpu != "x86":
1315 if simulator and simulator[0] == "arm":
1319 set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
1321 # Check for tm_zone, tm_gmtoff in struct tm
1322 # ===================================================
1323 with only_when(compile_environment):
1325 "HAVE_TM_ZONE_TM_GMTOFF",
1326 c_compiler.try_compile(
1327 includes=["time.h"],
1328 body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
1329 check_msg="for tm_zone and tm_gmtoff in struct tm",
1334 # Checks for library functions
1335 # ==============================================================
1336 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1337 set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
1338 set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
1339 set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
1340 set_define("HAVE_GETTID", check_symbol("gettid"))
1341 set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
1342 set_define("HAVE_SYSCALL", check_symbol("syscall"))
1343 set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
1344 set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
1345 set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
1346 set_define("HAVE_STRERROR", check_symbol("strerror"))
1349 "HAVE_LANGINFO_CODESET",
1351 includes=["langinfo.h"],
1352 body="char* cs = nl_langinfo(CODESET);",
1353 check_msg="for nl_langinfo and CODESET",
1354 when=building_with_gnu_cc,
1358 @depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
1359 def demangle_symbols(cxa_demangle, moz_debug, dmd):
1360 # Demangle only for debug or DMD builds
1361 if cxa_demangle and (moz_debug or dmd):
1364 set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
1366 set_define("HAVE__UNWIND_BACKTRACE", True, when=have_unwind)
1368 with only_when(compile_environment):
1369 set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
1370 set_define("HAVE_LOCALECONV", check_symbol("localeconv"))