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)
177 # Enable JSON.parse with source
178 # ===================================================
179 @depends(milestone.is_nightly)
180 def enable_json_parse_with_source(is_nightly):
185 set_config("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
186 set_define("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
189 # Portable Baseline Intepreter
190 # =======================================================
192 "--enable-portable-baseline-interp",
194 help="{Enable|Disable} the portable baseline interpreter.",
197 "ENABLE_PORTABLE_BASELINE_INTERP",
198 depends_if("--enable-portable-baseline-interp")(lambda _: True),
201 "ENABLE_PORTABLE_BASELINE_INTERP",
202 depends_if("--enable-portable-baseline-interp")(lambda _: True),
205 # Option to always force PBL tier.
207 "--enable-portable-baseline-interp-force",
209 help="{Enable|Disable} forcing use of the portable baseline interpreter.",
213 "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
214 depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
217 "ENABLE_PORTABLE_BASELINE_INTERP_FORCE",
218 depends_if("--enable-portable-baseline-interp-force")(lambda _: True),
223 # =======================================================
224 @depends(target, "--enable-record-tuple", "--enable-portable-baseline-interp")
225 def jit_default(target, enable_record_tuple, enable_portable_baseline_interp):
226 if enable_record_tuple:
228 if enable_portable_baseline_interp:
243 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
246 @deprecated_option("--enable-ion")
247 def report_deprecated(value):
249 die("--enable-ion is deprecated, use --enable-jit instead")
251 die("--disable-ion is deprecated, use --disable-jit instead")
254 # JIT code simulator for cross compiles
255 # =======================================================
257 "--enable-simulator",
258 choices=("arm", "arm64", "mips32", "mips64", "loong64", "riscv64"),
260 help="Enable a JIT code simulator for the specified architecture",
264 @depends("--enable-jit", "--enable-simulator", target)
265 def simulator(jit_enabled, simulator_enabled, target):
266 if not jit_enabled or not simulator_enabled:
269 sim_cpu = simulator_enabled[0]
271 if sim_cpu in ("arm", "mips32"):
272 if target.cpu != "x86":
273 die("The %s simulator only works on x86." % sim_cpu)
275 if sim_cpu in ("arm64", "mips64", "loong64", "riscv64"):
276 if target.cpu != "x86_64" and target.cpu != "aarch64":
277 die("The %s simulator only works on x86-64 or arm64." % sim_cpu)
279 return namespace(**{sim_cpu: True})
282 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
283 set_config("JS_SIMULATOR_ARM", simulator.arm)
284 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
285 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
286 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
287 set_config("JS_SIMULATOR_LOONG64", simulator.loong64)
288 set_config("JS_SIMULATOR_RISCV64", simulator.riscv64)
289 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
290 set_define("JS_SIMULATOR_ARM", simulator.arm)
291 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
292 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
293 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
294 set_define("JS_SIMULATOR_LOONG64", simulator.loong64)
295 set_define("JS_SIMULATOR_RISCV64", simulator.riscv64)
298 @depends("--enable-jit", simulator, target)
299 def jit_codegen(jit_enabled, simulator, target):
301 return namespace(none=True)
306 if target.cpu == "aarch64":
307 return namespace(arm64=True)
308 elif target.cpu == "x86_64":
309 return namespace(x64=True)
310 elif target.cpu == "loongarch64":
311 return namespace(loong64=True)
312 elif target.cpu == "riscv64":
313 return namespace(riscv64=True)
315 return namespace(**{str(target.cpu): True})
318 set_config("JS_CODEGEN_NONE", jit_codegen.none)
319 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
320 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
321 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
322 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
323 set_config("JS_CODEGEN_LOONG64", jit_codegen.loong64)
324 set_config("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
325 set_config("JS_CODEGEN_X86", jit_codegen.x86)
326 set_config("JS_CODEGEN_X64", jit_codegen.x64)
327 set_config("JS_CODEGEN_WASM32", jit_codegen.wasm32)
329 set_define("JS_CODEGEN_NONE", jit_codegen.none)
330 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
331 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
332 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
333 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
334 set_define("JS_CODEGEN_LOONG64", jit_codegen.loong64)
335 set_define("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
336 set_define("JS_CODEGEN_X86", jit_codegen.x86)
337 set_define("JS_CODEGEN_X64", jit_codegen.x64)
338 set_define("JS_CODEGEN_WASM32", jit_codegen.wasm32)
342 # =======================================================
344 "--enable-instruments",
345 env="MOZ_INSTRUMENTS",
346 help="Enable instruments remote profiling",
350 @depends("--enable-instruments", target)
351 def instruments(value, target):
352 if value and target.os != "OSX":
353 die("--enable-instruments cannot be used when targeting %s", target.os)
358 set_config("MOZ_INSTRUMENTS", instruments)
359 set_define("MOZ_INSTRUMENTS", instruments)
360 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
361 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
363 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
366 @depends("--enable-callgrind")
367 def callgrind(value):
372 set_define("MOZ_CALLGRIND", callgrind)
373 imply_option("--enable-profiling", callgrind)
377 def enable_profiling(milestone):
378 return milestone.is_nightly
382 "--enable-profiling",
384 default=enable_profiling,
385 help="{Set|Do not set} compile flags necessary for using sampling "
386 "profilers (e.g. shark, perf)",
390 @depends("--enable-profiling")
391 def profiling(value):
396 with only_when("--enable-compile-environment"):
397 imply_option("--enable-frame-pointers", True, when=profiling)
400 @depends(profiling, target)
401 def imply_vtune(value, target):
402 ok_cpu = target.cpu in ["x86", "x86_64"]
403 ok_kernel = target.kernel == "WINNT" or (
404 target.kernel == "Linux" and target.os == "GNU"
407 if value and ok_cpu and ok_kernel:
411 set_config("MOZ_PROFILING", profiling)
412 set_define("MOZ_PROFILING", profiling)
413 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
416 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
419 @depends("--enable-vtune")
425 set_config("MOZ_VTUNE", vtune)
426 set_define("MOZ_VTUNE", vtune)
430 "--enable-gc-probes",
432 help="Turn on probes for allocation and finalization",
436 @depends("--enable-gc-probes")
437 def gc_probes(value):
442 set_define("JS_GC_PROBES", gc_probes)
447 default=depends(when=moz_debug)(lambda: True),
448 help="{Enable|Disable} zealous GCing",
451 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
454 # Enable breakpoint for artificial OOMs
455 # =======================================================
457 "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
460 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
463 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
466 @depends("--enable-perf", target)
467 def ion_perf(value, target):
468 is_linux = target.kernel == "Linux"
469 is_mac = target.kernel == "Darwin" and target.os == "OSX"
471 if value and (is_linux or is_mac):
475 set_define("JS_ION_PERF", ion_perf)
480 default=depends(when=moz_debug)(lambda: True),
481 help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
484 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
485 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
487 # Also enable the structured spewer
488 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
489 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
492 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
493 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
497 if simulator and (debug or spew):
498 if getattr(simulator, "arm", None):
501 if target.cpu == "arm" and (debug or spew):
505 set_config("JS_DISASM_ARM", jit_disasm_arm)
506 set_define("JS_DISASM_ARM", jit_disasm_arm)
509 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
510 def jit_disasm_riscv(jit_enabled, spew, simulator, target, debug):
514 if simulator and (debug or spew):
515 if getattr(simulator, "riscv64", None):
518 if target.cpu == "riscv64" and (debug or spew):
522 set_config("JS_DISASM_RISCV64", jit_disasm_riscv)
523 set_define("JS_DISASM_RISCV64", jit_disasm_riscv)
526 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
527 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
531 if simulator and (debug or spew):
532 if getattr(simulator, "arm64", None):
535 if target.cpu == "aarch64" and (debug or spew):
539 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
540 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
542 # When enabled, masm will generate assumeUnreachable calls that act as
543 # assertions in the generated code. This option is worth disabling when you
544 # have to track mutated values through the generated code, to avoid constantly
545 # dumping registers on and off the stack.
547 "--enable-masm-verbose",
548 default=depends(when=moz_debug)(lambda: True),
549 help="{Enable|Disable} MacroAssembler verbosity of generated code.",
551 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
552 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
554 # Architecture feature flags
555 # =======================================================
558 # Apple silicon does not seem to have any way to query the OS for the JSCVT
559 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
560 # hard code the value of the JSCVT flag which guards the implementation of
561 # FJCVTZS instruction as part of ARMv8.3-JSConv.
563 def is_apple_silicon(target):
564 return target.kernel == "Darwin" and target.cpu == "aarch64"
568 "--enable-arm64-fjcvtzs",
569 default=is_apple_silicon,
570 help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
574 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
575 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
578 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
579 @depends("--enable-arm64-fjcvtzs", target, simulator)
580 def aarch64_jscvt(fjcvtzs, target, simulator):
581 if target.cpu == "aarch64" and fjcvtzs:
584 if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
590 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
594 def has_apple_fast_wx(target):
595 return target.kernel == "Darwin" and target.cpu == "aarch64"
598 # On Apple Silicon macOS we use MAP_JIT with pthread_jit_write_protect_np to
599 # implement JIT code write protection, while on iOS we use MAP_JIT with
600 # be_memory_inline_jit_restrict_*.
601 set_define("JS_USE_APPLE_FAST_WX", True, when=has_apple_fast_wx)
605 # =======================================================
606 @depends(js_standalone)
607 def ctypes_default(js_standalone):
608 return not js_standalone
611 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
613 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
615 set_config("BUILD_CTYPES", build_ctypes)
616 set_define("BUILD_CTYPES", build_ctypes)
618 set_config("JS_HAS_CTYPES", build_ctypes)
619 set_define("JS_HAS_CTYPES", build_ctypes)
622 @depends("--enable-ctypes", "--enable-compile-environment")
623 def ctypes_and_compile_environment(ctypes, compile_environment):
624 return ctypes and compile_environment
627 include("ffi.configure", when=ctypes_and_compile_environment)
630 # Enable pipeline operator
631 # ===================================================
632 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
635 @depends("--enable-pipeline-operator")
636 def enable_pipeline_operator(value):
641 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
642 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
645 # SIMD acceleration for encoding_rs
646 # ==============================================================
649 "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
653 @depends("--enable-rust-simd", target)
654 def rust_simd(value, target):
655 # As of 2019-09-17, the simd-accel feature of encoding_rs has not
656 # been properly set up outside aarch64, armv7, x86 and x86_64.
657 if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
661 set_config("MOZ_RUST_SIMD", rust_simd)
662 set_define("MOZ_RUST_SIMD", rust_simd)
664 # Telemetry to measure compile time and generated-code runtime
665 # ============================================================
668 "--enable-spidermonkey-telemetry",
669 default=milestone.is_nightly,
670 help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
674 "ENABLE_SPIDERMONKEY_TELEMETRY",
675 depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
678 # Support for debugging code generated by wasm backends
679 # =====================================================
682 "--enable-wasm-codegen-debug",
683 default=depends(when=moz_debug)(lambda: True),
684 help="{Enable|Disable} debugging for wasm codegen",
688 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
691 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
694 # WebAssembly feature flags
695 # ==================================================
698 "--wasm-no-experimental",
700 help="Force disable all wasm experimental features for testing.",
703 # Support for WebAssembly tail-calls.
704 # ===========================
708 def default_wasm_tail_calls(target):
709 if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
714 "--enable-wasm-tail-calls",
715 default=default_wasm_tail_calls,
716 help="{Enable|Disable} WebAssembly tail-calls",
720 @depends("--enable-wasm-tail-calls", target)
721 def wasm_tail_calls(value, target):
725 if target.cpu in ("x86", "x86_64", "arm", "aarch64", "loongarch64", "mips64"):
729 "--enable-wasm-tail-calls only possible when targeting the x86_64/x86/arm64/arm/loongarch64/mips64 jits"
733 set_config("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
734 set_define("ENABLE_WASM_TAIL_CALLS", wasm_tail_calls)
736 # Support for WebAssembly GC.
737 # ===========================
740 option("--disable-wasm-gc", default=True, help="{Enable|Disable} WebAssembly GC")
743 @depends("--disable-wasm-gc")
750 set_config("ENABLE_WASM_GC", wasm_gc)
751 set_define("ENABLE_WASM_GC", wasm_gc)
753 # Support for WebAssembly JS String Builtins
754 # ==========================================
758 "--disable-wasm-js-string-builtins",
760 help="{Enable|Disable} WebAssembly JS String Builtins",
764 @depends("--disable-wasm-js-string-builtins", "--wasm-no-experimental")
765 def wasm_js_string_builtins(value, no_experimental):
766 if no_experimental or not value:
772 set_config("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
773 set_define("ENABLE_WASM_JS_STRING_BUILTINS", wasm_js_string_builtins)
775 # Support for WebAssembly shared memory and atomics.
777 # This affects the JS shell only.
778 # =====================================================
781 "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
785 @depends("--disable-shared-memory")
786 def enable_shared_memory(value):
791 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
792 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
794 # Support for WebAssembly SIMD
795 # =====================================================
798 @depends("--enable-jit", "--enable-simulator", target)
799 def default_wasm_simd(jit_enabled, simulator, target):
803 if simulator and (simulator[0] != "arm64"):
806 if target.cpu in ("x86_64", "x86", "aarch64"):
811 "--enable-wasm-simd",
812 default=default_wasm_simd,
813 help="{Enable|Disable} WebAssembly SIMD",
818 "--enable-wasm-simd",
820 "--enable-simulator",
822 "--wasm-no-experimental",
824 def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
825 if no_experimental or not value:
829 die("--enable-wasm-simd requires --enable-jit")
831 if simulator and (simulator[0] != "arm64"):
832 die("--enable-wasm-simd is not supported for simulators, except arm64")
834 if target.cpu in ("x86_64", "x86", "aarch64"):
837 die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
840 set_config("ENABLE_WASM_SIMD", wasm_simd)
841 set_define("ENABLE_WASM_SIMD", wasm_simd)
843 # Whether to check for field changes in WebAssembly serialization
845 # See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
846 # for more background.
847 # =====================================================================
855 "--wasm-no-experimental",
857 def wasm_verify_serialization_for_size(
858 target, c_compiler, debug, milestone, no_experimental
862 and target.kernel == "Linux"
863 and target.cpu == "x86_64"
865 and c_compiler.type == "clang"
866 and milestone.is_nightly
867 and not no_experimental
874 "ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
877 # Support for Intel AVX instruction.
879 # AVX is exclusively used in WebAssembly SIMD instructions at the moment:
880 # set direct dependency on "--enable-wasm-simd".
881 # =====================================================
884 @depends("--enable-wasm-simd", "--enable-simulator", target)
885 def default_wasm_avx(wasm_simd_enabled, simulator, target):
886 if not wasm_simd_enabled:
892 if target.cpu in ("x86_64", "x86"):
898 default=default_wasm_avx,
899 help="{Enable|Disable} AVX support for WebAssembly SIMD",
905 "--enable-wasm-simd",
906 "--enable-simulator",
908 "--wasm-no-experimental",
910 def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
911 if no_experimental or not value:
914 if not wasm_simd_enabled:
915 die("--enable-wasm-avx requires --enable-wasm-simd")
918 die("--enable-wasm-avx is not supported for simulators")
920 if target.cpu in ("x86_64", "x86"):
923 die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
926 set_config("ENABLE_WASM_AVX", wasm_avx)
927 set_define("ENABLE_WASM_AVX", wasm_avx)
929 # Support for WebAssembly relaxed SIMD
930 # =====================================================
933 @depends(milestone.is_nightly, "--enable-wasm-simd")
934 def default_wasm_relaxed_simd(is_nightly, wasm_simd):
935 if is_nightly and wasm_simd:
940 "--enable-wasm-relaxed-simd",
941 default=default_wasm_relaxed_simd,
942 help="{Enable|Disable} WebAssembly relaxed SIMD",
946 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd", "--wasm-no-experimental")
947 def wasm_relaxed_simd(value, wasm_simd, no_experimental):
948 if no_experimental or not value:
952 die("relaxed SIMD requires SIMD")
957 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
958 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
960 # Support for WebAssembly intgemm private intrinsics
961 # =====================================================
965 def default_wasm_moz_intgemm(target):
966 return target.cpu in ("x86", "x86_64", "aarch64")
970 "--enable-wasm-moz-intgemm",
971 default=default_wasm_moz_intgemm,
972 help="{Enable|Disable} WebAssembly intgemm private intrinsics",
976 @depends("--enable-wasm-moz-intgemm", "--wasm-no-experimental")
977 def wasm_moz_intgemm(value, no_experimental):
985 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
986 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
988 # Support for WebAssembly Memory64.
989 # ===========================
992 @depends(milestone.is_nightly, "--enable-simulator", target)
993 def default_wasm_memory64(is_nightly, simulator, target):
994 if target.cpu == "mips32":
997 if simulator and simulator[0] == "mips32":
1005 "--enable-wasm-memory64",
1006 default=default_wasm_memory64,
1007 help="{Enable|Disable} WebAssembly Memory64",
1012 "--enable-wasm-memory64", "--enable-simulator", target, "--wasm-no-experimental"
1014 def wasm_memory64(value, simulator, target, no_experimental):
1015 if no_experimental or not value:
1018 if target.cpu == "mips32":
1019 die("Memory64 is incompatible with MIPS32 target")
1021 if simulator and simulator[0] == "mips32":
1022 die("Memory64 is incompatible with MIPS32 simulator")
1027 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
1028 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
1031 # Support for WebAssembly memory control.
1032 # ===========================
1035 @depends(milestone.is_nightly)
1036 def default_wasm_memory_control(is_nightly):
1042 "--enable-wasm-memory-control",
1043 default=default_wasm_memory_control,
1044 help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
1048 @depends("--enable-wasm-memory-control", "--wasm-no-experimental")
1049 def wasm_memory_control(value, no_experimental):
1050 if no_experimental or not value:
1056 set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1057 set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1060 # Support for WebAssembly Multi Memory.
1061 # =====================================
1065 "--disable-wasm-multi-memory",
1066 help="{Enable|Disable} WebAssembly multi-memory",
1070 @depends("--disable-wasm-multi-memory")
1071 def wasm_multi_memory(value):
1076 set_config("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1077 set_define("ENABLE_WASM_MULTI_MEMORY", wasm_multi_memory)
1080 # Support for WebAssembly Branch-hinting.
1081 # ===========================
1084 @depends(milestone.is_nightly)
1085 def default_wasm_branch_hinting(is_nightly):
1091 "--enable-wasm-branch-hinting",
1092 default=default_wasm_branch_hinting,
1093 help="{Enable|Disable} WebAssembly Branch hints",
1097 @depends("--enable-wasm-branch-hinting", "--wasm-no-experimental")
1098 def wasm_branch_hinting(value, no_experimental):
1099 if no_experimental or not value:
1105 set_config("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
1106 set_define("ENABLE_WASM_BRANCH_HINTING", wasm_branch_hinting)
1108 # Options for generating the shell as a script
1109 # ============================================
1110 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
1111 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
1116 default=depends(target.alias)(lambda x: "/usr/%s" % x),
1117 help="Use dir as the location for arm libraries",
1119 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
1121 # Enable static checking using sixgill
1122 # ====================================
1124 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
1127 @depends_if("--with-sixgill")
1130 for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
1131 if not os.path.exists(os.path.join(value[0], f)):
1132 die("The sixgill plugin and binaries are not at the specified path")
1136 set_config("SIXGILL_PATH", sixgill)
1139 # Support for readline
1140 # =====================================================
1143 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
1144 def editline(js_shell, is_windows, compile_environment, target):
1145 return js_shell and not is_windows and compile_environment and (target.os != "WASI")
1149 "--enable-readline", help="Link js shell to system readline library", when=editline
1152 has_readline = check_symbol(
1154 flags=["-lreadline"],
1155 when="--enable-readline",
1156 onerror=lambda: die("No system readline library found"),
1159 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
1162 @depends("--enable-readline", editline, when=editline)
1163 def bundled_editline(readline, editline):
1164 return editline and not readline
1167 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
1169 set_define("EDITLINE", True, when=editline)
1176 "--with-jitreport-granularity",
1178 choices=("0", "1", "2", "3"),
1179 help="Default granularity at which to report JIT code to external tools "
1180 "(0 - no info, 1 - code ranges for while functions only, "
1181 "2 - per-line information, 3 - per-op information)",
1185 "JS_DEFAULT_JITREPORT_GRANULARITY",
1186 depends_if("--with-jitreport-granularity")(lambda value: value[0]),
1190 # ECMAScript Internationalization API Support (uses ICU)
1191 # ======================================================
1192 system_lib_option("--with-system-icu", help="Use system ICU")
1194 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 73.1", when="--with-system-icu")
1197 @depends("--with-system-icu")
1198 def in_tree_icu(system_icu):
1199 return not system_icu
1202 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
1203 # for layout/style/extra-bindgen-flags
1204 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
1206 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1207 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1209 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1212 @depends("--with-intl-api", js_standalone)
1213 def check_intl_api(enabled, js_standalone):
1214 if not enabled and not js_standalone:
1215 die("--without-intl-api is not supported")
1218 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1219 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1222 @depends(build_environment, when="--with-intl-api")
1223 @imports(_from="__builtin__", _import="open")
1224 @imports(_from="__builtin__", _import="ValueError")
1225 def icu_version(build_env):
1226 path = os.path.join(
1227 build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1229 with open(path, encoding="utf-8") as fh:
1231 if line.startswith("#define"):
1232 define = line.split(None, 3)
1233 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1235 return str(int(define[2]))
1238 die("Cannot determine ICU version number from uvernum.h header file")
1241 set_config("MOZ_ICU_VERSION", icu_version)
1243 # Source files that use ICU should have control over which parts of the ICU
1244 # namespace they want to use.
1245 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1247 # We build ICU as a static library.
1248 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1251 # ECMAScript Temporal API Support (uses ICU)
1252 # ======================================================
1254 option("--with-temporal-api", default=False, help="Enable ECMAScript Temporal API")
1256 set_config("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1257 set_define("JS_HAS_TEMPORAL_API", True, when="--with-temporal-api")
1260 @depends("--with-temporal-api", "--with-intl-api")
1261 def check_temporal_api(temporal_enabled, intl_enabled):
1262 if temporal_enabled and not intl_enabled:
1263 die("Can't use both --with-temporal-api and --without-intl-api")
1266 # Initial support for WebAssembly JS-API Type Reflections
1267 # =======================================================
1270 @depends(milestone.is_nightly)
1271 def default_wasm_type_reflections(is_nightly):
1276 "--enable-wasm-type-reflections",
1277 default=default_wasm_type_reflections,
1278 help="{Enable|Disable} type reflection in WASM JS-API",
1282 "ENABLE_WASM_TYPE_REFLECTIONS",
1283 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1286 "ENABLE_WASM_TYPE_REFLECTIONS",
1287 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1290 # Wasi configuration
1291 # ===================================================
1295 def is_wasi_target(os):
1299 set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
1300 set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
1303 @depends(milestone.version)
1304 def js_version(version):
1305 return Version(version)
1308 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
1309 set_define("MOZJS_MAJOR_VERSION", js_version.major)
1310 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
1311 set_define("MOZJS_MINOR_VERSION", js_version.minor)
1312 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
1315 depends(js_version)(
1316 lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
1321 # Some platforms have HeapReg, some don't
1322 # =====================================================
1324 # The ARM simulator runs on x86 and might be excluded by the first test,
1325 # so we special-case it.
1328 @depends("--enable-simulator", target)
1329 def wasm_has_heapreg(simulator, target):
1330 if target.cpu != "x86":
1333 if simulator and simulator[0] == "arm":
1337 set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
1339 # Check for tm_zone, tm_gmtoff in struct tm
1340 # ===================================================
1341 with only_when(compile_environment):
1343 "HAVE_TM_ZONE_TM_GMTOFF",
1344 c_compiler.try_compile(
1345 includes=["time.h"],
1346 body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
1347 check_msg="for tm_zone and tm_gmtoff in struct tm",
1352 # Checks for library functions
1353 # ==============================================================
1354 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1355 set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
1356 set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
1357 set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
1358 set_define("HAVE_GETTID", check_symbol("gettid"))
1359 set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
1360 set_define("HAVE_SYSCALL", check_symbol("syscall"))
1361 set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
1362 set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
1363 set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
1364 set_define("HAVE_STRERROR", check_symbol("strerror"))
1367 "HAVE_LANGINFO_CODESET",
1369 includes=["langinfo.h"],
1370 body="char* cs = nl_langinfo(CODESET);",
1371 check_msg="for nl_langinfo and CODESET",
1372 when=building_with_gnu_cc,
1376 @depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
1377 def demangle_symbols(cxa_demangle, moz_debug, dmd):
1378 # Demangle only for debug or DMD builds
1379 if cxa_demangle and (moz_debug or dmd):
1382 set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
1384 set_define("HAVE__UNWIND_BACKTRACE", True, when=have_unwind)
1386 with only_when(compile_environment):
1387 set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
1388 set_define("HAVE_LOCALECONV", check_symbol("localeconv"))