101
101
}
102
102
103
103
DEFAULT_ASYNCIFY_IMPORTS = [
104
- 'emscripten_sleep' , ' emscripten_wget' , 'emscripten_wget_data' , 'emscripten_idb_load' ,
104
+ 'emscripten_wget' , 'emscripten_wget_data' , 'emscripten_idb_load' ,
105
105
'emscripten_idb_store' , 'emscripten_idb_delete' , 'emscripten_idb_exists' ,
106
106
'emscripten_idb_load_blob' , 'emscripten_idb_store_blob' , 'SDL_Delay' ,
107
107
'emscripten_scan_registers' , 'emscripten_lazy_load_code' ,
@@ -507,7 +507,7 @@ def ensure_archive_index(archive_file):
507
507
run_process ([shared .LLVM_RANLIB , archive_file ])
508
508
509
509
510
- def generate_js_symbols ():
510
+ def generate_js_sym_info ():
511
511
# Runs the js compiler to generate a list of all symbols available in the JS
512
512
# libraries. This must be done separately for each linker invokation since the
513
513
# list of symbols depends on what settings are used.
@@ -520,11 +520,11 @@ def generate_js_symbols():
520
520
521
521
522
522
@ToolchainProfiler .profile_block ('JS symbol generation' )
523
- def get_all_js_syms ():
523
+ def get_js_sym_info ():
524
524
# Avoiding using the cache when generating struct info since
525
525
# this step is performed while the cache is locked.
526
526
if DEBUG or settings .BOOTSTRAPPING_STRUCT_INFO or config .FROZEN_CACHE :
527
- return generate_js_symbols ()
527
+ return generate_js_sym_info ()
528
528
529
529
# We define a cache hit as when the settings and `--js-library` contents are
530
530
# identical.
@@ -545,29 +545,16 @@ def get_all_js_syms():
545
545
def build_symbol_list (filename ):
546
546
"""Only called when there is no existing symbol list for a given content hash.
547
547
"""
548
- library_syms = generate_js_symbols ()
549
- lines = []
548
+ library_syms = generate_js_sym_info ()
550
549
551
- for name , deps in library_syms .items ():
552
- if deps :
553
- lines .append ('%s: %s' % (name , ',' .join (deps )))
554
- else :
555
- lines .append (name )
556
- write_file (filename , '\n ' .join (lines ) + '\n ' )
550
+ write_file (filename , json .dumps (library_syms , separators = (',' , ':' )))
557
551
558
552
# We need to use a separate lock here for symbol lists because, unlike with system libraries,
559
553
# it's normally for these file to get pruned as part of normal operation. This means that it
560
554
# can be deleted between the `cache.get()` then the `read_file`.
561
555
with filelock .FileLock (cache .get_path (cache .get_path ('symbol_lists.lock' ))):
562
- filename = cache .get (f'symbol_lists/{ content_hash } .txt' , build_symbol_list )
563
- lines = read_file (filename ).splitlines ()
564
- library_syms = {}
565
- for line in lines :
566
- if ':' in line :
567
- name , deps = line .split (':' )
568
- library_syms [name ] = deps .strip ().split (',' )
569
- else :
570
- library_syms [line ] = []
556
+ filename = cache .get (f'symbol_lists/{ content_hash } .json' , build_symbol_list )
557
+ library_syms = json .loads (read_file (filename ))
571
558
572
559
# Limit of the overall size of the cache to 100 files.
573
560
# This code will get test coverage since a full test run of `other` or `core`
@@ -1334,9 +1321,13 @@ def run(args):
1334
1321
return 0
1335
1322
1336
1323
js_syms = {}
1337
- if not settings .SIDE_MODULE :
1338
- js_syms = get_all_js_syms ()
1339
- deps_info .append_deps_info (js_syms )
1324
+ if not settings .SIDE_MODULE or settings .ASYNCIFY :
1325
+ js_info = get_js_sym_info ()
1326
+ if not settings .SIDE_MODULE :
1327
+ js_syms = js_info ['deps' ]
1328
+ deps_info .append_deps_info (js_syms )
1329
+ if settings .ASYNCIFY :
1330
+ settings .ASYNCIFY_IMPORTS += ['env.' + x for x in js_info ['asyncFuncs' ]]
1340
1331
1341
1332
phase_calculate_system_libraries (state , linker_arguments , linker_inputs , newargs )
1342
1333
0 commit comments