Skip to content

Commit c7d4255

Browse files
authored
MINIMAL_RUNTIME: Remove the need for WASM_MODULE_EXPORTS_DECLARES. NFC (#23403)
In MINIMAL_RUNTIME we had extra replacements that were doing for declaring and assigned wasm exports: - WASM_MODULE_EXPORTS_DECLARES - WASM_MODULE_EXPORTS This change avoids the need for the first of these by instead modifying the `receiving`.
1 parent 1ce7ff5 commit c7d4255

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/postamble_minimal.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ var wasmExports;
9292
var wasmModule;
9393
#endif
9494

95-
#if DECLARE_ASM_MODULE_EXPORTS
96-
<<< WASM_MODULE_EXPORTS_DECLARES >>>
97-
#endif
98-
9995
#if PTHREADS
10096
function loadModule() {
10197
assignWasmImports();

tools/emscripten.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ def compute_minimal_runtime_initializer_and_exports(post, exports, receiving):
5858
# way that minifies well with Closure
5959
# e.g. var a,b,c,d,e,f;
6060

61-
exports = [asmjs_mangle(x) for x in exports if x != building.WASM_CALL_CTORS]
62-
63-
declares = 'var ' + ',\n '.join(exports) + ';'
64-
post = shared.do_replace(post, '<<< WASM_MODULE_EXPORTS_DECLARES >>>', declares)
65-
66-
# Generate assignments from all wasm exports out to the JS variables above: e.g. a = wasmExports['a']; b = wasmExports['b'];
61+
# `receiving` contains all of the assignments from wasm exports to
62+
# global JS variables: e.g. a = wasmExports['a']; b = wasmExports['b'];
6763
post = shared.do_replace(post, '<<< WASM_MODULE_EXPORTS >>>', receiving)
68-
return post
64+
65+
exports = [asmjs_mangle(x) for x in exports if x != building.WASM_CALL_CTORS]
66+
receiving = 'var ' + ',\n '.join(exports) + ';'
67+
return post, receiving
6968

7069

7170
def write_output_file(outfile, module):
@@ -462,8 +461,9 @@ def emscript(in_wasm, out_wasm, outfile_js, js_syms, finalize=True, base_metadat
462461

463462
if settings.MINIMAL_RUNTIME:
464463
if settings.DECLARE_ASM_MODULE_EXPORTS:
465-
post = compute_minimal_runtime_initializer_and_exports(post, function_exports, receiving)
466-
receiving = ''
464+
post, receiving = compute_minimal_runtime_initializer_and_exports(post, function_exports, receiving)
465+
else:
466+
receiving = ''
467467

468468
module = create_module(receiving, metadata, global_exports, forwarded_json['librarySymbols'])
469469

0 commit comments

Comments
 (0)