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/.
7 # /!\ Use js_option() instead of option() in this file. /!\
8 # =========================================================
10 @depends(build_project)
11 def building_js(build_project):
12 return build_project == 'js'
14 # Exception to the rule above: JS_STANDALONE is a special option that doesn't
15 # want the js_option treatment. When we're done merging js/src/configure and
16 # top-level configure, it can go away, although the JS_STANDALONE config
17 # will still need to be set depending on building_js above.
18 option(env='JS_STANDALONE', default=building_js,
19 help='Reserved for internal use')
21 # SmooshMonkey (new frontend)
22 # ==================================================
24 # Define here in order to use the option from bindgen.configure.
25 js_option('--enable-smoosh', default=False,
26 help='Enable SmooshMonkey (new JS engine frontend)')
28 @depends('--enable-smoosh')
29 def enable_smoosh(value):
33 set_config('JS_ENABLE_SMOOSH', enable_smoosh)
34 set_define('JS_ENABLE_SMOOSH', enable_smoosh)
36 include('../build/moz.configure/rust.configure',
37 when='--enable-compile-environment')
38 include('../build/moz.configure/bindgen.configure',
39 when='--enable-compile-environment')
41 @depends('JS_STANDALONE')
42 def js_standalone(value):
45 set_config('JS_STANDALONE', js_standalone)
46 set_define('JS_STANDALONE', js_standalone)
47 add_old_configure_assignment('JS_STANDALONE', js_standalone)
48 js_option('--disable-js-shell', default=building_js,
49 help='{Build|Do not build} the JS shell')
51 @depends('--disable-js-shell')
52 def js_disable_shell(value):
56 set_config('JS_DISABLE_SHELL', js_disable_shell)
58 set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))
60 set_define('JS_PUNBOX64', depends(target)(lambda t: t.bitness == 64 or None))
61 set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None))
64 # SpiderMonkey as a shared library, and how its symbols are exported
65 # ==================================================================
66 js_option('--disable-shared-js', when=js_standalone,
67 help='{Create|Do not create} a shared library')
69 js_option('--disable-export-js', when=js_standalone,
70 help='{Mark|Do not mark} JS symbols as DLL exported/visible')
72 @depends('--disable-shared-js', '--disable-export-js', when=js_standalone)
73 def shared_js(shared_js, export_js):
76 die('Must export JS symbols when building a shared library.')
79 set_config('JS_SHARED_LIBRARY', shared_js)
80 add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
82 @depends(shared_js, '--disable-export-js', when=js_standalone)
83 def exportable_js_api(shared_js, export_js):
84 if not shared_js and export_js:
87 set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
89 @depends(shared_js, exportable_js_api)
90 def static_js_api(shared_js, export_js):
91 if not shared_js and not export_js:
94 set_define('STATIC_JS_API', static_js_api)
101 set_define('MOZ_STATIC_JS', static_js)
104 js_option(env='NO_RUST_PANIC_HOOK', when=js_standalone,
105 help='Disable rust panic hook')
107 set_define('NO_RUST_PANIC_HOOK', True, when='NO_RUST_PANIC_HOOK')
111 # =======================================================
113 def jit_default(target):
114 if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
118 js_option('--enable-jit',
120 help='{Enable|Disable} use of the JITs')
122 @deprecated_option('--enable-ion')
123 def report_deprecated(value):
125 die('--enable-ion is deprecated, use --enable-jit instead')
127 die('--disable-ion is deprecated, use --disable-jit instead')
129 # JIT code simulator for cross compiles
130 # =======================================================
131 js_option('--enable-simulator', choices=('arm', 'arm64', 'mips32', 'mips64'),
133 help='Enable a JIT code simulator for the specified architecture')
135 @depends('--enable-jit', '--enable-simulator', target)
136 def simulator(jit_enabled, simulator_enabled, target):
137 if not jit_enabled or not simulator_enabled:
140 sim_cpu = simulator_enabled[0]
142 if sim_cpu in ('arm', 'mips32'):
143 if target.cpu != 'x86':
144 die('The %s simulator only works on x86.' % sim_cpu)
146 if sim_cpu in ('arm64', 'mips64'):
147 if target.cpu != 'x86_64':
148 die('The %s simulator only works on x86-64.' % sim_cpu)
150 return namespace(**{sim_cpu: True})
152 set_config('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
153 set_config('JS_SIMULATOR_ARM', simulator.arm)
154 set_config('JS_SIMULATOR_ARM64', simulator.arm64)
155 set_config('JS_SIMULATOR_MIPS32', simulator.mips32)
156 set_config('JS_SIMULATOR_MIPS64', simulator.mips64)
157 set_define('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
158 set_define('JS_SIMULATOR_ARM', simulator.arm)
159 set_define('JS_SIMULATOR_ARM64', simulator.arm64)
160 set_define('JS_SIMULATOR_MIPS32', simulator.mips32)
161 set_define('JS_SIMULATOR_MIPS64', simulator.mips64)
163 @depends('--enable-jit', simulator, target)
164 def jit_codegen(jit_enabled, simulator, target):
166 return namespace(none=True)
171 if target.cpu == 'aarch64':
172 return namespace(arm64=True)
173 elif target.cpu == 'x86_64':
174 return namespace(x64=True)
176 return namespace(**{str(target.cpu): True})
178 set_config('JS_CODEGEN_NONE', jit_codegen.none)
179 set_config('JS_CODEGEN_ARM', jit_codegen.arm)
180 set_config('JS_CODEGEN_ARM64', jit_codegen.arm64)
181 set_config('JS_CODEGEN_MIPS32', jit_codegen.mips32)
182 set_config('JS_CODEGEN_MIPS64', jit_codegen.mips64)
183 set_config('JS_CODEGEN_X86', jit_codegen.x86)
184 set_config('JS_CODEGEN_X64', jit_codegen.x64)
185 set_define('JS_CODEGEN_NONE', jit_codegen.none)
186 set_define('JS_CODEGEN_ARM', jit_codegen.arm)
187 set_define('JS_CODEGEN_ARM64', jit_codegen.arm64)
188 set_define('JS_CODEGEN_MIPS32', jit_codegen.mips32)
189 set_define('JS_CODEGEN_MIPS64', jit_codegen.mips64)
190 set_define('JS_CODEGEN_X86', jit_codegen.x86)
191 set_define('JS_CODEGEN_X64', jit_codegen.x64)
194 # =======================================================
195 js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
196 help='Enable instruments remote profiling')
198 @depends('--enable-instruments', target)
199 def instruments(value, target):
200 if value and target.os != 'OSX':
201 die('--enable-instruments cannot be used when targeting %s',
206 set_config('MOZ_INSTRUMENTS', instruments)
207 set_define('MOZ_INSTRUMENTS', instruments)
208 add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
209 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
211 js_option('--enable-callgrind', env='MOZ_CALLGRIND',
212 help='Enable callgrind profiling')
214 @depends('--enable-callgrind')
215 def callgrind(value):
219 set_define('MOZ_CALLGRIND', callgrind)
220 imply_option('--enable-profiling', callgrind)
223 def enable_profiling(milestone):
224 return milestone.is_nightly
226 js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling,
227 help='{Set|Do not set} compile flags necessary for using sampling '
228 'profilers (e.g. shark, perf)')
230 @depends('--enable-profiling')
231 def profiling(value):
235 add_old_configure_assignment('MOZ_PROFILING', profiling)
237 with only_when('--enable-compile-environment'):
238 imply_option('--enable-frame-pointers', True, when=profiling)
241 @depends(profiling, target)
242 def imply_vtune(value, target):
243 ok_cpu = target.cpu in ['x86', 'x86_64']
244 ok_kernel = target.kernel == 'WINNT' or \
245 (target.kernel == 'Linux' and target.os == 'GNU')
247 if value and ok_cpu and ok_kernel:
250 set_config('MOZ_PROFILING', profiling)
251 set_define('MOZ_PROFILING', profiling)
252 imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
255 js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')
257 @depends('--enable-vtune')
262 set_config('MOZ_VTUNE', vtune)
263 set_define('MOZ_VTUNE', vtune)
266 js_option('--enable-gc-trace', env='JS_GC_TRACE',
267 help='Enable tracing of allocation and finalization')
269 @depends('--enable-gc-trace')
274 set_define('JS_GC_TRACE', gc_trace)
277 js_option('--enable-gczeal',
278 default=depends(when=moz_debug)(lambda: True),
279 help='{Enable|Disable} zealous GCing')
281 set_define('JS_GC_ZEAL',
282 depends_if('--enable-gczeal')(lambda _: True))
285 # Use a smaller chunk size for GC chunks
286 # ========================================================
287 # Use large (1MB) chunks by default. This option can be used to give
288 # smaller (currently 256K) chunks.
289 js_option('--enable-small-chunk-size',
290 help='Allocate memory for JS GC things in smaller chunks')
292 set_define('JS_GC_SMALL_CHUNK_SIZE',
293 depends(when='--enable-small-chunk-size')(lambda: True))
297 # =======================================================
299 def default_trace_logging(milestone):
300 return milestone.is_nightly
303 js_option('--enable-trace-logging',
304 default=default_trace_logging,
305 help='{Enable|Disable} trace logging')
307 set_config('ENABLE_TRACE_LOGGING',
308 depends_if('--enable-trace-logging')(lambda x: True))
309 set_define('JS_TRACE_LOGGING',
310 depends_if('--enable-trace-logging')(lambda x: True))
313 # Enable breakpoint for artificial OOMs
314 # =======================================================
315 js_option('--enable-oom-breakpoint',
316 help='Enable a breakpoint function for artificial OOMs')
318 set_define('JS_OOM_BREAKPOINT',
319 depends_if('--enable-oom-breakpoint')(lambda _: True))
322 js_option('--enable-perf', env='JS_ION_PERF',
323 help='Enable Linux perf integration')
325 @depends('--enable-perf')
330 set_define('JS_ION_PERF', ion_perf)
333 js_option('--enable-jitspew',
334 default=depends(when=moz_debug)(lambda: True),
335 help='{Enable|Disable} the Jit spew and IONFLAGS environment '
338 set_define('JS_JITSPEW',
339 depends_if('--enable-jitspew')(lambda _: True))
340 set_config('JS_JITSPEW',
341 depends_if('--enable-jitspew')(lambda _: True))
343 # Also enable the structured spewer
344 set_define('JS_STRUCTURED_SPEW',
345 depends_if('--enable-jitspew')(lambda _: True))
346 set_config('JS_STRUCTURED_SPEW',
347 depends_if('--enable-jitspew')(lambda _: True))
349 @depends('--enable-jit', '--enable-jitspew', simulator, target, moz_debug)
350 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
354 if simulator and (debug or spew):
355 if getattr(simulator, 'arm', None):
358 if target.cpu == 'arm' and (debug or spew):
361 set_config('JS_DISASM_ARM', jit_disasm_arm)
362 set_define('JS_DISASM_ARM', jit_disasm_arm)
364 @depends('--enable-jit', '--enable-jitspew', simulator, target, moz_debug)
365 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
369 if simulator and (debug or spew):
370 if getattr(simulator, 'arm64', None):
373 if target.cpu == 'aarch64' and (debug or spew):
376 set_config('JS_DISASM_ARM64', jit_disasm_arm64)
377 set_define('JS_DISASM_ARM64', jit_disasm_arm64)
379 # When enabled, masm will generate assumeUnreachable calls that act as
380 # assertions in the generated code. This option is worth disabling when you
381 # have to track mutated values through the generated code, to avoid constantly
382 # dumping registers on and off the stack.
383 js_option('--enable-masm-verbose',
384 default=depends(when=moz_debug)(lambda: True),
385 help='{Enable|Disable} MacroAssembler verbosity of generated code.')
386 set_define('JS_MASM_VERBOSE',
387 depends_if('--enable-masm-verbose')(lambda _: True))
388 set_config('JS_MASM_VERBOSE',
389 depends_if('--enable-masm-verbose')(lambda _: True))
392 js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
393 help='Enable changes that make the shell more deterministic')
395 @depends('--enable-more-deterministic')
396 def more_deterministic(value):
400 set_define('JS_MORE_DETERMINISTIC', more_deterministic)
404 # =======================================================
405 @depends(building_js)
406 def ctypes_default(building_js):
407 return not building_js
409 js_option('--enable-ctypes',
410 default=ctypes_default,
411 help='{Enable|Disable} js-ctypes')
413 build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
415 set_config('BUILD_CTYPES', build_ctypes)
416 set_define('BUILD_CTYPES', build_ctypes)
418 @depends(build_ctypes, building_js)
419 def js_has_ctypes(ctypes, js):
423 set_config('JS_HAS_CTYPES', js_has_ctypes)
424 set_define('JS_HAS_CTYPES', js_has_ctypes)
426 @depends('--enable-ctypes', '--enable-compile-environment')
427 def ctypes_and_compile_environment(ctypes, compile_environment):
428 return ctypes and compile_environment
430 include('ffi.configure', when=ctypes_and_compile_environment)
433 # Enable pipeline operator
434 # ===================================================
435 js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
437 @depends('--enable-pipeline-operator')
438 def enable_pipeline_operator(value):
442 set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
443 set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
447 # Experimental support for BinAST
448 # ==============================================================
450 @depends(milestone.is_nightly)
451 def default_binast(is_nightly):
454 js_option('--enable-binast',
455 default=default_binast,
456 help="{Enable|Disable} BinAST support")
458 set_config('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
459 set_define('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
462 # SIMD acceleration for encoding_rs
463 # ==============================================================
465 js_option('--enable-rust-simd', env='MOZ_RUST_SIMD',
466 help='Enable explicit SIMD in Rust code.')
468 @depends('--enable-rust-simd', target)
469 def rust_simd(value, target):
470 # As of 2019-09-17, the simd-accel feature of encoding_rs has not
471 # been properly set up outside aarch64, armv7, x86 and x86_64.
472 if target.cpu in ('aarch64', 'arm', 'x86', 'x86_64') and value:
475 set_config('MOZ_RUST_SIMD', rust_simd)
476 set_define('MOZ_RUST_SIMD', rust_simd)
479 # Experimental support for wasm code generation with Cranelift
481 # Note, you may have to disable features not supported by Cranelift
482 # (multi-value, threads) to make Cranelift actually available
483 # ==============================================================
485 js_option('--enable-cranelift',
486 default=milestone.is_nightly,
487 help='{Enable|Disable} Cranelift code generator for wasm')
489 set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
490 set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
493 # Support for debugging code generated by wasm backends
494 # =====================================================
496 js_option('--enable-wasm-codegen-debug',
497 default=depends(when=moz_debug)(lambda: True),
498 help='{Enable|Disable} debugging for wasm codegen')
500 set_config('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
501 set_define('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
504 # Support for typed objects.
505 # =====================================================
507 @depends(milestone.is_nightly)
508 def default_typed_objects(is_nightly):
511 js_option('--enable-typed-objects',
512 default=default_typed_objects,
513 help='{Enable|Disable} typed objects')
515 set_config('JS_HAS_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
516 set_define('JS_HAS_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
519 # Support for WebAssembly bulk memory operations.
520 # =====================================================
522 @depends(milestone.is_nightly)
523 def default_wasm_bulk_memory(is_nightly):
526 js_option('--enable-wasm-bulk-memory',
527 default=default_wasm_bulk_memory,
528 help='{Enable|Disable} WebAssembly bulk memory operators')
530 set_config('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
531 set_define('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
534 # Support for WebAssembly reference types.
535 # =====================================================
537 @depends(milestone.is_nightly)
538 def default_wasm_reftypes(is_nightly):
541 js_option('--enable-wasm-reftypes',
542 default=default_wasm_reftypes,
543 help='{Enable|Disable} WebAssembly reference types')
545 set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
546 set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
549 # Support for WebAssembly I64/BigInt conversion
550 # ===========================================================================
552 @depends(milestone.is_nightly)
553 def default_wasm_bigint(is_nightly):
556 js_option('--enable-wasm-bigint',
557 default=default_wasm_bigint,
558 help='{Enable|Disable} WebAssembly I64/BigInt conversion')
560 set_config('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
561 set_define('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
564 # Support for WebAssembly GC.
565 # ===========================
567 @depends(milestone.is_nightly, '--enable-wasm-reftypes')
568 def default_wasm_gc(is_nightly, reftypes):
569 if reftypes and is_nightly:
572 js_option('--enable-wasm-gc',
573 default=default_wasm_gc,
574 help='{Enable|Disable} WebAssembly GC')
576 set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
577 set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
580 # Support for WebAssembly private ref types.
581 # Prevent (ref T) types from being exposed to JS content so that wasm need do
582 # no typechecking at the JS/wasm boundary
583 # ===========================================================================
585 @depends(milestone.is_nightly, '--enable-wasm-gc')
586 def default_wasm_private_reftypes(is_nightly, gc):
587 if gc and is_nightly:
590 js_option('--enable-wasm-private-reftypes',
591 default=default_wasm_private_reftypes,
592 help='{Enable|Disable} WebAssembly private reference types')
594 set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
595 set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
598 # Support for the WebAssembly multi-value proposal.
599 # Do not remove until Cranelift supports multi-value.
600 # =====================================================
602 @depends(milestone.is_nightly)
603 def default_wasm_multi_value(is_nightly):
606 js_option('--enable-wasm-multi-value',
607 default=default_wasm_multi_value,
608 help='{Enable|Disable} support for the experimental WebAssembly '
609 'multi-value proposal')
611 set_config('ENABLE_WASM_MULTI_VALUE', depends_if('--enable-wasm-multi-value')(lambda x: True))
612 set_define('ENABLE_WASM_MULTI_VALUE', depends_if('--enable-wasm-multi-value')(lambda x: True))
615 # Support for WebAssembly shared memory and atomics.
617 # This affects the JS shell only and here to allow the use of
618 # Cranelift in the shell. Once Cranelift supports shared memory
619 # and atomics it can go away.
620 # =====================================================
622 js_option('--disable-shared-memory', help='Disable JS/WebAssembly shared memory and atomics')
624 @depends('--disable-shared-memory')
625 def enable_shared_memory(value):
629 set_config('ENABLE_SHARED_MEMORY', enable_shared_memory)
630 set_define('ENABLE_SHARED_MEMORY', enable_shared_memory)
633 # Initial support for new regexp engine
634 # ==================================================
636 js_option('--enable-new-regexp', default=False, help='Enable new regexp engine')
638 @depends('--enable-new-regexp')
639 def enable_new_regexp(value):
643 set_config('ENABLE_NEW_REGEXP', enable_new_regexp)
644 set_define('ENABLE_NEW_REGEXP', enable_new_regexp)