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')
26 @depends('JS_STANDALONE')
27 def js_standalone(value):
30 set_config('JS_STANDALONE', js_standalone)
31 set_define('JS_STANDALONE', js_standalone)
32 add_old_configure_assignment('JS_STANDALONE', js_standalone)
33 js_option('--disable-js-shell', default=building_js,
34 help='{Build|Do not build} the JS shell')
36 @depends('--disable-js-shell')
37 def js_disable_shell(value):
41 set_config('JS_DISABLE_SHELL', js_disable_shell)
43 set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))
45 set_define('JS_PUNBOX64', depends(target)(lambda t: t.bitness == 64 or None))
46 set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None))
49 # SpiderMonkey as a shared library, and how its symbols are exported
50 # ==================================================================
51 js_option('--disable-shared-js', default=building_js,
52 help='{Create|Do not create} a shared library')
54 js_option('--disable-export-js', default=building_js,
55 help='{Mark|Do not mark} JS symbols as DLL exported/visible')
57 @depends('--disable-shared-js', '--disable-export-js')
58 def shared_js(shared_js, export_js):
61 die('Must export JS symbols when building a shared library.')
64 set_config('JS_SHARED_LIBRARY', shared_js)
65 add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
67 @depends('--disable-shared-js', '--disable-export-js')
68 def exportable_js_api(shared_js, export_js):
69 if not shared_js and export_js:
72 set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
74 @depends('--disable-shared-js', '--disable-export-js')
75 def static_js_api(shared_js, export_js):
76 if not shared_js and not export_js:
79 set_define('STATIC_JS_API', static_js_api)
81 @depends('--disable-shared-js')
86 set_define('MOZ_STATIC_JS', static_js)
88 @deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
89 def disable_shared_js(value):
90 # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
91 if value and not len(value):
92 suggestion = '--disable-shared-js'
94 suggestion = '--enable-shared-js'
96 die('Setting %s is deprecated, use %s instead.',
97 value.format('DISABLE_SHARED_JS'), suggestion)
99 @deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
100 def disable_export_js(value):
101 # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
102 if value and not len(value):
103 suggestion = '--disable-export-js'
105 suggestion = '--enable-export-js'
107 die('Setting %s is deprecated, use %s instead.',
108 value.format('DISABLE_EXPORT_JS'), suggestion)
111 # =======================================================
113 def ion_default(target):
114 if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
118 js_option('--enable-ion',
120 help='{Enable|Disable} use of the IonMonkey JIT')
122 set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True))
124 # JIT code simulator for cross compiles
125 # =======================================================
126 js_option('--enable-simulator', choices=('arm', 'arm64', 'mips32', 'mips64'),
128 help='Enable a JIT code simulator for the specified architecture')
130 @depends('--enable-ion', '--enable-simulator', target)
131 def simulator(ion_enabled, simulator_enabled, target):
132 if not ion_enabled or not simulator_enabled:
135 sim_cpu = simulator_enabled[0]
137 if sim_cpu in ('arm', 'mips32'):
138 if target.cpu != 'x86':
139 die('The %s simulator only works on x86.' % sim_cpu)
141 if sim_cpu in ('arm64', 'mips64'):
142 if target.cpu != 'x86_64':
143 die('The %s simulator only works on x86-64.' % sim_cpu)
145 return namespace(**{sim_cpu: True})
147 set_config('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
148 set_config('JS_SIMULATOR_ARM', simulator.arm)
149 set_config('JS_SIMULATOR_ARM64', simulator.arm64)
150 set_config('JS_SIMULATOR_MIPS32', simulator.mips32)
151 set_config('JS_SIMULATOR_MIPS64', simulator.mips64)
152 set_define('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
153 set_define('JS_SIMULATOR_ARM', simulator.arm)
154 set_define('JS_SIMULATOR_ARM64', simulator.arm64)
155 set_define('JS_SIMULATOR_MIPS32', simulator.mips32)
156 set_define('JS_SIMULATOR_MIPS64', simulator.mips64)
158 @depends('--enable-ion', simulator, target)
159 def jit_codegen(ion_enabled, simulator, target):
161 return namespace(none=True)
166 if target.cpu == 'aarch64':
167 return namespace(arm64=True)
168 elif target.cpu == 'x86_64':
169 return namespace(x64=True)
171 return namespace(**{str(target.cpu): True})
173 set_config('JS_CODEGEN_NONE', jit_codegen.none)
174 set_config('JS_CODEGEN_ARM', jit_codegen.arm)
175 set_config('JS_CODEGEN_ARM64', jit_codegen.arm64)
176 set_config('JS_CODEGEN_MIPS32', jit_codegen.mips32)
177 set_config('JS_CODEGEN_MIPS64', jit_codegen.mips64)
178 set_config('JS_CODEGEN_X86', jit_codegen.x86)
179 set_config('JS_CODEGEN_X64', jit_codegen.x64)
180 set_define('JS_CODEGEN_NONE', jit_codegen.none)
181 set_define('JS_CODEGEN_ARM', jit_codegen.arm)
182 set_define('JS_CODEGEN_ARM64', jit_codegen.arm64)
183 set_define('JS_CODEGEN_MIPS32', jit_codegen.mips32)
184 set_define('JS_CODEGEN_MIPS64', jit_codegen.mips64)
185 set_define('JS_CODEGEN_X86', jit_codegen.x86)
186 set_define('JS_CODEGEN_X64', jit_codegen.x64)
188 @depends('--enable-ion', simulator, target, moz_debug)
189 def jit_disasm_arm(ion_enabled, simulator, target, debug):
193 if simulator and debug:
194 if getattr(simulator, 'arm', None):
197 if target.cpu == 'arm' and debug:
200 set_config('JS_DISASM_ARM', jit_disasm_arm)
201 set_define('JS_DISASM_ARM', jit_disasm_arm)
203 @depends('--enable-ion', simulator, target, moz_debug)
204 def jit_disasm_arm64(ion_enabled, simulator, target, debug):
208 if simulator and debug:
209 if getattr(simulator, 'arm64', None):
212 if target.cpu == 'aarch64' and debug:
215 set_config('JS_DISASM_ARM64', jit_disasm_arm64)
216 set_define('JS_DISASM_ARM64', jit_disasm_arm64)
219 # =======================================================
220 js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
221 help='Enable instruments remote profiling')
223 @depends('--enable-instruments', target)
224 def instruments(value, target):
225 if value and target.os != 'OSX':
226 die('--enable-instruments cannot be used when targeting %s',
231 set_config('MOZ_INSTRUMENTS', instruments)
232 set_define('MOZ_INSTRUMENTS', instruments)
233 add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
234 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
236 js_option('--enable-callgrind', env='MOZ_CALLGRIND',
237 help='Enable callgrind profiling')
239 @depends('--enable-callgrind')
240 def callgrind(value):
244 set_define('MOZ_CALLGRIND', callgrind)
245 imply_option('--enable-profiling', callgrind)
248 def enable_profiling(milestone):
249 return milestone.is_nightly
251 js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling,
252 help='{Set|Do not set} compile flags necessary for using sampling '
253 'profilers (e.g. shark, perf)')
255 @depends('--enable-profiling')
256 def profiling(value):
260 add_old_configure_assignment('MOZ_PROFILING', profiling)
262 @depends(profiling, target)
263 def imply_vtune(value, target):
264 ok_cpu = target.cpu in ['x86', 'x86_64']
265 ok_kernel = target.kernel == 'WINNT' or \
266 (target.kernel == 'Linux' and target.os == 'GNU')
268 if value and ok_cpu and ok_kernel:
271 set_config('MOZ_PROFILING', profiling)
272 set_define('MOZ_PROFILING', profiling)
273 imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
276 js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')
278 @depends('--enable-vtune')
283 set_config('MOZ_VTUNE', vtune)
284 set_define('MOZ_VTUNE', vtune)
287 js_option('--enable-gc-trace', env='JS_GC_TRACE',
288 help='Enable tracing of allocation and finalization')
290 @depends('--enable-gc-trace')
295 set_define('JS_GC_TRACE', gc_trace)
298 js_option('--enable-gczeal',
299 default=depends(when=moz_debug)(lambda: True),
300 help='{Enable|Disable} zealous GCing')
302 set_define('JS_GC_ZEAL',
303 depends_if('--enable-gczeal')(lambda _: True))
306 # Use a smaller chunk size for GC chunks
307 # ========================================================
308 # Use large (1MB) chunks by default. This option can be used to give
309 # smaller (currently 256K) chunks.
310 js_option('--enable-small-chunk-size',
311 help='Allocate memory for JS GC things in smaller chunks')
313 set_define('JS_GC_SMALL_CHUNK_SIZE',
314 depends(when='--enable-small-chunk-size')(lambda: True))
318 # =======================================================
319 js_option('--enable-trace-logging',
320 default=depends(when=moz_debug)(lambda: True),
321 help='{Enable|Disable} trace logging')
323 set_config('ENABLE_TRACE_LOGGING',
324 depends_if('--enable-trace-logging')(lambda x: True))
325 set_define('JS_TRACE_LOGGING',
326 depends_if('--enable-trace-logging')(lambda x: True))
329 # Enable breakpoint for artificial OOMs
330 # =======================================================
331 js_option('--enable-oom-breakpoint',
332 help='Enable a breakpoint function for artificial OOMs')
334 set_define('JS_OOM_BREAKPOINT',
335 depends_if('--enable-oom-breakpoint')(lambda _: True))
338 js_option('--enable-perf', env='JS_ION_PERF',
339 help='Enable Linux perf integration')
341 @depends('--enable-perf')
346 set_define('JS_ION_PERF', ion_perf)
349 js_option('--enable-jitspew',
350 default=depends(when=moz_debug)(lambda: True),
351 help='{Enable|Disable} the Jit spew and IONFLAGS environment '
354 set_define('JS_JITSPEW',
355 depends_if('--enable-jitspew')(lambda _: True))
356 set_config('JS_JITSPEW',
357 depends_if('--enable-jitspew')(lambda _: True))
359 # Also enable the structured spewer
360 set_define('JS_STRUCTURED_SPEW',
361 depends_if('--enable-jitspew')(lambda _: True))
362 set_config('JS_STRUCTURED_SPEW',
363 depends_if('--enable-jitspew')(lambda _: True))
364 # When enabled, masm will generate assumeUnreachable calls that act as
365 # assertions in the generated code. This option is worth disabling when you
366 # have to track mutated values through the generated code, to avoid constantly
367 # dumping registers on and off the stack.
368 js_option('--enable-masm-verbose',
369 default=depends(when=moz_debug)(lambda: True),
370 help='{Enable|Disable} MacroAssembler verbosity of generated code.')
371 set_define('JS_MASM_VERBOSE',
372 depends_if('--enable-masm-verbose')(lambda _: True))
373 set_config('JS_MASM_VERBOSE',
374 depends_if('--enable-masm-verbose')(lambda _: True))
377 js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
378 help='Enable changes that make the shell more deterministic')
380 @depends('--enable-more-deterministic')
381 def more_deterministic(value):
385 set_define('JS_MORE_DETERMINISTIC', more_deterministic)
389 # =======================================================
390 @depends(building_js)
391 def ctypes_default(building_js):
392 return not building_js
394 js_option('--enable-ctypes',
395 default=ctypes_default,
396 help='{Enable|Disable} js-ctypes')
398 build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
400 set_config('BUILD_CTYPES', build_ctypes)
401 set_define('BUILD_CTYPES', build_ctypes)
403 @depends(build_ctypes, building_js)
404 def js_has_ctypes(ctypes, js):
408 set_config('JS_HAS_CTYPES', js_has_ctypes)
409 set_define('JS_HAS_CTYPES', js_has_ctypes)
411 @depends('--enable-ctypes', '--enable-compile-environment')
412 def ctypes_and_compile_environment(ctypes, compile_environment):
413 return ctypes and compile_environment
415 include('ffi.configure', when=ctypes_and_compile_environment)
418 # Support various fuzzing options
419 # ==============================================================
420 with only_when('--enable-compile-environment'):
421 js_option('--enable-fuzzing', help='Enable fuzzing support')
423 @depends('--enable-fuzzing')
424 def enable_fuzzing(value):
428 @depends(try_compile(body='__AFL_COMPILER;',
429 check_msg='for AFL compiler',
430 when='--enable-fuzzing'))
431 def enable_aflfuzzer(afl):
435 @depends(enable_fuzzing,
439 def enable_libfuzzer(fuzzing, afl, c_compiler, target):
440 if fuzzing and not afl and c_compiler.type == 'clang' and target.os != 'Android':
443 @depends(enable_fuzzing,
446 def enable_fuzzing_interfaces(fuzzing, afl, libfuzzer):
447 if fuzzing and (afl or libfuzzer):
450 set_config('FUZZING', enable_fuzzing)
451 set_define('FUZZING', enable_fuzzing)
453 set_config('LIBFUZZER', enable_libfuzzer)
454 set_define('LIBFUZZER', enable_libfuzzer)
455 add_old_configure_assignment('LIBFUZZER', enable_libfuzzer)
457 set_config('FUZZING_INTERFACES', enable_fuzzing_interfaces)
458 set_define('FUZZING_INTERFACES', enable_fuzzing_interfaces)
459 add_old_configure_assignment('FUZZING_INTERFACES', enable_fuzzing_interfaces)
461 # Enable pipeline operator
462 # ===================================================
463 js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
465 @depends('--enable-pipeline-operator')
466 def enable_pipeline_operator(value):
470 set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
471 set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
475 # Experimental support for BinAST
476 # ==============================================================
478 @depends(milestone.is_nightly)
479 def default_binast(is_nightly):
482 js_option('--enable-binast',
483 default=default_binast,
484 help="{Enable|Disable} BinAST support")
486 set_config('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
487 set_define('JS_BUILD_BINAST', depends_if('--enable-binast')(lambda x: True))
490 # Experimental support for wasm code generation with Cranelift
491 # ==============================================================
493 @depends(milestone.is_nightly)
494 def default_cranelift(is_nightly):
497 js_option('--enable-cranelift',
498 default=default_cranelift,
499 help='{Enable|Disable} Cranelift code generator for wasm')
501 set_config('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
502 set_define('ENABLE_WASM_CRANELIFT', depends_if('--enable-cranelift')(lambda x: True))
505 # Support for debugging code generated by wasm backends
506 # =====================================================
508 js_option('--enable-wasm-codegen-debug',
509 default=depends(when=moz_debug)(lambda: True),
510 help='{Enable|Disable} debugging for wasm codegen')
512 set_config('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
513 set_define('WASM_CODEGEN_DEBUG', depends_if('--enable-wasm-codegen-debug')(lambda x: True))
516 # Support for typed objects.
517 # =====================================================
519 @depends(milestone.is_nightly)
520 def default_typed_objects(is_nightly):
523 js_option('--enable-typed-objects',
524 default=default_typed_objects,
525 help='{Enable|Disable} typed objects')
527 set_config('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
528 set_define('ENABLE_TYPED_OBJECTS', depends_if('--enable-typed-objects')(lambda x: True))
531 # Support for WebAssembly bulk memory operations.
532 # =====================================================
534 @depends(milestone.is_nightly)
535 def default_wasm_bulk_memory(is_nightly):
538 js_option('--enable-wasm-bulk-memory',
539 default=default_wasm_bulk_memory,
540 help='{Enable|Disable} WebAssembly bulk memory operators')
542 set_config('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
543 set_define('ENABLE_WASM_BULKMEM_OPS', depends_if('--enable-wasm-bulk-memory')(lambda x: True))
546 # Support for WebAssembly reference types.
547 # =====================================================
549 @depends(milestone.is_nightly)
550 def default_wasm_reftypes(is_nightly):
553 js_option('--enable-wasm-reftypes',
554 default=default_wasm_reftypes,
555 help='{Enable|Disable} WebAssembly reference types')
557 set_config('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
558 set_define('ENABLE_WASM_REFTYPES', depends_if('--enable-wasm-reftypes')(lambda x: True))
561 # Support for WebAssembly generalized tables (anyref tables, multiple tables).
562 # ============================================================================
564 @depends(milestone.is_nightly, '--enable-wasm-reftypes')
565 def default_wasm_generalized_tables(is_nightly, reftypes):
566 if reftypes and is_nightly:
569 js_option('--enable-wasm-generalized-tables',
570 default=default_wasm_generalized_tables,
571 help='{Enable|Disable} WebAssembly generalized reference tables')
573 set_config('ENABLE_WASM_GENERALIZED_TABLES', depends_if('--enable-wasm-generalized-tables')(lambda x: True))
574 set_define('ENABLE_WASM_GENERALIZED_TABLES', depends_if('--enable-wasm-generalized-tables')(lambda x: True))
577 # Support for WebAssembly GC.
578 # ===========================
580 @depends(milestone.is_nightly, '--enable-wasm-reftypes')
581 def default_wasm_gc(is_nightly, reftypes):
582 if reftypes and is_nightly:
585 js_option('--enable-wasm-gc',
586 default=default_wasm_gc,
587 help='{Enable|Disable} WebAssembly GC')
589 set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
590 set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
593 # Support for WebAssembly private ref types.
594 # Prevent (ref T) types from being exposed to JS content so that wasm need do
595 # no typechecking at the JS/wasm boundary
596 # ===========================================================================
598 @depends(milestone.is_nightly, '--enable-wasm-gc')
599 def default_wasm_private_reftypes(is_nightly, gc):
600 if gc and is_nightly:
603 js_option('--enable-wasm-private-reftypes',
604 default=default_wasm_private_reftypes,
605 help='{Enable|Disable} WebAssembly private reference types')
607 set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
608 set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))