Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,6 @@ function getWasmImports() {
#endif
#endif

#if hasExportedSymbol('__cpp_exception') && !RELOCATABLE
___cpp_exception = wasmExports['__cpp_exception'];
{{{ receivedSymbol('___cpp_exception') }}};
#endif

#if hasExportedSymbol('__wasm_apply_data_relocs')
__RELOC_FUNCS__.push(wasmExports['__wasm_apply_data_relocs']);
#endif
Expand Down
13 changes: 5 additions & 8 deletions tools/emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ def trim_asm_const_body(body):
return body


def create_other_export_declarations(tag_exports):
return '\n'.join(f'var {asmjs_mangle(name)};' for name in tag_exports)


def create_global_exports(global_exports):
lines = []
for k, v in global_exports.items():
Expand Down Expand Up @@ -953,6 +949,8 @@ def create_receiving(function_exports, tag_exports, library_symbols):
# function assignWasmExports(wasmExport) {
# _main = wasmExports["_main"];
exports = {name: sig for name, sig in function_exports.items() if name != building.WASM_CALL_CTORS}
for t in tag_exports:
exports[t] = None

if settings.ASSERTIONS:
# In debug builds we generate trapping functions in case
Expand All @@ -979,16 +977,17 @@ def create_receiving(function_exports, tag_exports, library_symbols):

receiving.append('\nfunction assignWasmExports(wasmExports) {')
for sym, sig in exports.items():
is_function = sig is not None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure how Emscripten is currently handling tags, but at least in wasm, tags have signatures too (the return value is void and the arguments are the payload type). In C++ we only use i32-payload tags, and maybe that's fine for Emscripten, but if we want this linking method to be fully general it should handle other tag types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exports map only stores signatures for functions (since we don't care about tag signatures here)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(See the = None assignment above)

mangled = asmjs_mangle(sym)
if generate_dyncall_assignment and sym.startswith('dynCall_'):
if generate_dyncall_assignment and is_function and sym.startswith('dynCall_'):
sig_str = sym.replace('dynCall_', '')
dynCallAssignment = f"dynCalls['{sig_str}'] = "
else:
dynCallAssignment = ''
export_assignment = ''
if (settings.MODULARIZE or not settings.MINIMAL_RUNTIME) and should_export(mangled) and settings.MODULARIZE != 'instance':
export_assignment = f"Module['{mangled}'] = "
if install_debug_wrapper(sym):
if is_function and install_debug_wrapper(sym):
nargs = len(sig.params)
receiving.append(f" {export_assignment}{dynCallAssignment}{mangled} = createExportWrapper('{sym}', {nargs});")
else:
Expand All @@ -1010,8 +1009,6 @@ def create_module(metadata, function_exports, global_exports, tag_exports, libra
if settings.WASM_ESM_INTEGRATION:
module.append(sending)
else:
module.append(create_other_export_declarations(tag_exports))

if settings.PTHREADS or settings.WASM_WORKERS or (settings.IMPORTED_MEMORY and settings.MODULARIZE == 'instance'):
sending = textwrap.indent(sending, ' ').strip()
module.append('''\
Expand Down