@@ -217,8 +217,6 @@ def get_js_sym_info():
217
217
assert jslibs
218
218
input_files .extend (read_file (jslib ) for jslib in sorted (jslibs ))
219
219
for jslib in settings .JS_LIBRARIES :
220
- if not os .path .isabs (jslib ):
221
- jslib = utils .path_from_root ('src/lib' , jslib )
222
220
input_files .append (read_file (jslib ))
223
221
content = '\n ' .join (input_files )
224
222
content_hash = hashlib .sha1 (content .encode ('utf-8' )).hexdigest ()
@@ -629,6 +627,12 @@ def check_browser_versions():
629
627
exit_with_error (f'{ key } older than { oldest } is not supported' )
630
628
631
629
630
+ def add_system_js_lib (lib ):
631
+ lib = utils .path_from_root ('src/lib' , lib )
632
+ assert os .path .exists (lib )
633
+ settings .JS_LIBRARIES .append (lib )
634
+
635
+
632
636
@ToolchainProfiler .profile_block ('linker_setup' )
633
637
def phase_linker_setup (options , linker_args ): # noqa: C901, PLR0912, PLR0915
634
638
"""Future modifications should consider refactoring to reduce complexity.
@@ -1246,7 +1250,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
1246
1250
if settings .WASMFS :
1247
1251
settings .FILESYSTEM = 1
1248
1252
settings .SYSCALLS_REQUIRE_FILESYSTEM = 0
1249
- settings . JS_LIBRARIES . append ('libwasmfs.js' )
1253
+ add_system_js_lib ('libwasmfs.js' )
1250
1254
if settings .ASSERTIONS :
1251
1255
# used in assertion checks for unflushed content
1252
1256
settings .REQUIRED_EXPORTS += ['wasmfs_flush' ]
@@ -1362,14 +1366,14 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
1362
1366
1363
1367
if settings .PTHREADS :
1364
1368
setup_pthreads ()
1365
- settings . JS_LIBRARIES . append ('libpthread.js' )
1369
+ add_system_js_lib ('libpthread.js' )
1366
1370
if settings .PROXY_TO_PTHREAD :
1367
1371
settings .PTHREAD_POOL_SIZE_STRICT = 0
1368
1372
settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$runtimeKeepalivePush' ]
1369
1373
else :
1370
1374
if settings .PROXY_TO_PTHREAD :
1371
1375
exit_with_error ('-sPROXY_TO_PTHREAD requires -pthread to work!' )
1372
- settings . JS_LIBRARIES . append ('libpthread_stub.js' )
1376
+ add_system_js_lib ('libpthread_stub.js' )
1373
1377
1374
1378
if settings .MEMORY64 :
1375
1379
# Any "pointers" passed to JS will now be i64's, in both modes.
@@ -1383,7 +1387,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
1383
1387
# set location of Wasm Worker bootstrap JS file
1384
1388
if settings .WASM_WORKERS == 1 :
1385
1389
settings .WASM_WORKER_FILE = unsuffixed (os .path .basename (target )) + '.ww.js'
1386
- settings . JS_LIBRARIES . append ('libwasm_worker.js' )
1390
+ add_system_js_lib ('libwasm_worker.js' )
1387
1391
1388
1392
# Set min browser versions based on certain settings such as WASM_BIGINT,
1389
1393
# PTHREADS, AUDIO_WORKLET
@@ -1401,7 +1405,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
1401
1405
if settings .AUDIO_WORKLET :
1402
1406
if settings .AUDIO_WORKLET == 1 :
1403
1407
settings .AUDIO_WORKLET_FILE = unsuffixed (os .path .basename (target )) + '.aw.js'
1404
- settings . JS_LIBRARIES . append ('libwebaudio.js' )
1408
+ add_system_js_lib ('libwebaudio.js' )
1405
1409
if not settings .MINIMAL_RUNTIME :
1406
1410
# If we are in the audio worklet environment, we can only access the Module object
1407
1411
# and not the global scope of the main JS script. Therefore we need to export
@@ -1774,11 +1778,13 @@ def get_full_import_name(name):
1774
1778
if not js_manipulation .isidentifier (settings .EXPORT_NAME ):
1775
1779
exit_with_error (f'EXPORT_NAME is not a valid JS identifier: `{ settings .EXPORT_NAME } `' )
1776
1780
1777
- if settings .EMSCRIPTEN_TRACING and settings .ALLOW_MEMORY_GROWTH :
1778
- settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['emscripten_trace_report_memory_layout' ]
1779
- settings .REQUIRED_EXPORTS += ['emscripten_stack_get_current' ,
1780
- 'emscripten_stack_get_base' ,
1781
- 'emscripten_stack_get_end' ]
1781
+ if settings .EMSCRIPTEN_TRACING :
1782
+ add_system_js_lib ('libtrace.js' )
1783
+ if settings .ALLOW_MEMORY_GROWTH :
1784
+ settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['emscripten_trace_report_memory_layout' ]
1785
+ settings .REQUIRED_EXPORTS += ['emscripten_stack_get_current' ,
1786
+ 'emscripten_stack_get_base' ,
1787
+ 'emscripten_stack_get_end' ]
1782
1788
1783
1789
settings .EMSCRIPTEN_VERSION = utils .EMSCRIPTEN_VERSION
1784
1790
settings .SOURCE_MAP_BASE = options .source_map_base or ''
@@ -1999,11 +2005,11 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
1999
2005
setup_environment_settings ()
2000
2006
# Use a separate Wasm file so the JS does not need to be modified after emscripten.emscript.
2001
2007
settings .SINGLE_FILE = False
2002
- # Embind may be included multiple times, de-duplicate the list first.
2003
- settings .JS_LIBRARIES = dedup_list (settings .JS_LIBRARIES )
2004
2008
# Replace embind with the TypeScript generation version.
2005
- embind_index = settings .JS_LIBRARIES .index ('libembind.js' )
2006
- settings .JS_LIBRARIES [embind_index ] = 'libembind_gen.js'
2009
+ for i , lib in enumerate (settings .JS_LIBRARIES ):
2010
+ dirname , basename = os .path .split (lib )
2011
+ if basename == 'libembind.js' :
2012
+ settings .JS_LIBRARIES [i ] = os .path .join (dirname , 'libembind_gen.js' )
2007
2013
if settings .MEMORY64 :
2008
2014
settings .MIN_NODE_VERSION = 160000
2009
2015
# Source maps haven't been generated yet and aren't needed to run embind_gen.
@@ -2774,7 +2780,7 @@ def process_libraries(options, flags):
2774
2780
# Process `-l` and `--js-library` flags
2775
2781
for flag in flags :
2776
2782
if flag .startswith ('--js-library=' ):
2777
- js_lib = os . path . abspath ( flag .split ('=' , 1 )[1 ])
2783
+ js_lib = flag .split ('=' , 1 )[1 ]
2778
2784
settings .JS_LIBRARIES .append (js_lib )
2779
2785
continue
2780
2786
if not flag .startswith ('-l' ):
@@ -2786,7 +2792,8 @@ def process_libraries(options, flags):
2786
2792
2787
2793
js_libs = map_to_js_libs (lib )
2788
2794
if js_libs is not None :
2789
- settings .JS_LIBRARIES += js_libs
2795
+ for l in js_libs :
2796
+ add_system_js_lib (l )
2790
2797
2791
2798
# We don't need to resolve system libraries to absolute paths here, we can just
2792
2799
# let wasm-ld handle that. However, we do want to map to the correct variant.
0 commit comments