From ab34a779552ea4a8747e7729433d8c7f89c458c0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 1 Jul 2019 16:46:08 -0400 Subject: Workaround for wasm2js output minification issue with emscripten (#2185) * Workaround for wasm2js output minification issue with emscripten When using emscripten with -O2 and --memory-init-file 0, the JS minification breaks on this function for memory initialization setup, causing an exception to be thrown during module setup. Moving from two 'var' declarations for the same variable to one should avoid hitting this with no change in functionality (the var gets hoisted anyway). https://github.com/emscripten-core/emscripten/issues/8886 --- src/wasm2js.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wasm2js.h b/src/wasm2js.h index a14aad2a4..d01a2dcd7 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -2146,12 +2146,13 @@ void Wasm2JSGlue::emitMemory( function(mem) { var _mem = new Uint8Array(mem); return function(offset, s) { + var bytes; if (typeof Buffer === 'undefined') { - var bytes = atob(s); + bytes = atob(s); for (var i = 0; i < bytes.length; i++) _mem[offset + i] = bytes.charCodeAt(i); } else { - var bytes = Buffer.from(s, 'base64'); + bytes = Buffer.from(s, 'base64'); for (var i = 0; i < bytes.length; i++) _mem[offset + i] = bytes[i]; } -- cgit v1.2.3