@@ -380,7 +380,7 @@ def setup_environment_settings():
380380 settings .ENVIRONMENT_MAY_BE_WORKER  =  \
381381 not  settings .ENVIRONMENT  or  \
382382 'worker'  in  environments  or  \
383-  (settings .ENVIRONMENT_MAY_BE_NODE  and  settings .USE_PTHREADS )
383+  (settings .ENVIRONMENT_MAY_BE_NODE  and  settings .PTHREADS )
384384
385385 if  not  settings .ENVIRONMENT_MAY_BE_WORKER  and  settings .PROXY_TO_WORKER :
386386 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):
15951595 if  settings .MAIN_MODULE  or  settings .SIDE_MODULE :
15961596 settings .RELOCATABLE  =  1 
15971597
1598+  if  'USE_PTHREADS'  in  user_settings :
1599+  settings .PTHREADS  =  settings .USE_PTHREADS 
1600+ 
15981601 # 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 :
16001603 settings .SHARED_MEMORY  =  1 
16011604
1602-  if  settings .USE_PTHREADS  and  '-pthread'  not  in newargs :
1605+  if  settings .PTHREADS  and  '-pthread'  not  in newargs :
16031606 newargs  +=  ['-pthread' ]
16041607 elif  settings .SHARED_MEMORY :
16051608 if  '-matomics'  not  in newargs :
@@ -1751,7 +1754,7 @@ def include_and_export(name):
17511754 if  not  settings .EXPORT_ES6  and  settings .EXPORT_NAME  ==  'Module' :
17521755 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' )
17531756
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 
17551758 # can access them: 
17561759
17571760 # general threading variables: 
@@ -2099,7 +2102,7 @@ def phase_linker_setup(options, state, newargs):
20992102 '$mergeLibSymbols' ,
21002103 ]
21012104
2102-  if  settings .USE_PTHREADS :
2105+  if  settings .PTHREADS :
21032106 settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE  +=  [
21042107 '$registerTLSInit' ,
21052108 ]
@@ -2210,7 +2213,7 @@ def phase_linker_setup(options, state, newargs):
22102213 # HTML output creates a singleton instance, and it does so without the 
22112214 # Promise. However, in Pthreads mode the Promise is used for worker 
22122215 # 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 :
22142217 settings .EXPORT_READY_PROMISE  =  0 
22152218
22162219 if  settings .LEGACY_VM_SUPPORT :
@@ -2327,7 +2330,7 @@ def phase_linker_setup(options, state, newargs):
23272330 if  settings .FETCH  and  final_suffix  in  EXECUTABLE_ENDINGS :
23282331 state .forced_stdlibs .append ('libfetch' )
23292332 settings .JS_LIBRARIES .append ((0 , 'library_fetch.js' ))
2330-  if  settings .USE_PTHREADS :
2333+  if  settings .PTHREADS :
23312334 settings .FETCH_WORKER_FILE  =  unsuffixed_basename (target ) +  '.fetch.js' 
23322335
23332336 if  settings .DEMANGLE_SUPPORT :
@@ -2397,7 +2400,7 @@ def phase_linker_setup(options, state, newargs):
23972400 # overrides that. 
23982401 default_setting ('ABORTING_MALLOC' , 0 )
23992402
2400-  if  settings .USE_PTHREADS :
2403+  if  settings .PTHREADS :
24012404 setup_pthreads (target )
24022405 settings .JS_LIBRARIES .append ((0 , 'library_pthread.js' ))
24032406 if  settings .PROXY_TO_PTHREAD :
@@ -2629,7 +2632,7 @@ def check_memory_setting(setting):
26292632 # are based on experimentation with different tests/programs under asan and 
26302633 # lsan. 
26312634 settings .INITIAL_MEMORY  +=  50  *  1024  *  1024 
2632-  if  settings .USE_PTHREADS :
2635+  if  settings .PTHREADS :
26332636 settings .INITIAL_MEMORY  +=  50  *  1024  *  1024 
26342637
26352638 if  settings .USE_OFFSET_CONVERTER  and  settings .WASM2JS :
@@ -3175,7 +3178,7 @@ def phase_final_emitting(options, state, target, wasm_target, memfile):
31753178 # write_file(final_js, src) 
31763179
31773180 target_dir  =  os .path .dirname (os .path .abspath (target ))
3178-  if  settings .USE_PTHREADS :
3181+  if  settings .PTHREADS :
31793182 worker_output  =  os .path .join (target_dir , settings .PTHREAD_WORKER_FILE )
31803183 contents  =  shared .read_and_preprocess (utils .path_from_root ('src/worker.js' ), expand_macros = True )
31813184 write_file (worker_output , contents )
@@ -3576,9 +3579,11 @@ def consume_arg_file():
35763579 options .output_eol  =  '\n ' 
35773580 else :
35783581 exit_with_error (f'Invalid value "{ style }  )
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 
35803583 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 
35823587 elif  arg  ==  '-pthreads' :
35833588 exit_with_error ('unrecognized command-line option ‘-pthreads’; did you mean ‘-pthread’?' )
35843589 elif  arg  in  ('-fno-diagnostics-color' , '-fdiagnostics-color=never' ):
@@ -3706,7 +3711,7 @@ def phase_binaryen(target, options, wasm_target):
37063711 # adds some >>> 0 things, while growth will replace a HEAP8 with a call to 
37073712 # a method to get the heap, and that call would not be recognized by the 
37083713 # unsigning pass 
3709-  if  settings .USE_PTHREADS  and  settings .ALLOW_MEMORY_GROWTH :
3714+  if  settings .PTHREADS  and  settings .ALLOW_MEMORY_GROWTH :
37103715 with  ToolchainProfiler .profile_block ('apply_wasm_memory_growth' ):
37113716 final_js  =  building .apply_wasm_memory_growth (final_js )
37123717
@@ -3880,15 +3885,15 @@ def modularize():
38803885 'capture_module_function_for_audio_worklet' : 'globalThis.AudioWorkletModule = Module;'  if  settings .AUDIO_WORKLET  and  settings .MODULARIZE  else  '' 
38813886 }
38823887
3883-  if  settings .MINIMAL_RUNTIME  and  not  settings .USE_PTHREADS :
3888+  if  settings .MINIMAL_RUNTIME  and  not  settings .PTHREADS :
38843889 # Single threaded MINIMAL_RUNTIME programs do not need access to 
38853890 # document.currentScript, so a simple export declaration is enough. 
38863891 src  =  'var %s=%s'  %  (settings .EXPORT_NAME , src )
38873892 else :
38883893 script_url_node  =  '' 
38893894 # When MODULARIZE this JS may be executed later, 
38903895 # 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, 
38923897 # so doesn't have access to 'document'. In this case use 'import.meta' instead. 
38933898 if  settings .EXPORT_ES6  and  settings .USE_ES6_IMPORT_META :
38943899 script_url  =  'import.meta.url' 
0 commit comments