Skip to content
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

refactor check_all_implemented. NFC #8453

Merged
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
24 changes: 13 additions & 11 deletions emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,24 +852,26 @@ def get_all_implemented(forwarded_json, metadata):


def check_all_implemented(all_implemented, pre):
for requested in shared.Settings.ORIGINAL_EXPORTED_FUNCTIONS:
if not is_already_implemented(requested, pre, all_implemented):
# we are not checking anyway, so just skip this
if not shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS and not shared.Settings.WARN_ON_UNDEFINED_SYMBOLS:
return
# the initial list of missing functions are those we expected to export, but were not implemented in compiled code
missing = list(set(shared.Settings.ORIGINAL_EXPORTED_FUNCTIONS) - set(all_implemented))
# special-case malloc, EXPORTED by default for internal use, but we bake in a
# trivial allocator and warn at runtime if used in ASSERTIONS
if '_malloc' in missing:
missing.remove('_malloc')

for requested in missing:
in_pre = ('function ' + asstr(requested)) in pre
if not in_pre:
# could be a js library func
if shared.Settings.ERROR_ON_UNDEFINED_SYMBOLS:
exit_with_error('undefined exported function: "%s"', requested)
elif shared.Settings.WARN_ON_UNDEFINED_SYMBOLS:
logger.warning('undefined exported function: "%s"', requested)


def is_already_implemented(requested, pre, all_implemented):
is_implemented = requested in all_implemented
# special-case malloc, EXPORTED by default for internal use, but we bake in a
# trivial allocator and warn at runtime if used in ASSERTIONS
is_exception = requested == '_malloc'
in_pre = ('function ' + asstr(requested)) in pre
return is_implemented or is_exception or in_pre


def get_exported_implemented_functions(all_exported_functions, all_implemented, metadata):
funcs = set(metadata['exports'])
export_bindings = shared.Settings.EXPORT_BINDINGS
Expand Down