Source code

Revision control

Other Tools

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/.
6
7
# /!\ Use js_option() instead of option() in this file. /!\
8
# =========================================================
9
10
@depends(build_project)
11
def building_js(build_project):
12
return build_project == 'js'
13
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')
20
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')
27
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')
37
38
@depends('--disable-js-shell')
39
def js_disable_shell(value):
40
if not value:
41
return True
42
43
set_config('JS_DISABLE_SHELL', js_disable_shell)
44
45
set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))
46
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))
49
50
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')
55
56
js_option('--disable-export-js', when=js_standalone,
57
help='{Mark|Do not mark} JS symbols as DLL exported/visible')
58
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
65
66
set_config('JS_SHARED_LIBRARY', shared_js)
67
add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
68
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
73
74
set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
75
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
80
81
set_define('STATIC_JS_API', static_js_api)
82
83
@depends(shared_js)
84
def static_js(value):
85
if not value:
86
return True
87
88
set_define('MOZ_STATIC_JS', static_js)
89
90
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
98
99
js_option('--enable-ion',
100
default=ion_default,
101
help='{Enable|Disable} use of the IonMonkey JIT')
102
103
set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True))
104
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')
110
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
115
116
sim_cpu = simulator_enabled[0]
117
118
if sim_cpu in ('arm', 'mips32'):
119
if target.cpu != 'x86':
120
die('The %s simulator only works on x86.' % sim_cpu)
121
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)
125
126
return namespace(**{sim_cpu: True})
127
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)
138
139
@depends('--enable-ion', simulator, target)
140
def jit_codegen(ion_enabled, simulator, target):
141
if not ion_enabled:
142
return namespace(none=True)
143
144
if simulator:
145
return simulator
146
147
if target.cpu == 'aarch64':
148
return namespace(arm64=True)
149
elif target.cpu == 'x86_64':
150
return namespace(x64=True)
151
152
return namespace(**{str(target.cpu): True})
153
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)
168
169
# Profiling
170
# =======================================================
171
js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
172
help='Enable instruments remote profiling')
173
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
181
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')
186
187
js_option('--enable-callgrind', env='MOZ_CALLGRIND',
188
help='Enable callgrind profiling')
189
190
@depends('--enable-callgrind')
191
def callgrind(value):
192
if value:
193
return True
194
195
set_define('MOZ_CALLGRIND', callgrind)
196
imply_option('--enable-profiling', callgrind)
197
198
@depends(milestone)
199
def enable_profiling(milestone):
200
return milestone.is_nightly
201
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)')
205
206
@depends('--enable-profiling')
207
def profiling(value):
208
if value:
209
return True
210
211
add_old_configure_assignment('MOZ_PROFILING', profiling)
212
213
with only_when('--enable-compile-environment'):
214
imply_option('--enable-frame-pointers', True, when=profiling)
215
216
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')
222
223
if value and ok_cpu and ok_kernel:
224
return True
225
226
set_config('MOZ_PROFILING', profiling)
227
set_define('MOZ_PROFILING', profiling)
228
imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
229
230
231
js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')
232
233
@depends('--enable-vtune')
234
def vtune(value):
235
if value:
236
return True
237
238
set_config('MOZ_VTUNE', vtune)
239
set_define('MOZ_VTUNE', vtune)
240
241
242
js_option('--enable-gc-trace', env='JS_GC_TRACE',
243
help='Enable tracing of allocation and finalization')
244
245
@depends('--enable-gc-trace')
246
def gc_trace(value):
247
if value:
248
return True
249
250
set_define('JS_GC_TRACE', gc_trace)
251
252
253
js_option('--enable-gczeal',
254
default=depends(when=moz_debug)(lambda: True),
255
help='{Enable|Disable} zealous GCing')
256
257
set_define('JS_GC_ZEAL',
258
depends_if('--enable-gczeal')(lambda _: True))
259
260
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')
267
268
set_define('JS_GC_SMALL_CHUNK_SIZE',
269
depends(when='--enable-small-chunk-size')(lambda: True))
270
271
272
# Trace logging.
273
# =======================================================
274
@depends(milestone)
275
def default_trace_logging(milestone):
276
return milestone.is_nightly
277
278
279
js_option('--enable-trace-logging',
280
default=default_trace_logging,
281
help='{Enable|Disable} trace logging')
282
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))
287
288
289
# Enable breakpoint for artificial OOMs
290
# =======================================================
291
js_option('--enable-oom-breakpoint',
292
help='Enable a breakpoint function for artificial OOMs')
293
294
set_define('JS_OOM_BREAKPOINT',
295
depends_if('--enable-oom-breakpoint')(lambda _: True))
296
297
298
js_option('--enable-perf', env='JS_ION_PERF',
299
help='Enable Linux perf integration')
300
301
@depends('--enable-perf')
302
def ion_perf(value):
303
if value:
304
return True
305
306
set_define('JS_ION_PERF', ion_perf)
307
308
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')
313
314
set_define('JS_JITSPEW',
315
depends_if('--enable-jitspew')(lambda _: True))
316
set_config('JS_JITSPEW',
317
depends_if('--enable-jitspew')(lambda _: True))
318
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))
324
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
329
330
if simulator and (debug or spew):
331
if getattr(simulator, 'arm', None):
332
return True
333
334
if target.cpu == 'arm' and (debug or spew):
335
return True
336
337
set_config('JS_DISASM_ARM', jit_disasm_arm)
338
set_define('JS_DISASM_ARM', jit_disasm_arm)
339
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
344
345
if simulator and (debug or spew):
346
if getattr(simulator, 'arm64', None):
347
return True
348
349
if target.cpu == 'aarch64' and (debug or spew):
350
return True
351
352
set_config('JS_DISASM_ARM64', jit_disasm_arm64)
353
set_define('JS_DISASM_ARM64', jit_disasm_arm64)
354
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))
366
367
368
js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
369
help='Enable changes that make the shell more deterministic')
370
371
@depends('--enable-more-deterministic')
372
def more_deterministic(value):
373
if value:
374
return True
375
376
set_define('JS_MORE_DETERMINISTIC', more_deterministic)
377
378
379
# CTypes
380
# =======================================================
381
@depends(building_js)
382
def ctypes_default(building_js):
383
return not building_js
384
385
js_option('--enable-ctypes',
386
default=ctypes_default,
387
help='{Enable|Disable} js-ctypes')
388
389
build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
390
391
set_config('BUILD_CTYPES', build_ctypes)
392
set_define('BUILD_CTYPES', build_ctypes)
393
394
@depends(build_ctypes, building_js)
395
def js_has_ctypes(ctypes, js):
396
if ctypes and js:
397
return True
398
399
set_config('JS_HAS_CTYPES', js_has_ctypes)
400
set_define('JS_HAS_CTYPES', js_has_ctypes)
401
402
@depends('--enable-ctypes', '--enable-compile-environment')
403
def ctypes_and_compile_environment(ctypes, compile_environment):
404
return ctypes and compile_environment
405
406
include('ffi.configure', when=ctypes_and_compile_environment)
407
408
409
# Enable pipeline operator
410
# ===================================================
411
js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
412
413
@depends('--enable-pipeline-operator')
414
def enable_pipeline_operator(value):
415
if value:
416
return True
417
418
set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
419
set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
420
421
422
423
# Experimental support for BinAST
424
# ==============================================================
425
426
@depends(milestone.is_nightly)
427
def default_binast(is_nightly):
428
return is_nightly
429
430
js_option('--enable-binast',
431
default=default_binast,
432
help="{Enable|Disable} BinAST support")
433
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))
436
437
438
# Experimental support for wasm code generation with Cranelift
439
# ==============================================================
440
441
js_option('--enable-cranelift',
442
default=milestone.is_nightly,
443
help='{Enable|Disable} Cranelift code generator for wasm')
444
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))
447
448
449
# Support for debugging code generated by wasm backends
450
# =====================================================
451
452
js_option('--enable-wasm-codegen-debug',
453
default=depends(when=moz_debug)(lambda: True),
454
help='{Enable|Disable} debugging for wasm codegen')
455
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))
458
459
460
# Support for typed objects.
461
# =====================================================
462
463
@depends(milestone.is_nightly)
464
def default_typed_objects(is_nightly):
465
return is_nightly
466
467
js_option('--enable-typed-objects',
468
default=default_typed_objects,
469
help='{Enable|Disable} typed objects')
470
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))
473
474
475
# Support for WebAssembly bulk memory operations.
476
# =====================================================
477
478
@depends(milestone.is_nightly)
479
def default_wasm_bulk_memory(is_nightly):
480
return is_nightly
481
482
js_option('--enable-wasm-bulk-memory',
483
default=default_wasm_bulk_memory,
484
help='{Enable|Disable} WebAssembly bulk memory operators')
485
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))
488
489
490
# Support for WebAssembly reference types.
491
# =====================================================
492
493
@depends(milestone.is_nightly)
494
def default_wasm_reftypes(is_nightly):
495
return is_nightly
496
497
js_option('--enable-wasm-reftypes',
498
default=default_wasm_reftypes,
499
help='{Enable|Disable} WebAssembly reference types')
500
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))
503
504
505
# Support for WebAssembly I64/BigInt conversion
506
# ===========================================================================
507
508
@depends(milestone.is_nightly)
509
def default_wasm_bigint(is_nightly):
510
return is_nightly
511
512
js_option('--enable-wasm-bigint',
513
default=default_wasm_bigint,
514
help='{Enable|Disable} WebAssembly I64/BigInt conversion')
515
516
set_config('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
517
set_define('ENABLE_WASM_BIGINT', depends_if('--enable-wasm-bigint')(lambda x: True))
518
519
520
# Support for WebAssembly GC.
521
# ===========================
522
523
@depends(milestone.is_nightly, '--enable-wasm-reftypes')
524
def default_wasm_gc(is_nightly, reftypes):
525
if reftypes and is_nightly:
526
return True
527
528
js_option('--enable-wasm-gc',
529
default=default_wasm_gc,
530
help='{Enable|Disable} WebAssembly GC')
531
532
set_config('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
533
set_define('ENABLE_WASM_GC', depends_if('--enable-wasm-gc')(lambda x: True))
534
535
536
# Support for WebAssembly private ref types.
537
# Prevent (ref T) types from being exposed to JS content so that wasm need do
538
# no typechecking at the JS/wasm boundary
539
# ===========================================================================
540
541
@depends(milestone.is_nightly, '--enable-wasm-gc')
542
def default_wasm_private_reftypes(is_nightly, gc):
543
if gc and is_nightly:
544
return True
545
546
js_option('--enable-wasm-private-reftypes',
547
default=default_wasm_private_reftypes,
548
help='{Enable|Disable} WebAssembly private reference types')
549
550
set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
551
set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))