@@ -217,8 +217,6 @@ def get_js_sym_info():
217217 assert jslibs
218218 input_files .extend (read_file (jslib ) for jslib in sorted (jslibs ))
219219 for jslib in settings .JS_LIBRARIES :
220- if not os .path .isabs (jslib ):
221- jslib = utils .path_from_root ('src/lib' , jslib )
222220 input_files .append (read_file (jslib ))
223221 content = '\n ' .join (input_files )
224222 content_hash = hashlib .sha1 (content .encode ('utf-8' )).hexdigest ()
@@ -1246,7 +1244,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
12461244 if settings .WASMFS :
12471245 settings .FILESYSTEM = 1
12481246 settings .SYSCALLS_REQUIRE_FILESYSTEM = 0
1249- settings . JS_LIBRARIES . append ('libwasmfs.js' )
1247+ add_system_js_lib ('libwasmfs.js' )
12501248 if settings .ASSERTIONS :
12511249 # used in assertion checks for unflushed content
12521250 settings .REQUIRED_EXPORTS += ['wasmfs_flush' ]
@@ -1362,14 +1360,14 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
13621360
13631361 if settings .PTHREADS :
13641362 setup_pthreads ()
1365- settings . JS_LIBRARIES . append ('libpthread.js' )
1363+ add_system_js_lib ('libpthread.js' )
13661364 if settings .PROXY_TO_PTHREAD :
13671365 settings .PTHREAD_POOL_SIZE_STRICT = 0
13681366 settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$runtimeKeepalivePush' ]
13691367 else :
13701368 if settings .PROXY_TO_PTHREAD :
13711369 exit_with_error ('-sPROXY_TO_PTHREAD requires -pthread to work!' )
1372- settings . JS_LIBRARIES . append ('libpthread_stub.js' )
1370+ add_system_js_lib ('libpthread_stub.js' )
13731371
13741372 if settings .MEMORY64 :
13751373 # Any "pointers" passed to JS will now be i64's, in both modes.
@@ -1383,7 +1381,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
13831381 # set location of Wasm Worker bootstrap JS file
13841382 if settings .WASM_WORKERS == 1 :
13851383 settings .WASM_WORKER_FILE = unsuffixed (os .path .basename (target )) + '.ww.js'
1386- settings . JS_LIBRARIES . append ('libwasm_worker.js' )
1384+ add_system_js_lib ('libwasm_worker.js' )
13871385
13881386 # Set min browser versions based on certain settings such as WASM_BIGINT,
13891387 # PTHREADS, AUDIO_WORKLET
@@ -1401,7 +1399,7 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
14011399 if settings .AUDIO_WORKLET :
14021400 if settings .AUDIO_WORKLET == 1 :
14031401 settings .AUDIO_WORKLET_FILE = unsuffixed (os .path .basename (target )) + '.aw.js'
1404- settings . JS_LIBRARIES . append ('libwebaudio.js' )
1402+ add_system_js_lib ('libwebaudio.js' )
14051403 if not settings .MINIMAL_RUNTIME :
14061404 # If we are in the audio worklet environment, we can only access the Module object
14071405 # and not the global scope of the main JS script. Therefore we need to export
@@ -2767,14 +2765,20 @@ def map_to_js_libs(library_name):
27672765 return None
27682766
27692767
2768+ def add_system_js_lib (lib ):
2769+ lib = utils .path_from_root ('src/lib' , lib )
2770+ assert os .path .exists (lib )
2771+ settings .JS_LIBRARIES .append (lib )
2772+
2773+
27702774def process_libraries (options , flags ):
27712775 new_flags = []
27722776 system_libs_map = system_libs .Library .get_usable_variations ()
27732777
27742778 # Process `-l` and `--js-library` flags
27752779 for flag in flags :
27762780 if flag .startswith ('--js-library=' ):
2777- js_lib = os . path . abspath ( flag .split ('=' , 1 )[1 ])
2781+ js_lib = flag .split ('=' , 1 )[1 ]
27782782 settings .JS_LIBRARIES .append (js_lib )
27792783 continue
27802784 if not flag .startswith ('-l' ):
@@ -2784,9 +2788,8 @@ def process_libraries(options, flags):
27842788
27852789 logger .debug ('looking for library "%s"' , lib )
27862790
2787- js_libs = map_to_js_libs (lib )
2788- if js_libs is not None :
2789- settings .JS_LIBRARIES += js_libs
2791+ for lib in map_to_js_libs (lib ):
2792+ add_system_js_lib (lib )
27902793
27912794 # We don't need to resolve system libraries to absolute paths here, we can just
27922795 # let wasm-ld handle that. However, we do want to map to the correct variant.
0 commit comments