Skip to content

Commit bc78a3c

Browse files
authored
Don't generate js output is final output is wasm file (#12196)
This mostly effect WASM_STANDALONE mode since we already had an early return in place for SIDE_MODULE.
1 parent 14bd2e2 commit bc78a3c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

emcc.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,24 @@ def get_final():
21712171
open(final + '.mem.js', 'w').write(src)
21722172
final += '.mem.js'
21732173

2174+
log_time('memory initializer')
2175+
2176+
with ToolchainProfiler.profile_block('binaryen'):
2177+
do_binaryen(target, options, memfile, wasm_target,
2178+
wasm_source_map_target, misc_temp_files)
2179+
2180+
log_time('binaryen')
2181+
# If we are not emitting any JS then we are all done now
2182+
if shared.Settings.SIDE_MODULE or final_suffix in WASM_ENDINGS:
2183+
return
2184+
2185+
with ToolchainProfiler.profile_block('final emitting'):
2186+
# Remove some trivial whitespace
2187+
# TODO: do not run when compress has already been done on all parts of the code
2188+
# src = open(final).read()
2189+
# src = re.sub(r'\n+[ \n]*\n+', '\n', src)
2190+
# open(final, 'w').write(src)
2191+
21742192
if shared.Settings.USE_PTHREADS:
21752193
target_dir = os.path.dirname(os.path.abspath(target))
21762194
worker_output = os.path.join(target_dir, shared.Settings.PTHREAD_WORKER_FILE)
@@ -2182,24 +2200,9 @@ def get_final():
21822200
minified_worker = building.acorn_optimizer(worker_output, ['minifyWhitespace'], return_output=True)
21832201
open(worker_output, 'w').write(minified_worker)
21842202

2185-
log_time('js opts')
2186-
2187-
with ToolchainProfiler.profile_block('final emitting'):
2188-
# Remove some trivial whitespace
2189-
# TODO: do not run when compress has already been done on all parts of the code
2190-
# src = open(final).read()
2191-
# src = re.sub(r'\n+[ \n]*\n+', '\n', src)
2192-
# open(final, 'w').write(src)
2193-
21942203
# track files that will need native eols
21952204
generated_text_files_with_native_eols = []
21962205

2197-
do_binaryen(target, options, memfile, wasm_target,
2198-
wasm_source_map_target, misc_temp_files)
2199-
# If we are building a wasm side module then we are all done now
2200-
if shared.Settings.SIDE_MODULE:
2201-
return
2202-
22032206
if shared.Settings.MODULARIZE:
22042207
modularize()
22052208

@@ -2228,8 +2231,6 @@ def get_final():
22282231

22292232
if final_suffix in JS_ENDINGS:
22302233
js_target = target
2231-
elif final_suffix in WASM_ENDINGS:
2232-
js_target = misc_temp_files.get(suffix='.js').name
22332234
else:
22342235
js_target = unsuffixed(target) + '.js'
22352236

0 commit comments

Comments
 (0)