Skip to content

Commit dcde704

Browse files
authored
Emit binary straight from asm2wasm. create a text wast only if necessary (#4889)
* emit binary straight from asm2wasm. create a text wast only if necessary * update binaryen to version_26
1 parent 0ca77c7 commit dcde704

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

emcc.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,26 +2124,27 @@ def do_minify(): # minifies the code. this is also when we do certain optimizati
21242124
cmd += ['--mem-max=' + str(shared.Settings.BINARYEN_MEM_MAX)]
21252125
if shared.Building.is_wasm_only():
21262126
cmd += ['--wasm-only'] # this asm.js is code not intended to run as asm.js, it is only ever going to be wasm, an can contain special fastcomp-wasm support
2127+
if debug_level >= 2 or profiling_funcs:
2128+
cmd += ['-g']
2129+
if emit_symbol_map or shared.Settings.CYBERDWARF:
2130+
cmd += ['--symbolmap=' + target + '.symbols']
2131+
cmd += ['-o', wasm_binary_target]
21272132
logging.debug('asm2wasm (asm.js => WebAssembly): ' + ' '.join(cmd))
21282133
TimeLogger.update()
2129-
subprocess.check_call(cmd, stdout=open(wasm_text_target, 'w'))
2134+
subprocess.check_call(cmd)
21302135
if import_mem_init:
21312136
# remove and forget about the mem init file in later processing; it does not need to be prefetched in the html, etc.
21322137
os.unlink(memfile)
21332138
memory_init_file = False
21342139
log_time('asm2wasm')
21352140
if shared.Settings.BINARYEN_PASSES:
2136-
shutil.move(wasm_text_target, wasm_text_target + '.pre')
2137-
cmd = [os.path.join(binaryen_bin, 'wasm-opt'), wasm_text_target + '.pre', '-o', wasm_text_target] + map(lambda p: '--' + p, shared.Settings.BINARYEN_PASSES.split(','))
2141+
shutil.move(wasm_binary_target, wasm_binary_target + '.pre')
2142+
cmd = [os.path.join(binaryen_bin, 'wasm-opt'), wasm_binary_target + '.pre', '-o', wasm_binary_target] + map(lambda p: '--' + p, shared.Settings.BINARYEN_PASSES.split(','))
21382143
logging.debug('wasm-opt on BINARYEN_PASSES: ' + ' '.join(cmd))
21392144
subprocess.check_call(cmd)
2140-
if 'native-wasm' in shared.Settings.BINARYEN_METHOD or 'interpret-binary' in shared.Settings.BINARYEN_METHOD:
2141-
cmd = [os.path.join(binaryen_bin, 'wasm-as'), wasm_text_target, '-o', wasm_binary_target]
2142-
if debug_level >= 2 or profiling_funcs:
2143-
cmd += ['-g']
2144-
if emit_symbol_map or shared.Settings.CYBERDWARF:
2145-
cmd += ['--symbolmap=' + target + '.symbols']
2146-
logging.debug('wasm-as (text => binary): ' + ' '.join(cmd))
2145+
if 'interpret-s-expr' in shared.Settings.BINARYEN_METHOD:
2146+
cmd = [os.path.join(binaryen_bin, 'wasm-dis'), wasm_binary_target, '-o', wasm_text_target]
2147+
logging.debug('wasm-dis (binary => text): ' + ' '.join(cmd))
21472148
subprocess.check_call(cmd)
21482149
if shared.Settings.BINARYEN_SCRIPTS:
21492150
binaryen_scripts = os.path.join(shared.Settings.BINARYEN_ROOT, 'scripts')

tools/ports/binaryen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, shutil, logging
22

3-
TAG = 'version_25'
3+
TAG = 'version_26'
44

55
def needed(settings, shared, ports):
66
if not settings.BINARYEN: return False

0 commit comments

Comments
 (0)