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 # =======================================================
178 @depends(target, "--enable-record-tuple")
179 def jit_default(target, enable_record_tuple):
180 if enable_record_tuple:
195 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
198 @deprecated_option("--enable-ion")
199 def report_deprecated(value):
201 die("--enable-ion is deprecated, use --enable-jit instead")
203 die("--disable-ion is deprecated, use --disable-jit instead")
206 # JIT code simulator for cross compiles
207 # =======================================================
209 "--enable-simulator",
210 choices=("arm", "arm64", "mips32", "mips64", "loong64", "riscv64"),
212 help="Enable a JIT code simulator for the specified architecture",
216 @depends("--enable-jit", "--enable-simulator", target)
217 def simulator(jit_enabled, simulator_enabled, target):
218 if not jit_enabled or not simulator_enabled:
221 sim_cpu = simulator_enabled[0]
223 if sim_cpu in ("arm", "mips32"):
224 if target.cpu != "x86":
225 die("The %s simulator only works on x86." % sim_cpu)
227 if sim_cpu in ("arm64", "mips64", "loong64", "riscv64"):
228 if target.cpu != "x86_64" and target.cpu != "aarch64":
229 die("The %s simulator only works on x86-64 or arm64." % sim_cpu)
231 return namespace(**{sim_cpu: True})
234 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
235 set_config("JS_SIMULATOR_ARM", simulator.arm)
236 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
237 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
238 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
239 set_config("JS_SIMULATOR_LOONG64", simulator.loong64)
240 set_config("JS_SIMULATOR_RISCV64", simulator.riscv64)
241 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
242 set_define("JS_SIMULATOR_ARM", simulator.arm)
243 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
244 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
245 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
246 set_define("JS_SIMULATOR_LOONG64", simulator.loong64)
247 set_define("JS_SIMULATOR_RISCV64", simulator.riscv64)
250 @depends("--enable-jit", simulator, target)
251 def jit_codegen(jit_enabled, simulator, target):
253 return namespace(none=True)
258 if target.cpu == "aarch64":
259 return namespace(arm64=True)
260 elif target.cpu == "x86_64":
261 return namespace(x64=True)
262 elif target.cpu == "loongarch64":
263 return namespace(loong64=True)
264 elif target.cpu == "riscv64":
265 return namespace(riscv64=True)
267 return namespace(**{str(target.cpu): True})
270 set_config("JS_CODEGEN_NONE", jit_codegen.none)
271 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
272 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
273 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
274 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
275 set_config("JS_CODEGEN_LOONG64", jit_codegen.loong64)
276 set_config("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
277 set_config("JS_CODEGEN_X86", jit_codegen.x86)
278 set_config("JS_CODEGEN_X64", jit_codegen.x64)
279 set_config("JS_CODEGEN_WASM32", jit_codegen.wasm32)
281 set_define("JS_CODEGEN_NONE", jit_codegen.none)
282 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
283 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
284 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
285 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
286 set_define("JS_CODEGEN_LOONG64", jit_codegen.loong64)
287 set_define("JS_CODEGEN_RISCV64", jit_codegen.riscv64)
288 set_define("JS_CODEGEN_X86", jit_codegen.x86)
289 set_define("JS_CODEGEN_X64", jit_codegen.x64)
290 set_define("JS_CODEGEN_WASM32", jit_codegen.wasm32)
294 # =======================================================
296 "--enable-instruments",
297 env="MOZ_INSTRUMENTS",
298 help="Enable instruments remote profiling",
302 @depends("--enable-instruments", target)
303 def instruments(value, target):
304 if value and target.os != "OSX":
305 die("--enable-instruments cannot be used when targeting %s", target.os)
310 set_config("MOZ_INSTRUMENTS", instruments)
311 set_define("MOZ_INSTRUMENTS", instruments)
312 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
313 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
315 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
318 @depends("--enable-callgrind")
319 def callgrind(value):
324 set_define("MOZ_CALLGRIND", callgrind)
325 imply_option("--enable-profiling", callgrind)
329 def enable_profiling(milestone):
330 return milestone.is_nightly
334 "--enable-profiling",
336 default=enable_profiling,
337 help="{Set|Do not set} compile flags necessary for using sampling "
338 "profilers (e.g. shark, perf)",
342 @depends("--enable-profiling")
343 def profiling(value):
348 with only_when("--enable-compile-environment"):
349 imply_option("--enable-frame-pointers", True, when=profiling)
352 @depends(profiling, target)
353 def imply_vtune(value, target):
354 ok_cpu = target.cpu in ["x86", "x86_64"]
355 ok_kernel = target.kernel == "WINNT" or (
356 target.kernel == "Linux" and target.os == "GNU"
359 if value and ok_cpu and ok_kernel:
363 set_config("MOZ_PROFILING", profiling)
364 set_define("MOZ_PROFILING", profiling)
365 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
368 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
371 @depends("--enable-vtune")
377 set_config("MOZ_VTUNE", vtune)
378 set_define("MOZ_VTUNE", vtune)
382 "--enable-gc-probes",
384 help="Turn on probes for allocation and finalization",
388 @depends("--enable-gc-probes")
389 def gc_probes(value):
394 set_define("JS_GC_PROBES", gc_probes)
399 default=depends(when=moz_debug)(lambda: True),
400 help="{Enable|Disable} zealous GCing",
403 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
406 # Use a smaller chunk size for GC chunks
407 # ========================================================
408 # Use large (1MB) chunks by default. This option can be used to give
409 # smaller (currently 256K) chunks.
411 "--enable-small-chunk-size",
412 help="Allocate memory for JS GC things in smaller chunks",
416 "JS_GC_SMALL_CHUNK_SIZE", depends(when="--enable-small-chunk-size")(lambda: True)
420 # Enable breakpoint for artificial OOMs
421 # =======================================================
423 "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
426 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
429 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
432 @depends("--enable-perf", target)
433 def ion_perf(value, target):
434 is_linux = target.kernel == "Linux" and target.os == "GNU"
435 is_mac = target.kernel == "Darwin" and target.os == "OSX"
437 if value and (is_linux or is_mac):
441 set_define("JS_ION_PERF", ion_perf)
446 default=depends(when=moz_debug)(lambda: True),
447 help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
450 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
451 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
453 # Also enable the structured spewer
454 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
455 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
458 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
459 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
463 if simulator and (debug or spew):
464 if getattr(simulator, "arm", None):
467 if target.cpu == "arm" and (debug or spew):
471 set_config("JS_DISASM_ARM", jit_disasm_arm)
472 set_define("JS_DISASM_ARM", jit_disasm_arm)
475 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
476 def jit_disasm_riscv(jit_enabled, spew, simulator, target, debug):
480 if simulator and (debug or spew):
481 if getattr(simulator, "riscv64", None):
484 if target.cpu == "riscv64" and (debug or spew):
488 set_config("JS_DISASM_RISCV64", jit_disasm_riscv)
489 set_define("JS_DISASM_RISCV64", jit_disasm_riscv)
492 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
493 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
497 if simulator and (debug or spew):
498 if getattr(simulator, "arm64", None):
501 if target.cpu == "aarch64" and (debug or spew):
505 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
506 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
508 # When enabled, masm will generate assumeUnreachable calls that act as
509 # assertions in the generated code. This option is worth disabling when you
510 # have to track mutated values through the generated code, to avoid constantly
511 # dumping registers on and off the stack.
513 "--enable-masm-verbose",
514 default=depends(when=moz_debug)(lambda: True),
515 help="{Enable|Disable} MacroAssembler verbosity of generated code.",
517 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
518 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
520 # Architecture feature flags
521 # =======================================================
523 # Apple silicon does not seem to have any way to query the OS for the JSCVT
524 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
525 # hard code the value of the JSCVT flag which guards the implementation of
526 # FJCVTZS instruction as part of ARMv8.3-JSConv.
528 def is_apple_silicon(target):
529 return target.os == "OSX" and target.kernel == "Darwin" and target.cpu == "aarch64"
533 "--enable-arm64-fjcvtzs",
534 default=is_apple_silicon,
535 help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
538 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
539 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
542 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
543 @depends("--enable-arm64-fjcvtzs", target, simulator)
544 def aarch64_jscvt(fjcvtzs, target, simulator):
545 if target.cpu == "aarch64" and fjcvtzs:
548 if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
554 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
557 # =======================================================
558 @depends(js_standalone)
559 def ctypes_default(js_standalone):
560 return not js_standalone
563 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
565 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
567 set_config("BUILD_CTYPES", build_ctypes)
568 set_define("BUILD_CTYPES", build_ctypes)
570 set_config("JS_HAS_CTYPES", build_ctypes)
571 set_define("JS_HAS_CTYPES", build_ctypes)
574 @depends("--enable-ctypes", "--enable-compile-environment")
575 def ctypes_and_compile_environment(ctypes, compile_environment):
576 return ctypes and compile_environment
579 include("ffi.configure", when=ctypes_and_compile_environment)
582 # Enable pipeline operator
583 # ===================================================
584 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
587 @depends("--enable-pipeline-operator")
588 def enable_pipeline_operator(value):
593 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
594 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
597 # SIMD acceleration for encoding_rs
598 # ==============================================================
601 "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
605 @depends("--enable-rust-simd", target)
606 def rust_simd(value, target):
607 # As of 2019-09-17, the simd-accel feature of encoding_rs has not
608 # been properly set up outside aarch64, armv7, x86 and x86_64.
609 if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
613 set_config("MOZ_RUST_SIMD", rust_simd)
614 set_define("MOZ_RUST_SIMD", rust_simd)
616 # Telemetry to measure compile time and generated-code runtime
617 # ============================================================
620 "--enable-spidermonkey-telemetry",
621 default=milestone.is_nightly,
622 help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
626 "ENABLE_SPIDERMONKEY_TELEMETRY",
627 depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
630 # Support for debugging code generated by wasm backends
631 # =====================================================
634 "--enable-wasm-codegen-debug",
635 default=depends(when=moz_debug)(lambda: True),
636 help="{Enable|Disable} debugging for wasm codegen",
640 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
643 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
646 # WebAssembly feature flags
647 # ==================================================
650 "--wasm-no-experimental",
652 help="Force disable all wasm experimental features for testing.",
655 # Support for WebAssembly function-references.
656 # ===========================
659 @depends(milestone.is_nightly)
660 def default_wasm_function_references(is_nightly):
666 "--enable-wasm-function-references",
667 default=default_wasm_function_references,
668 help="{Enable|Disable} WebAssembly function-references",
672 @depends("--enable-wasm-function-references", "--wasm-no-experimental")
673 def wasm_function_references(value, no_experimental):
681 set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
682 set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
684 # Support for WebAssembly GC.
685 # ===========================
688 @depends(milestone.is_nightly, "--enable-wasm-function-references")
689 def default_wasm_gc(is_nightly, function_references):
690 if is_nightly and function_references:
695 "--enable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
700 "--enable-wasm-gc", "--enable-wasm-function-references", "--wasm-no-experimental"
702 def wasm_gc(value, function_references, no_experimental):
703 if no_experimental or not value:
706 if function_references:
709 die("--enable-wasm-gc only possible with --enable-wasm-function-references")
712 set_config("ENABLE_WASM_GC", wasm_gc)
713 set_define("ENABLE_WASM_GC", wasm_gc)
716 # Support for WebAssembly shared memory and atomics.
718 # This affects the JS shell only.
719 # =====================================================
722 "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
726 @depends("--disable-shared-memory")
727 def enable_shared_memory(value):
732 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
733 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
735 # Support for WebAssembly extended constant expressions
736 # =====================================================
740 "--disable-wasm-extended-const",
741 help="{Enable|Disable} WebAssembly extended constant expressions",
745 @depends("--disable-wasm-extended-const")
746 def wasm_extended_const(value):
751 set_config("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
752 set_define("ENABLE_WASM_EXTENDED_CONST", wasm_extended_const)
754 # Support for WebAssembly SIMD
755 # =====================================================
758 @depends("--enable-jit", "--enable-simulator", target)
759 def default_wasm_simd(jit_enabled, simulator, target):
763 if simulator and (simulator[0] != "arm64"):
766 if target.cpu in ("x86_64", "x86", "aarch64"):
771 "--enable-wasm-simd",
772 default=default_wasm_simd,
773 help="{Enable|Disable} WebAssembly SIMD",
778 "--enable-wasm-simd",
780 "--enable-simulator",
782 "--wasm-no-experimental",
784 def wasm_simd(value, jit_enabled, simulator, target, no_experimental):
785 if no_experimental or not value:
789 die("--enable-wasm-simd requires --enable-jit")
791 if simulator and (simulator[0] != "arm64"):
792 die("--enable-wasm-simd is not supported for simulators, except arm64")
794 if target.cpu in ("x86_64", "x86", "aarch64"):
797 die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
800 set_config("ENABLE_WASM_SIMD", wasm_simd)
801 set_define("ENABLE_WASM_SIMD", wasm_simd)
803 # Whether to check for field changes in WebAssembly serialization
805 # See the comment for 'WASM_VERIFY_SERIALIZATION_FOR_SIZE' in WasmSerialize.cpp
806 # for more background.
807 # =====================================================================
815 "--wasm-no-experimental",
817 def wasm_verify_serialization_for_size(
818 target, c_compiler, debug, milestone, no_experimental
822 and target.kernel == "Linux"
823 and target.cpu == "x86_64"
825 and c_compiler.type == "clang"
826 and milestone.is_nightly
827 and not no_experimental
834 "ENABLE_WASM_VERIFY_SERIALIZATION_FOR_SIZE", wasm_verify_serialization_for_size
837 # Support for Intel AVX instruction.
839 # AVX is exclusively used in WebAssembly SIMD instructions at the moment:
840 # set direct dependency on "--enable-wasm-simd".
841 # =====================================================
844 @depends("--enable-wasm-simd", "--enable-simulator", target)
845 def default_wasm_avx(wasm_simd_enabled, simulator, target):
846 if not wasm_simd_enabled:
852 if target.cpu in ("x86_64", "x86"):
858 default=default_wasm_avx,
859 help="{Enable|Disable} AVX support for WebAssembly SIMD",
865 "--enable-wasm-simd",
866 "--enable-simulator",
868 "--wasm-no-experimental",
870 def wasm_avx(value, wasm_simd_enabled, simulator, target, no_experimental):
871 if no_experimental or not value:
874 if not wasm_simd_enabled:
875 die("--enable-wasm-avx requires --enable-wasm-simd")
878 die("--enable-wasm-avx is not supported for simulators")
880 if target.cpu in ("x86_64", "x86"):
883 die("--enable-wasm-avx only possible when targeting the x86_64/x86 jits")
886 set_config("ENABLE_WASM_AVX", wasm_avx)
887 set_define("ENABLE_WASM_AVX", wasm_avx)
889 # Support for WebAssembly relaxed SIMD
890 # =====================================================
893 @depends(milestone.is_nightly, "--enable-wasm-simd")
894 def default_wasm_relaxed_simd(is_nightly, wasm_simd):
895 if is_nightly and wasm_simd:
900 "--enable-wasm-relaxed-simd",
901 default=default_wasm_relaxed_simd,
902 help="{Enable|Disable} WebAssembly relaxed SIMD",
906 @depends("--enable-wasm-relaxed-simd", "--enable-wasm-simd", "--wasm-no-experimental")
907 def wasm_relaxed_simd(value, wasm_simd, no_experimental):
908 if no_experimental or not value:
912 die("relaxed SIMD requires SIMD")
917 set_config("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
918 set_define("ENABLE_WASM_RELAXED_SIMD", wasm_relaxed_simd)
920 # Support for WebAssembly intgemm private intrinsics
921 # =====================================================
924 @depends(milestone.is_nightly)
925 def default_wasm_moz_intgemm(is_nightly):
931 "--enable-wasm-moz-intgemm",
932 default=default_wasm_moz_intgemm,
933 help="{Enable|Disable} WebAssembly intgemm private intrinsics",
937 @depends("--enable-wasm-moz-intgemm", target, "--wasm-no-experimental")
938 def wasm_moz_intgemm(value, target, no_experimental):
942 if value and target.cpu in ("x86", "x86_64", "aarch64"):
946 set_config("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
947 set_define("ENABLE_WASM_MOZ_INTGEMM", wasm_moz_intgemm)
949 # Support for WebAssembly Memory64.
950 # ===========================
953 @depends(milestone.is_nightly, "--enable-simulator", target)
954 def default_wasm_memory64(is_nightly, simulator, target):
955 if target.cpu == "mips32":
958 if simulator and simulator[0] == "mips32":
966 "--enable-wasm-memory64",
967 default=default_wasm_memory64,
968 help="{Enable|Disable} WebAssembly Memory64",
973 "--enable-wasm-memory64", "--enable-simulator", target, "--wasm-no-experimental"
975 def wasm_memory64(value, simulator, target, no_experimental):
976 if no_experimental or not value:
979 if target.cpu == "mips32":
980 die("Memory64 is incompatible with MIPS32 target")
982 if simulator and simulator[0] == "mips32":
983 die("Memory64 is incompatible with MIPS32 simulator")
988 set_config("ENABLE_WASM_MEMORY64", wasm_memory64)
989 set_define("ENABLE_WASM_MEMORY64", wasm_memory64)
992 # Support for WebAssembly memory control.
993 # ===========================
996 @depends(milestone.is_nightly)
997 def default_wasm_memory_control(is_nightly):
1003 "--enable-wasm-memory-control",
1004 default=default_wasm_memory_control,
1005 help="{Enable|Disable} WebAssembly fine-grained memory control instructions",
1009 @depends("--enable-wasm-memory-control", "--wasm-no-experimental")
1010 def wasm_memory_control(value, no_experimental):
1011 if no_experimental or not value:
1017 set_config("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1018 set_define("ENABLE_WASM_MEMORY_CONTROL", wasm_memory_control)
1021 # Options for generating the shell as a script
1022 # ============================================
1023 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
1024 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
1029 default=depends(target.alias)(lambda x: "/usr/%s" % x),
1030 help="Use dir as the location for arm libraries",
1032 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
1034 # Enable static checking using sixgill
1035 # ====================================
1037 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
1040 @depends_if("--with-sixgill")
1043 for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
1044 if not os.path.exists(os.path.join(value[0], f)):
1045 die("The sixgill plugin and binaries are not at the specified path")
1049 set_config("SIXGILL_PATH", sixgill)
1052 # Support for readline
1053 # =====================================================
1056 @depends("--enable-js-shell", target_is_windows, compile_environment, target)
1057 def editline(js_shell, is_windows, compile_environment, target):
1058 return js_shell and not is_windows and compile_environment and (target.os != "WASI")
1062 "--enable-readline", help="Link js shell to system readline library", when=editline
1065 has_readline = check_symbol(
1067 flags=["-lreadline"],
1068 when="--enable-readline",
1069 onerror=lambda: die("No system readline library found"),
1072 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
1075 @depends("--enable-readline", editline, when=editline)
1076 def bundled_editline(readline, editline):
1077 return editline and not readline
1080 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
1082 set_define("EDITLINE", True, when=editline)
1089 "--with-jitreport-granularity",
1091 choices=("0", "1", "2", "3"),
1092 help="Default granularity at which to report JIT code to external tools "
1093 "(0 - no info, 1 - code ranges for while functions only, "
1094 "2 - per-line information, 3 - per-op information)",
1098 "JS_DEFAULT_JITREPORT_GRANULARITY",
1099 depends_if("--with-jitreport-granularity")(lambda value: value[0]),
1103 # ECMAScript Internationalization API Support (uses ICU)
1104 # ======================================================
1105 system_lib_option("--with-system-icu", help="Use system ICU")
1107 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 72.1", when="--with-system-icu")
1110 @depends("--with-system-icu")
1111 def in_tree_icu(system_icu):
1112 return not system_icu
1115 # Set MOZ_ICU_CFLAGS to an explicit empty value when --with-system-icu is *not* used,
1116 # for layout/style/extra-bindgen-flags
1117 set_config("MOZ_ICU_CFLAGS", [], when=in_tree_icu)
1119 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
1120 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
1122 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
1125 @depends("--with-intl-api", js_standalone)
1126 def check_intl_api(enabled, js_standalone):
1127 if not enabled and not js_standalone:
1128 die("--without-intl-api is not supported")
1131 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
1132 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
1135 @depends(build_environment, when="--with-intl-api")
1136 @imports(_from="__builtin__", _import="open")
1137 @imports(_from="__builtin__", _import="ValueError")
1138 def icu_version(build_env):
1139 path = os.path.join(
1140 build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
1142 with open(path, encoding="utf-8") as fh:
1144 if line.startswith("#define"):
1145 define = line.split(None, 3)
1146 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
1148 return str(int(define[2]))
1151 die("Cannot determine ICU version number from uvernum.h header file")
1154 set_config("MOZ_ICU_VERSION", icu_version)
1156 # Source files that use ICU should have control over which parts of the ICU
1157 # namespace they want to use.
1158 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1160 # We build ICU as a static library.
1161 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1164 # Initial support for WebAssembly JS-API Type Reflections
1165 # =======================================================
1168 @depends(milestone.is_nightly)
1169 def default_wasm_type_reflections(is_nightly):
1174 "--enable-wasm-type-reflections",
1175 default=default_wasm_type_reflections,
1176 help="{Enable|Disable} type reflection in WASM JS-API",
1180 "ENABLE_WASM_TYPE_REFLECTIONS",
1181 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1184 "ENABLE_WASM_TYPE_REFLECTIONS",
1185 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1188 # Wasi configuration
1189 # ===================================================
1193 def is_wasi_target(os):
1197 set_define("_WASI_EMULATED_PROCESS_CLOCKS", True, when=is_wasi_target)
1198 set_define("_WASI_EMULATED_GETPID", True, when=is_wasi_target)
1200 # Enable change-array-by-copy
1201 # ===================================================
1204 @depends(milestone.is_nightly)
1205 def use_change_array_by_copy(is_nightly):
1210 "--enable-change-array-by-copy",
1211 default=use_change_array_by_copy,
1212 help="{Enable|Disable} change-array-by-copy method pref/command-line option (disabled by default in Release-or-Beta)",
1216 @depends("--enable-change-array-by-copy")
1217 def enable_change_array_by_copy(value):
1222 set_config("ENABLE_CHANGE_ARRAY_BY_COPY", enable_change_array_by_copy)
1223 set_define("ENABLE_CHANGE_ARRAY_BY_COPY", enable_change_array_by_copy)
1225 # Enable New Set methods
1226 # ===================================================
1227 def use_new_set_methods():
1232 "--enable-new-set-methods",
1233 default=use_new_set_methods(),
1234 help="{Enable|Disable} New Set methods pref/command-line option (disabled by default)",
1238 @depends("--enable-new-set-methods")
1239 def enable_new_set_methods(value):
1244 set_config("ENABLE_NEW_SET_METHODS", enable_new_set_methods)
1245 set_define("ENABLE_NEW_SET_METHODS", enable_new_set_methods)
1248 @depends(milestone.version)
1249 def js_version(version):
1250 return Version(version)
1253 set_config("MOZJS_MAJOR_VERSION", depends(js_version.major)(lambda m: str(m)))
1254 set_define("MOZJS_MAJOR_VERSION", js_version.major)
1255 set_config("MOZJS_MINOR_VERSION", depends(js_version.minor)(lambda m: str(m)))
1256 set_define("MOZJS_MINOR_VERSION", js_version.minor)
1257 set_config("MOZJS_PATCH_VERSION", depends(js_version.patch)(lambda p: str(p)))
1260 depends(js_version)(
1261 lambda x: x.version[-2] if str(x.version[-2]) in "ab" else None
1266 # Some platforms have HeapReg, some don't
1267 # =====================================================
1269 # The ARM simulator runs on x86 and might be excluded by the first test,
1270 # so we special-case it.
1273 @depends("--enable-simulator", target)
1274 def wasm_has_heapreg(simulator, target):
1275 if target.cpu != "x86":
1278 if simulator and simulator[0] == "arm":
1282 set_define("WASM_HAS_HEAPREG", wasm_has_heapreg)
1284 # Check for tm_zone, tm_gmtoff in struct tm
1285 # ===================================================
1286 with only_when(compile_environment):
1288 "HAVE_TM_ZONE_TM_GMTOFF",
1289 c_compiler.try_compile(
1290 includes=["time.h"],
1291 body="struct tm tm; tm.tm_zone = 0; tm.tm_gmtoff = 1;",
1292 check_msg="for tm_zone and tm_gmtoff in struct tm",
1297 # Checks for library functions
1298 # ==============================================================
1299 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1300 set_define("HAVE_GETPAGESIZE", check_symbol("getpagesize"))
1301 set_define("HAVE_GMTIME_R", check_symbol("gmtime_r"))
1302 set_define("HAVE_LOCALTIME_R", check_symbol("localtime_r"))
1303 set_define("HAVE_GETTID", check_symbol("gettid"))
1304 set_define("HAVE_SETPRIORITY", check_symbol("setpriority"))
1305 set_define("HAVE_SYSCALL", check_symbol("syscall"))
1306 set_define("HAVE_GETC_UNLOCKED", check_symbol("getc_unlocked"))
1307 set_define("HAVE_PTHREAD_GETNAME_NP", check_symbol("pthread_getname_np"))
1308 set_define("HAVE_PTHREAD_GET_NAME_NP", check_symbol("pthread_get_name_np"))
1309 set_define("HAVE_STRERROR", check_symbol("strerror"))
1311 @depends(check_symbol("__cxa_demangle", language="C++"), moz_debug, dmd)
1312 def demangle_symbols(cxa_demangle, moz_debug, dmd):
1313 # Demangle only for debug or DMD builds
1314 if cxa_demangle and (moz_debug or dmd):
1317 set_define("MOZ_DEMANGLE_SYMBOLS", demangle_symbols)
1320 "HAVE__UNWIND_BACKTRACE",
1321 check_symbol("_Unwind_Backtrace", when=check_header("unwind.h")),
1324 with only_when(compile_environment):
1325 set_define("HAVE__GETC_NOLOCK", check_symbol("_getc_nolock"))
1326 set_define("HAVE_LOCALECONV", check_symbol("localeconv"))