Skip to content

Commit 7c1d7ea

Browse files
authored
Remove wasm-emscripten-finalize metadata extraction method (#16529)
The python method has been the default now since 3.1.15. We had one bug report which was fixed so I think we can now safely remove the old path.
1 parent 400165b commit 7c1d7ea

File tree

3 files changed

+4
-70
lines changed

3 files changed

+4
-70
lines changed

.circleci/config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,6 @@ jobs:
356356
test_targets: "posixtest"
357357
test-core0:
358358
executor: bionic
359-
# Temporarily set EMCC_READ_METADATA to compare to ensure that the python
360-
# can marches precisely the output wasm-emscripten-finalize.
361-
environment:
362-
EMCC_READ_METADATA: "compare"
363359
steps:
364360
- run-tests-linux:
365361
test_targets: "core0"

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.19
2222
------
23+
- Old method of metadata extraction via wasm-emscripten-finalize removed
24+
in favor of local python code. (#16529)
2325

2426
3.1.18 - 08/01/2022
2527
-------------------

emscripten.py

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,7 @@ def remove_trailing_zeros(memfile):
434434

435435

436436
@ToolchainProfiler.profile()
437-
def get_metadata_binaryen(infile, outfile, modify_wasm, args):
438-
stdout = building.run_binaryen_command('wasm-emscripten-finalize',
439-
infile=infile,
440-
outfile=outfile if modify_wasm else None,
441-
args=args,
442-
stdout=subprocess.PIPE)
443-
metadata = load_metadata_json(stdout)
444-
return metadata
445-
446-
447-
@ToolchainProfiler.profile()
448-
def get_metadata_python(infile, outfile, modify_wasm, args):
437+
def get_metadata(infile, outfile, modify_wasm, args):
449438
metadata = extract_metadata.extract_metadata(infile)
450439
if modify_wasm:
451440
# In some cases we still need to modify the wasm file
@@ -554,30 +543,7 @@ def finalize_wasm(infile, outfile, memfile):
554543
if settings.DEBUG_LEVEL >= 3:
555544
args.append('--dwarf')
556545

557-
# Currently we have two different ways to extract the metadata from the
558-
# wasm binary:
559-
# 1. via wasm-emscripten-finalize (binaryen)
560-
# 2. via local python code
561-
# We also have a 'compare' mode that runs both extraction methods and
562-
# checks that they produce identical results.
563-
read_metadata = os.environ.get('EMCC_READ_METADATA', 'python')
564-
if read_metadata == 'binaryen':
565-
metadata = get_metadata_binaryen(infile, outfile, modify_wasm, args)
566-
elif read_metadata == 'python':
567-
metadata = get_metadata_python(infile, outfile, modify_wasm, args)
568-
elif read_metadata == 'compare':
569-
shutil.copy2(infile, infile + '.bak')
570-
if settings.GENERATE_SOURCE_MAP:
571-
shutil.copy2(infile + '.map', infile + '.map.bak')
572-
pymetadata = get_metadata_python(infile, outfile, modify_wasm, args)
573-
shutil.move(infile + '.bak', infile)
574-
if settings.GENERATE_SOURCE_MAP:
575-
shutil.move(infile + '.map.bak', infile + '.map')
576-
metadata = get_metadata_binaryen(infile, outfile, modify_wasm, args)
577-
compare_metadata(metadata, pymetadata)
578-
else:
579-
assert False
580-
546+
metadata = get_metadata(infile, outfile, modify_wasm, args)
581547
if modify_wasm:
582548
building.save_intermediate(infile, 'post_finalize.wasm')
583549
elif infile != outfile:
@@ -899,36 +865,6 @@ def create_module(sending, receiving, invoke_funcs, metadata):
899865
return module
900866

901867

902-
def load_metadata_json(metadata_raw):
903-
try:
904-
metadata_json = json.loads(metadata_raw)
905-
except Exception:
906-
logger.error('emscript: failure to parse metadata output from wasm-emscripten-finalize. raw output is: \n' + metadata_raw)
907-
raise
908-
909-
metadata = {
910-
'declares': [],
911-
'globalImports': [],
912-
'exports': [],
913-
'namedGlobals': {},
914-
'emJsFuncs': {},
915-
'asmConsts': {},
916-
'invokeFuncs': [],
917-
'features': [],
918-
'mainReadsParams': 1,
919-
}
920-
921-
for key, value in metadata_json.items():
922-
if key not in metadata:
923-
exit_with_error('unexpected metadata key received from wasm-emscripten-finalize: %s', key)
924-
metadata[key] = value
925-
926-
if DEBUG:
927-
logger.debug("Metadata parsed: " + pprint.pformat(metadata))
928-
929-
return metadata
930-
931-
932868
def create_invoke_wrappers(invoke_funcs):
933869
"""Asm.js-style exception handling: invoke wrapper generation."""
934870
invoke_wrappers = ''

0 commit comments

Comments
 (0)