Skip to content

Commit f42831e

Browse files
committed
Fix wasm2.test_no_declare_asm_module_exports
1 parent 99d7f4d commit f42831e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

emscripten.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,8 @@ def create_receiving(function_table_data, function_tables_defs, exported_impleme
17201720
''' % {'name': name, 'runtime_assertions': runtime_assertions})
17211721
receiving = '\n'.join(wrappers)
17221722

1723-
shared.Settings.MODULE_EXPORTS = module_exports = exported_implemented_functions + function_tables(function_table_data)
1723+
module_exports = exported_implemented_functions + function_tables(function_table_data)
1724+
shared.Settings.MODULE_EXPORTS = [(f, f) for f in exports]
17241725

17251726
if not shared.Settings.SWAPPABLE_ASM_MODULE:
17261727
if shared.Settings.DECLARE_ASM_MODULE_EXPORTS:
@@ -2243,9 +2244,9 @@ def emscript_wasm_backend(infile, outfile, memfile, compiler_engine,
22432244

22442245
exports = metadata['exports']
22452246

2246-
# Store exports for Closure copmiler to be able to track these as globals in
2247+
# Store exports for Closure compiler to be able to track these as globals in
22472248
# -s DECLARE_ASM_MODULE_EXPORTS=0 builds.
2248-
shared.Settings.MODULE_EXPORTS = [f for f in exports]
2249+
shared.Settings.MODULE_EXPORTS = [(asmjs_mangle(f), f) for f in exports]
22492250

22502251
if shared.Settings.ASYNCIFY:
22512252
exports += ['asyncify_start_unwind', 'asyncify_stop_unwind', 'asyncify_start_rewind', 'asyncify_stop_rewind']

tools/shared.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,7 +2472,7 @@ def closure_compiler(filename, pretty=True, advanced=True, extra_closure_args=[]
24722472
# externs file for the exports, Closure is able to reason about the exports.
24732473
if Settings.MODULE_EXPORTS and not Settings.DECLARE_ASM_MODULE_EXPORTS:
24742474
# Generate an exports file that records all the exported symbols from asm.js/wasm module.
2475-
module_exports_suppressions = '\n'.join(['/**\n * @suppress {duplicate, undefinedVars}\n */\nvar %s;\n' % i for i in Settings.MODULE_EXPORTS])
2475+
module_exports_suppressions = '\n'.join(['/**\n * @suppress {duplicate, undefinedVars}\n */\nvar %s;\n' % i for i,j in Settings.MODULE_EXPORTS])
24762476
exports_file = configuration.get_temp_files().get('_module_exports.js')
24772477
exports_file.write(module_exports_suppressions.encode())
24782478
exports_file.close()
@@ -2584,7 +2584,7 @@ def metadce(js_file, wasm_file, minify_whitespace, debug_info):
25842584
logger.debug('running meta-DCE')
25852585
temp_files = configuration.get_temp_files()
25862586
# first, get the JS part of the graph
2587-
extra_info = '{ "exports": [' + ','.join(map(lambda x: '["' + (asmjs_mangle(x) if Settings.WASM_BACKEND else x) + '","' + x + '"]', Settings.MODULE_EXPORTS)) + ']}'
2587+
extra_info = '{ "exports": [' + ','.join(map(lambda x: '["' + x[0] + '","' + x[1] + '"]', Settings.MODULE_EXPORTS)) + ']}'
25882588
txt = Building.acorn_optimizer(js_file, ['emitDCEGraph', 'noPrint'], return_output=True, extra_info=extra_info)
25892589
graph = json.loads(txt)
25902590
# add exports based on the backend output, that are not present in the JS
@@ -2593,7 +2593,7 @@ def metadce(js_file, wasm_file, minify_whitespace, debug_info):
25932593
for item in graph:
25942594
if 'export' in item:
25952595
exports.add(item['export'])
2596-
for export in Settings.MODULE_EXPORTS:
2596+
for export, unminified in Settings.MODULE_EXPORTS:
25972597
if export not in exports:
25982598
graph.append({
25992599
'export': export,

0 commit comments

Comments
 (0)