Skip to content

Commit 4fd2ad0

Browse files
authored
Re-export HEAP* views on Module for embedders (#76)
Recent Emscripten (>=3.1.x) makes the HEAP{,U}{8,16,32} TypedArray views module-local by default to help tree-shaking. The bundled simple.js (and any other code that embeds the Binjgb factory) reaches into module.HEAP8.buffer / module.HEAPU8 / etc. via makeWasmBuffer; with the new default those accesses are undefined and the first Emulator construction throws "Cannot read properties of undefined (reading 'buffer')" before the ROM even loads. Add an explicit EXPORTED_RUNTIME_METHODS list so the wasm build re-attaches these views to the Module object the way pre-3.1.x Emscripten did by default. Also gitignore the `emscripten` symlink that contributors create at the repo root per the README build instructions. docs/binjgb.{js,wasm} regenerated via `make demo` under Emscripten 5.0.7.
1 parent 9ff6e8a commit 4fd2ad0

4 files changed

Lines changed: 4 additions & 21 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/bin
22
/out
3+
/emscripten
34
/test/mooneye-gb
45
/test/mooneye-gb-wp
56
/third_party/wla-dx

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ else (EMSCRIPTEN)
161161

162162
set(LINK_FLAGS
163163
-s EXPORTED_FUNCTIONS=\"@${EXPORTED_JSON}\"
164+
-s EXPORTED_RUNTIME_METHODS=\"['HEAP8','HEAPU8','HEAP16','HEAPU16','HEAP32','HEAPU32','HEAPF32','HEAPF64']\"
164165
-s MALLOC=emmalloc
165166
-s ASSERTIONS=0
166167
-s ENVIRONMENT=web

0 commit comments

Comments
 (0)