@@ -380,7 +380,7 @@ def setup_environment_settings():
380
380
settings .ENVIRONMENT_MAY_BE_WORKER = \
381
381
not settings .ENVIRONMENT or \
382
382
'worker' in environments or \
383
- (settings .ENVIRONMENT_MAY_BE_NODE and settings .USE_PTHREADS )
383
+ (settings .ENVIRONMENT_MAY_BE_NODE and settings .PTHREADS )
384
384
385
385
if not settings .ENVIRONMENT_MAY_BE_WORKER and settings .PROXY_TO_WORKER :
386
386
exit_with_error ('If you specify --proxy-to-worker and specify a "-sENVIRONMENT=" directive, it must include "worker" as a target! (Try e.g. -sENVIRONMENT=web,worker)' )
@@ -1595,11 +1595,14 @@ def phase_setup(options, state, newargs):
1595
1595
if settings .MAIN_MODULE or settings .SIDE_MODULE :
1596
1596
settings .RELOCATABLE = 1
1597
1597
1598
+ if 'USE_PTHREADS' in user_settings :
1599
+ settings .PTHREADS = settings .USE_PTHREADS
1600
+
1598
1601
# Pthreads and Wasm Workers require targeting shared Wasm memory (SAB).
1599
- if settings .USE_PTHREADS or settings .WASM_WORKERS :
1602
+ if settings .PTHREADS or settings .WASM_WORKERS :
1600
1603
settings .SHARED_MEMORY = 1
1601
1604
1602
- if settings .USE_PTHREADS and '-pthread' not in newargs :
1605
+ if settings .PTHREADS and '-pthread' not in newargs :
1603
1606
newargs += ['-pthread' ]
1604
1607
elif settings .SHARED_MEMORY :
1605
1608
if '-matomics' not in newargs :
@@ -1751,7 +1754,7 @@ def include_and_export(name):
1751
1754
if not settings .EXPORT_ES6 and settings .EXPORT_NAME == 'Module' :
1752
1755
exit_with_error ('pthreads + MODULARIZE currently require you to set -sEXPORT_NAME=Something (see settings.js) to Something != Module, so that the .worker.js file can work' )
1753
1756
1754
- # MODULARIZE+USE_PTHREADS mode requires extra exports out to Module so that worker.js
1757
+ # MODULARIZE+PTHREADS mode requires extra exports out to Module so that worker.js
1755
1758
# can access them:
1756
1759
1757
1760
# general threading variables:
@@ -2099,7 +2102,7 @@ def phase_linker_setup(options, state, newargs):
2099
2102
'$mergeLibSymbols' ,
2100
2103
]
2101
2104
2102
- if settings .USE_PTHREADS :
2105
+ if settings .PTHREADS :
2103
2106
settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += [
2104
2107
'$registerTLSInit' ,
2105
2108
]
@@ -2210,7 +2213,7 @@ def phase_linker_setup(options, state, newargs):
2210
2213
# HTML output creates a singleton instance, and it does so without the
2211
2214
# Promise. However, in Pthreads mode the Promise is used for worker
2212
2215
# creation.
2213
- if settings .MINIMAL_RUNTIME and options .oformat == OFormat .HTML and not settings .USE_PTHREADS :
2216
+ if settings .MINIMAL_RUNTIME and options .oformat == OFormat .HTML and not settings .PTHREADS :
2214
2217
settings .EXPORT_READY_PROMISE = 0
2215
2218
2216
2219
if settings .LEGACY_VM_SUPPORT :
@@ -2327,7 +2330,7 @@ def phase_linker_setup(options, state, newargs):
2327
2330
if settings .FETCH and final_suffix in EXECUTABLE_ENDINGS :
2328
2331
state .forced_stdlibs .append ('libfetch' )
2329
2332
settings .JS_LIBRARIES .append ((0 , 'library_fetch.js' ))
2330
- if settings .USE_PTHREADS :
2333
+ if settings .PTHREADS :
2331
2334
settings .FETCH_WORKER_FILE = unsuffixed_basename (target ) + '.fetch.js'
2332
2335
2333
2336
if settings .DEMANGLE_SUPPORT :
@@ -2397,7 +2400,7 @@ def phase_linker_setup(options, state, newargs):
2397
2400
# overrides that.
2398
2401
default_setting ('ABORTING_MALLOC' , 0 )
2399
2402
2400
- if settings .USE_PTHREADS :
2403
+ if settings .PTHREADS :
2401
2404
setup_pthreads (target )
2402
2405
settings .JS_LIBRARIES .append ((0 , 'library_pthread.js' ))
2403
2406
if settings .PROXY_TO_PTHREAD :
@@ -2629,7 +2632,7 @@ def check_memory_setting(setting):
2629
2632
# are based on experimentation with different tests/programs under asan and
2630
2633
# lsan.
2631
2634
settings .INITIAL_MEMORY += 50 * 1024 * 1024
2632
- if settings .USE_PTHREADS :
2635
+ if settings .PTHREADS :
2633
2636
settings .INITIAL_MEMORY += 50 * 1024 * 1024
2634
2637
2635
2638
if settings .USE_OFFSET_CONVERTER and settings .WASM2JS :
@@ -3175,7 +3178,7 @@ def phase_final_emitting(options, state, target, wasm_target, memfile):
3175
3178
# write_file(final_js, src)
3176
3179
3177
3180
target_dir = os .path .dirname (os .path .abspath (target ))
3178
- if settings .USE_PTHREADS :
3181
+ if settings .PTHREADS :
3179
3182
worker_output = os .path .join (target_dir , settings .PTHREAD_WORKER_FILE )
3180
3183
contents = shared .read_and_preprocess (utils .path_from_root ('src/worker.js' ), expand_macros = True )
3181
3184
write_file (worker_output , contents )
@@ -3576,9 +3579,11 @@ def consume_arg_file():
3576
3579
options .output_eol = '\n '
3577
3580
else :
3578
3581
exit_with_error (f'Invalid value "{ style } " to --output_eol!' )
3579
- # Record USE_PTHREADS setting because it controls whether --shared-memory is passed to lld
3582
+ # Record PTHREADS setting because it controls whether --shared-memory is passed to lld
3580
3583
elif arg == '-pthread' :
3581
- settings_changes .append ('USE_PTHREADS=1' )
3584
+ settings .PTHREADS = 1
3585
+ # Also set the legacy setting name, in case use JS code depends on it.
3586
+ settings .USE_PTHREADS = 1
3582
3587
elif arg == '-pthreads' :
3583
3588
exit_with_error ('unrecognized command-line option ‘-pthreads’; did you mean ‘-pthread’?' )
3584
3589
elif arg in ('-fno-diagnostics-color' , '-fdiagnostics-color=never' ):
@@ -3706,7 +3711,7 @@ def phase_binaryen(target, options, wasm_target):
3706
3711
# adds some >>> 0 things, while growth will replace a HEAP8 with a call to
3707
3712
# a method to get the heap, and that call would not be recognized by the
3708
3713
# unsigning pass
3709
- if settings .USE_PTHREADS and settings .ALLOW_MEMORY_GROWTH :
3714
+ if settings .PTHREADS and settings .ALLOW_MEMORY_GROWTH :
3710
3715
with ToolchainProfiler .profile_block ('apply_wasm_memory_growth' ):
3711
3716
final_js = building .apply_wasm_memory_growth (final_js )
3712
3717
@@ -3880,15 +3885,15 @@ def modularize():
3880
3885
'capture_module_function_for_audio_worklet' : 'globalThis.AudioWorkletModule = Module;' if settings .AUDIO_WORKLET and settings .MODULARIZE else ''
3881
3886
}
3882
3887
3883
- if settings .MINIMAL_RUNTIME and not settings .USE_PTHREADS :
3888
+ if settings .MINIMAL_RUNTIME and not settings .PTHREADS :
3884
3889
# Single threaded MINIMAL_RUNTIME programs do not need access to
3885
3890
# document.currentScript, so a simple export declaration is enough.
3886
3891
src = 'var %s=%s' % (settings .EXPORT_NAME , src )
3887
3892
else :
3888
3893
script_url_node = ''
3889
3894
# When MODULARIZE this JS may be executed later,
3890
3895
# after document.currentScript is gone, so we save it.
3891
- # In EXPORT_ES6 + USE_PTHREADS the 'thread' is actually an ES6 module webworker running in strict mode,
3896
+ # In EXPORT_ES6 + PTHREADS the 'thread' is actually an ES6 module webworker running in strict mode,
3892
3897
# so doesn't have access to 'document'. In this case use 'import.meta' instead.
3893
3898
if settings .EXPORT_ES6 and settings .USE_ES6_IMPORT_META :
3894
3899
script_url = 'import.meta.url'
0 commit comments