-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Best practices for Module['buffer']? #18474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think that's right but @sbc100 might be aware of something I forgot. Note that you also need |
Agreed, I would have thought you wouldn't actually need this at all, unless
you explicitly opt into `-sIMPORTED_MEMORY`.
In the default configuration the memory should be created by the wasm (or
the transpiles wasm2js) automatically.
Did you have code that used to work prior to #18454 and/or #18452? If so,
can you share what it looked like exactly? I'd like to avoid breaking
folks if we can.
|
Other way around, actually -- no working examples. I was trying to figure out why graaljs kept insisting that memory.buffer was undefined, which led me to try providing an imported one, assuming the issue was one of me using the wrong flags or needing to stick some pre-js in. Based on #18452 I tried replacing the uses of env.memory and memory.buffer inside the generated -O0 code itself with a direct usage of Memory['wasmMemory'] and it loaded successfully with graal, at least with emscripten 3.1.24 (stuck there for now because of LLVM 14). I've gone ahead and backported #18452 and #18454 locally and anything else that touched |
Problem solved. #18452 and #18454 indeed solve the problem, suggesting that this is similar to #17842. That wasn't clear to me yesterday because in trying to debug I'd added 'wasmMemory' to |
Moving WebAssembly/binaryen#5390 here.
New emscripten-specific question
It looks like my attempts to use
Module['buffer']
in pre-js are ill-advised, per #18452. For environments without WebAssembly, what is the preferred method to pass an external ArrayBuffer?I suppose I'd be happy to use the internal glue code's mechanism as well, but something about the graaljs environment seems unable right now to create a
memory
orwasmMemory
object on its own to emscripten's satisfaction. That said, I can absolutely confirm that I can createArrayBuffer
s, and that they seem truthy enough on an ad-hoc basis.Original text from binaryen issue
In attempting to load a wasm2js-generated js file on graaljs, I hit the following error:
It's referring to these lines in the transpiled js, implying that the env.memory section is undefined.
This error occurs when using the shell environment, which I suppose graal isn't, but running the transpilation without setting an env fails with
Aborted(Assertion failed: shell environment detected but not enabled at build time. Add 'shell' to
-sENVIRONMENTto enable.)
Should I be using a different environment, does this mean that the shell environment needs something else to generate a
WebAssembly.Memory
, or does there need to be an entirely new graal environment?The text was updated successfully, but these errors were encountered: