chiark / gitweb /
Set ALLOW_MEMORY_GROWTH in the Emscripten build.
authorSimon Tatham <anakin@pobox.com>
Fri, 16 Apr 2021 17:07:15 +0000 (18:07 +0100)
committerSimon Tatham <anakin@pobox.com>
Fri, 16 Apr 2021 17:07:15 +0000 (18:07 +0100)
How embarrassing. When I updated the Emscripten build to use WASM, a
major reason I bothered to do it at all was that I'd heard that WASM
was capable of reallocating its memory arena larger on the fly. Turns
out that it _can_, but only if you specifically set the option in
Emscripten to allow it.

With this option set, I can finish a 25x25 Galaxies, where previously
the game would crash part way through (and not even a very large part)
with errors about memory growth in the Javascript console.

cmake/platforms/emscripten.cmake

index 89223a55b97f9d7879345dc9b25cb2b5260aeb27..bbb0897aaa2c84fbd24c25c881fda7bc869e7ed3 100644 (file)
@@ -30,6 +30,7 @@ list(TRANSFORM emcc_export_list PREPEND \")
 list(TRANSFORM emcc_export_list APPEND \")
 string(JOIN "," emcc_export_string ${emcc_export_list})
 set(CMAKE_C_LINK_FLAGS "\
+-s ALLOW_MEMORY_GROWTH=1 \
 -s EXPORTED_FUNCTIONS='[${emcc_export_string}]' \
 -s EXTRA_EXPORTED_RUNTIME_METHODS='[cwrap,callMain]'")