Skip to content

Minor refactor of process_libraries. NFC #14384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ def run(args):
if state.mode == Mode.POST_LINK_ONLY:
settings.limit_settings(None)
target, wasm_target = phase_linker_setup(options, state, newargs, settings_map)
process_libraries(state.link_flags, state.lib_dirs, [])
process_libraries(state, [])
if len(input_files) != 1:
exit_with_error('--post-link requires a single input file')
phase_post_link(options, state, input_files[0][1], wasm_target, target)
Expand Down Expand Up @@ -1113,7 +1113,7 @@ def phase_calculate_linker_inputs(options, state, linker_inputs):
state.link_flags = filter_link_flags(state.link_flags, using_lld)

# Decide what we will link
state.link_flags = process_libraries(state.link_flags, state.lib_dirs, linker_inputs)
process_libraries(state, linker_inputs)

linker_args = [val for _, val in sorted(linker_inputs + state.link_flags)]

Expand Down Expand Up @@ -3502,14 +3502,14 @@ def find_library(lib, lib_dirs):
return None


def process_libraries(link_flags, lib_dirs, linker_inputs):
def process_libraries(state, linker_inputs):
new_flags = []
libraries = []
suffixes = STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS
system_libs_map = system_libs.Library.get_usable_variations()

# Find library files
for i, flag in link_flags:
for i, flag in state.link_flags:
if not flag.startswith('-l'):
new_flags.append((i, flag))
continue
Expand All @@ -3527,7 +3527,7 @@ def process_libraries(link_flags, lib_dirs, linker_inputs):
path = None
for suff in suffixes:
name = 'lib' + lib + suff
path = find_library(name, lib_dirs)
path = find_library(name, state.lib_dirs)
if path:
break

Expand All @@ -3546,7 +3546,7 @@ def process_libraries(link_flags, lib_dirs, linker_inputs):
# Sort the input list from (order, lib_name) pairs to a flat array in the right order.
settings.SYSTEM_JS_LIBRARIES.sort(key=lambda lib: lib[0])
settings.SYSTEM_JS_LIBRARIES = [lib[1] for lib in settings.SYSTEM_JS_LIBRARIES]
return new_flags
state.link_flags = new_flags


class ScriptSource:
Expand Down