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):
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):
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):
63 die('Must export JS symbols when building a shared library.')
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:
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:
81 set_define('STATIC_JS_API', static_js_api)
88 set_define('MOZ_STATIC_JS', static_js)
92 # =======================================================
94 def ion_default(target):
95 if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
99 js_option('--enable-ion',
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'),
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:
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):
142 return namespace(none=True)
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)
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',
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):
195 set_define('MOZ_CALLGRIND', callgrind)
196 imply_option('--enable-profiling', callgrind)
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):
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:
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')
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')
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))
273 # =======================================================
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')
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 '
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):
330 if simulator and (debug or spew):
331 if getattr(simulator, 'arm', None):
334 if target.cpu == 'arm' and (debug or spew):
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):
345 if simulator and (debug or spew):
346 if getattr(simulator, 'arm64', None):
349 if target.cpu == 'aarch64' and (debug or spew):
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):
376 set_define('JS_MORE_DETERMINISTIC', more_deterministic)
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):
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):
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):
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 # Experimental support for wasm code generation with Cranelift
439 # ==============================================================
441 js_option('--enable-cranelift',
442 default=milestone.is_nightly & js_standalone,
443 help='{Enable|Disable} Cranelift code generator for wasm')
445 set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
446 set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
449 # Support for debugging code generated by wasm backends
450 # =====================================================
452 js_option('--enable-wasm-codegen-debug',
453 default=depends(when=moz_debug)(lambda: True),
454 help='{Enable|Disable} debugging for wasm codegen')
456 set_config('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
457 set_define('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
460 # Support for typed objects.
461 # =====================================================
463 @depends(milestone.is_nightly)
464 def default_typed_objects(is_nightly):
467 js_option('--enable-typed-objects',
468 default=default_typed_objects,
469 help='{Enable|Disable} typed objects')
471 set_config('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
472 set_define('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
475 # Support for WebAssembly bulk memory operations.
476 # =====================================================
478 @depends(milestone.is_nightly)
479 def default_wasm_bulk_memory(is_nightly):
482 js_option('--enable-wasm-bulk-memory',
483 default=default_wasm_bulk_memory,
484 help='{Enable|Disable} WebAssembly bulk memory operators')
486 set_config('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
487 set_define('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
490 # Support for WebAssembly reference types.
491 # =====================================================
493 @depends(milestone.is_nightly)
494 def default_wasm_reftypes(is_nightly):
497 js_option('--enable-wasm-reftypes',
498 default=default_wasm_reftypes,
499 help='{Enable|Disable} WebAssembly reference types')
501 set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
502 set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
505 # Support for WebAssembly GC.
506 # ===========================
508 @depends(milestone.is_nightly, '--enable-wasm-reftypes')
509 def default_wasm_gc(is_nightly, reftypes):
510 if reftypes and is_nightly:
513 js_option('--enable-wasm-gc',
514 default=default_wasm_gc,
515 help='{Enable|Disable} WebAssembly GC')
517 set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
518 set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
521 # Support for WebAssembly private ref types.
522 # Prevent (ref T) types from being exposed to JS content so that wasm need do
523 # no typechecking at the JS/wasm boundary
524 # ===========================================================================
526 @depends(milestone.is_nightly, '--enable-wasm-gc')
527 def default_wasm_private_reftypes(is_nightly, gc):
528 if gc and is_nightly:
531 js_option('--enable-wasm-private-reftypes',
532 default=default_wasm_private_reftypes,
533 help='{Enable|Disable} WebAssembly private reference types')
535 set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
536 set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))