Skip to content

Memory views in strict mode #22612

Closed Answered by sbc100
peterhirn asked this question in Q&A
Sep 24, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

In strict mode, for code size reasons, we only export what you ask for. You can export a given heap by adding it to -sEXPORTED_RUNTIME_METHODS.

See #21439

I debug builds I believe you should see an informative error if you try to access a heap that you didn't export. e.g.:

$ cat test.c 
#include <emscripten/emscripten.h>

int main() {
  EM_ASM(Module["HEAPF32"][100] = 0.1);
}
$ emcc test.c -sSTRICT
$ node ./a.out.js 
Aborted('HEAPF32' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ))
/usr/local/google/home/sbc/dev/wasm/emscripten/a.out.js:547
  var e = new WebAssembly.RuntimeError(what);
          ^

RuntimeError: Aborted('HEAPF32' was not exported. add it to …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@peterhirn
Comment options

Answer selected by peterhirn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants