Bug 1586801 - Use the contextual WalkerFront in _duplicateNode(). r=pbro
[gecko.git] / js / moz.configure
blobc33216ec973f5b31d794f3917769bd5ce83b4cae
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 include('../build/moz.configure/rust.configure',
22         when='--enable-compile-environment')
23 include('../build/moz.configure/bindgen.configure',
24         when='--enable-compile-environment')
25 include('../build/moz.configure/lto-pgo.configure',
26         when='--enable-compile-environment')
28 @depends('JS_STANDALONE')
29 def js_standalone(value):
30     if value:
31         return True
32 set_config('JS_STANDALONE', js_standalone)
33 set_define('JS_STANDALONE', js_standalone)
34 add_old_configure_assignment('JS_STANDALONE', js_standalone)
35 js_option('--disable-js-shell', default=building_js,
36           help='{Build|Do not build} the JS shell')
38 @depends('--disable-js-shell')
39 def js_disable_shell(value):
40     if not value:
41         return True
43 set_config('JS_DISABLE_SHELL', js_disable_shell)
45 set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))
47 set_define('JS_PUNBOX64', depends(target)(lambda t: t.bitness == 64 or None))
48 set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None))
51 # SpiderMonkey as a shared library, and how its symbols are exported
52 # ==================================================================
53 js_option('--disable-shared-js', when=js_standalone,
54           help='{Create|Do not create} a shared library')
56 js_option('--disable-export-js', when=js_standalone,
57           help='{Mark|Do not mark} JS symbols as DLL exported/visible')
59 @depends('--disable-shared-js', '--disable-export-js', when=js_standalone)
60 def shared_js(shared_js, export_js):
61     if shared_js:
62         if not export_js:
63             die('Must export JS symbols when building a shared library.')
64         return True
66 set_config('JS_SHARED_LIBRARY', shared_js)
67 add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
69 @depends(shared_js, '--disable-export-js', when=js_standalone)
70 def exportable_js_api(shared_js, export_js):
71     if not shared_js and export_js:
72         return True
74 set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
76 @depends(shared_js, exportable_js_api)
77 def static_js_api(shared_js, export_js):
78     if not shared_js and not export_js:
79         return True
81 set_define('STATIC_JS_API', static_js_api)
83 @depends(shared_js)
84 def static_js(value):
85     if not value:
86         return True
88 set_define('MOZ_STATIC_JS', static_js)
91 # JIT support
92 # =======================================================
93 @depends(target)
94 def ion_default(target):
95     if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
96         return True
97     return False
99 js_option('--enable-ion',
100           default=ion_default,
101           help='{Enable|Disable} use of the IonMonkey JIT')
103 set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True))
105 # JIT code simulator for cross compiles
106 # =======================================================
107 js_option('--enable-simulator', choices=('arm', 'arm64', 'mips32', 'mips64'),
108           nargs=1,
109           help='Enable a JIT code simulator for the specified architecture')
111 @depends('--enable-ion', '--enable-simulator', target)
112 def simulator(ion_enabled, simulator_enabled, target):
113     if not ion_enabled or not simulator_enabled:
114         return
116     sim_cpu = simulator_enabled[0]
118     if sim_cpu in ('arm', 'mips32'):
119         if target.cpu != 'x86':
120             die('The %s simulator only works on x86.' % sim_cpu)
122     if sim_cpu in ('arm64', 'mips64'):
123         if target.cpu != 'x86_64':
124             die('The %s simulator only works on x86-64.' % sim_cpu)
126     return namespace(**{sim_cpu: True})
128 set_config('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
129 set_config('JS_SIMULATOR_ARM', simulator.arm)
130 set_config('JS_SIMULATOR_ARM64', simulator.arm64)
131 set_config('JS_SIMULATOR_MIPS32', simulator.mips32)
132 set_config('JS_SIMULATOR_MIPS64', simulator.mips64)
133 set_define('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
134 set_define('JS_SIMULATOR_ARM', simulator.arm)
135 set_define('JS_SIMULATOR_ARM64', simulator.arm64)
136 set_define('JS_SIMULATOR_MIPS32', simulator.mips32)
137 set_define('JS_SIMULATOR_MIPS64', simulator.mips64)
139 @depends('--enable-ion', simulator, target)
140 def jit_codegen(ion_enabled, simulator, target):
141     if not ion_enabled:
142         return namespace(none=True)
144     if simulator:
145         return simulator
147     if target.cpu == 'aarch64':
148         return namespace(arm64=True)
149     elif target.cpu == 'x86_64':
150         return namespace(x64=True)
152     return namespace(**{str(target.cpu): True})
154 set_config('JS_CODEGEN_NONE', jit_codegen.none)
155 set_config('JS_CODEGEN_ARM', jit_codegen.arm)
156 set_config('JS_CODEGEN_ARM64', jit_codegen.arm64)
157 set_config('JS_CODEGEN_MIPS32', jit_codegen.mips32)
158 set_config('JS_CODEGEN_MIPS64', jit_codegen.mips64)
159 set_config('JS_CODEGEN_X86', jit_codegen.x86)
160 set_config('JS_CODEGEN_X64', jit_codegen.x64)
161 set_define('JS_CODEGEN_NONE', jit_codegen.none)
162 set_define('JS_CODEGEN_ARM', jit_codegen.arm)
163 set_define('JS_CODEGEN_ARM64', jit_codegen.arm64)
164 set_define('JS_CODEGEN_MIPS32', jit_codegen.mips32)
165 set_define('JS_CODEGEN_MIPS64', jit_codegen.mips64)
166 set_define('JS_CODEGEN_X86', jit_codegen.x86)
167 set_define('JS_CODEGEN_X64', jit_codegen.x64)
169 # Profiling
170 # =======================================================
171 js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
172           help='Enable instruments remote profiling')
174 @depends('--enable-instruments', target)
175 def instruments(value, target):
176     if value and target.os != 'OSX':
177         die('--enable-instruments cannot be used when targeting %s',
178             target.os)
179     if value:
180         return True
182 set_config('MOZ_INSTRUMENTS', instruments)
183 set_define('MOZ_INSTRUMENTS', instruments)
184 add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
185 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
187 js_option('--enable-callgrind', env='MOZ_CALLGRIND',
188           help='Enable callgrind profiling')
190 @depends('--enable-callgrind')
191 def callgrind(value):
192     if value:
193         return True
195 set_define('MOZ_CALLGRIND', callgrind)
196 imply_option('--enable-profiling', callgrind)
198 @depends(milestone)
199 def enable_profiling(milestone):
200     return milestone.is_nightly
202 js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling,
203           help='{Set|Do not set} compile flags necessary for using sampling '
204                 'profilers (e.g. shark, perf)')
206 @depends('--enable-profiling')
207 def profiling(value):
208     if value:
209         return True
211 add_old_configure_assignment('MOZ_PROFILING', profiling)
213 with only_when('--enable-compile-environment'):
214     imply_option('--enable-frame-pointers', True, when=profiling)
217 @depends(profiling, target)
218 def imply_vtune(value, target):
219     ok_cpu    = target.cpu in ['x86', 'x86_64']
220     ok_kernel = target.kernel == 'WINNT' or \
221                 (target.kernel == 'Linux' and target.os == 'GNU')
223     if value and ok_cpu and ok_kernel:
224         return True
226 set_config('MOZ_PROFILING', profiling)
227 set_define('MOZ_PROFILING', profiling)
228 imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
231 js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')
233 @depends('--enable-vtune')
234 def vtune(value):
235     if value:
236         return True
238 set_config('MOZ_VTUNE', vtune)
239 set_define('MOZ_VTUNE', vtune)
242 js_option('--enable-gc-trace', env='JS_GC_TRACE',
243           help='Enable tracing of allocation and finalization')
245 @depends('--enable-gc-trace')
246 def gc_trace(value):
247     if value:
248         return True
250 set_define('JS_GC_TRACE', gc_trace)
253 js_option('--enable-gczeal',
254           default=depends(when=moz_debug)(lambda: True),
255           help='{Enable|Disable} zealous GCing')
257 set_define('JS_GC_ZEAL',
258            depends_if('--enable-gczeal')(lambda _: True))
261 # Use a smaller chunk size for GC chunks
262 # ========================================================
263 # Use large (1MB) chunks by default.  This option can be used to give
264 # smaller (currently 256K) chunks.
265 js_option('--enable-small-chunk-size',
266           help='Allocate memory for JS GC things in smaller chunks')
268 set_define('JS_GC_SMALL_CHUNK_SIZE',
269            depends(when='--enable-small-chunk-size')(lambda: True))
272 # Trace logging.
273 # =======================================================
274 @depends(milestone)
275 def default_trace_logging(milestone):
276     return milestone.is_nightly
279 js_option('--enable-trace-logging',
280           default=default_trace_logging,
281           help='{Enable|Disable} trace logging')
283 set_config('ENABLE_TRACE_LOGGING',
284            depends_if('--enable-trace-logging')(lambda x: True))
285 set_define('JS_TRACE_LOGGING',
286            depends_if('--enable-trace-logging')(lambda x: True))
289 # Enable breakpoint for artificial OOMs
290 # =======================================================
291 js_option('--enable-oom-breakpoint',
292           help='Enable a breakpoint function for artificial OOMs')
294 set_define('JS_OOM_BREAKPOINT',
295            depends_if('--enable-oom-breakpoint')(lambda _: True))
298 js_option('--enable-perf', env='JS_ION_PERF',
299           help='Enable Linux perf integration')
301 @depends('--enable-perf')
302 def ion_perf(value):
303     if value:
304         return True
306 set_define('JS_ION_PERF', ion_perf)
309 js_option('--enable-jitspew',
310           default=depends(when=moz_debug)(lambda: True),
311           help='{Enable|Disable} the Jit spew and IONFLAGS environment '
312                'variable')
314 set_define('JS_JITSPEW',
315            depends_if('--enable-jitspew')(lambda _: True))
316 set_config('JS_JITSPEW',
317            depends_if('--enable-jitspew')(lambda _: True))
319 # Also enable the structured spewer
320 set_define('JS_STRUCTURED_SPEW',
321            depends_if('--enable-jitspew')(lambda _: True))
322 set_config('JS_STRUCTURED_SPEW',
323            depends_if('--enable-jitspew')(lambda _: True))
325 @depends('--enable-ion', '--enable-jitspew', simulator, target, moz_debug)
326 def jit_disasm_arm(ion_enabled, spew, simulator, target, debug):
327     if not ion_enabled:
328         return
330     if simulator and (debug or spew):
331         if getattr(simulator, 'arm', None):
332             return True
334     if target.cpu == 'arm' and (debug or spew):
335         return True
337 set_config('JS_DISASM_ARM', jit_disasm_arm)
338 set_define('JS_DISASM_ARM', jit_disasm_arm)
340 @depends('--enable-ion', '--enable-jitspew', simulator, target, moz_debug)
341 def jit_disasm_arm64(ion_enabled, spew, simulator, target, debug):
342     if not ion_enabled:
343         return
345     if simulator and (debug or spew):
346         if getattr(simulator, 'arm64', None):
347             return True
349     if target.cpu == 'aarch64' and (debug or spew):
350         return True
352 set_config('JS_DISASM_ARM64', jit_disasm_arm64)
353 set_define('JS_DISASM_ARM64', jit_disasm_arm64)
355 # When enabled, masm will generate assumeUnreachable calls that act as
356 # assertions in the generated code. This option is worth disabling when you
357 # have to track mutated values through the generated code, to avoid constantly
358 # dumping registers on and off the stack.
359 js_option('--enable-masm-verbose',
360           default=depends(when=moz_debug)(lambda: True),
361           help='{Enable|Disable} MacroAssembler verbosity of generated code.')
362 set_define('JS_MASM_VERBOSE',
363            depends_if('--enable-masm-verbose')(lambda _: True))
364 set_config('JS_MASM_VERBOSE',
365            depends_if('--enable-masm-verbose')(lambda _: True))
368 js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
369           help='Enable changes that make the shell more deterministic')
371 @depends('--enable-more-deterministic')
372 def more_deterministic(value):
373     if value:
374         return True
376 set_define('JS_MORE_DETERMINISTIC', more_deterministic)
379 # CTypes
380 # =======================================================
381 @depends(building_js)
382 def ctypes_default(building_js):
383     return not building_js
385 js_option('--enable-ctypes',
386           default=ctypes_default,
387           help='{Enable|Disable} js-ctypes')
389 build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
391 set_config('BUILD_CTYPES', build_ctypes)
392 set_define('BUILD_CTYPES', build_ctypes)
394 @depends(build_ctypes, building_js)
395 def js_has_ctypes(ctypes, js):
396     if ctypes and js:
397         return True
399 set_config('JS_HAS_CTYPES', js_has_ctypes)
400 set_define('JS_HAS_CTYPES', js_has_ctypes)
402 @depends('--enable-ctypes', '--enable-compile-environment')
403 def ctypes_and_compile_environment(ctypes, compile_environment):
404     return ctypes and compile_environment
406 include('ffi.configure', when=ctypes_and_compile_environment)
409 # Enable pipeline operator
410 # ===================================================
411 js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
413 @depends('--enable-pipeline-operator')
414 def enable_pipeline_operator(value):
415     if value:
416         return True
418 set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
419 set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
423 # Experimental support for BinAST
424 # ==============================================================
426 @depends(milestone.is_nightly)
427 def default_binast(is_nightly):
428     return is_nightly
430 js_option('--enable-binast',
431           default=default_binast,
432           help="{Enable|Disable} BinAST support")
434 set_config('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
435 set_define('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
438 # SIMD acceleration for encoding_rs
439 # ==============================================================
441 js_option('--enable-rust-simd', env='MOZ_RUST_SIMD',
442           help='Enable explicit SIMD in Rust code.')
444 @depends('--enable-rust-simd', target)
445 def rust_simd(value, target):
446     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
447     # been properly set up outside aarch64, armv7, x86 and x86_64.
448     if target.cpu in ('aarch64', 'arm', 'x86', 'x86_64') and value:
449         return True
451 set_config('MOZ_RUST_SIMD', rust_simd)
452 set_define('MOZ_RUST_SIMD', rust_simd)
455 # Experimental support for wasm code generation with Cranelift
456 # ==============================================================
458 js_option('--enable-cranelift',
459           default=milestone.is_nightly,
460           help='{Enable|Disable} Cranelift code generator for wasm')
462 set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
463 set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
466 # Support for debugging code generated by wasm backends
467 # =====================================================
469 js_option('--enable-wasm-codegen-debug',
470           default=depends(when=moz_debug)(lambda: True),
471           help='{Enable|Disable} debugging for wasm codegen')
473 set_config('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
474 set_define('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
477 # Support for typed objects.
478 # =====================================================
480 @depends(milestone.is_nightly)
481 def default_typed_objects(is_nightly):
482     return is_nightly
484 js_option('--enable-typed-objects',
485           default=default_typed_objects,
486           help='{Enable|Disable} typed objects')
488 set_config('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
489 set_define('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
492 # Support for WebAssembly bulk memory operations.
493 # =====================================================
495 @depends(milestone.is_nightly)
496 def default_wasm_bulk_memory(is_nightly):
497     return is_nightly
499 js_option('--enable-wasm-bulk-memory',
500           default=default_wasm_bulk_memory,
501           help='{Enable|Disable} WebAssembly bulk memory operators')
503 set_config('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
504 set_define('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
507 # Support for WebAssembly reference types.
508 # =====================================================
510 @depends(milestone.is_nightly)
511 def default_wasm_reftypes(is_nightly):
512     return is_nightly
514 js_option('--enable-wasm-reftypes',
515           default=default_wasm_reftypes,
516           help='{Enable|Disable} WebAssembly reference types')
518 set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
519 set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
522 # Support for WebAssembly I64/BigInt conversion
523 # ===========================================================================
525 @depends(milestone.is_nightly)
526 def default_wasm_bigint(is_nightly):
527     return is_nightly
529 js_option('--enable-wasm-bigint',
530           default=default_wasm_bigint,
531           help='{Enable|Disable} WebAssembly I64/BigInt conversion')
533 set_config('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
534 set_define('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
537 # Support for WebAssembly GC.
538 # ===========================
540 @depends(milestone.is_nightly, '--enable-wasm-reftypes')
541 def default_wasm_gc(is_nightly, reftypes):
542     if reftypes and is_nightly:
543         return True
545 js_option('--enable-wasm-gc',
546           default=default_wasm_gc,
547           help='{Enable|Disable} WebAssembly GC')
549 set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
550 set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
553 # Support for WebAssembly private ref types.
554 # Prevent (ref T) types from being exposed to JS content so that wasm need do
555 # no typechecking at the JS/wasm boundary
556 # ===========================================================================
558 @depends(milestone.is_nightly, '--enable-wasm-gc')
559 def default_wasm_private_reftypes(is_nightly, gc):
560     if gc and is_nightly:
561         return True
563 js_option('--enable-wasm-private-reftypes',
564           default=default_wasm_private_reftypes,
565           help='{Enable|Disable} WebAssembly private reference types')
567 set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
568 set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
571 # Support for the WebAssembly multi-value proposal.
572 # =====================================================
574 @depends(milestone.is_nightly, building_js)
575 def default_wasm_multi_value(is_nightly, building_js):
576     return is_nightly and building_js
578 js_option('--enable-wasm-multi-value',
579           default=default_wasm_multi_value,
580           help='{Enable|Disable} support for the experimental WebAssembly '
581                'multi-value proposal')
583 set_config('ENABLE_WASM_MULTI_VALUE', depends_if('--enable-wasm-multi-value')(lambda x: True))
584 set_define('ENABLE_WASM_MULTI_VALUE', depends_if('--enable-wasm-multi-value')(lambda x: True))