-
Notifications
You must be signed in to change notification settings - Fork 758
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
Apply the sbrk/brk value at compile time #2366
Conversation
src/passes/PostEmscripten.cpp
Outdated
@@ -80,6 +81,23 @@ struct PostEmscripten : public Pass { | |||
func->body = builder.makeConst(Literal(int32_t(sbrkPtr))); | |||
func->module = func->base = Name(); | |||
} | |||
// Apply the sbrk ptr value, if it was provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good if this comment explained what it means to apply the sbrk ptr value. I'm still not sure why the value needs to be written into memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, added more text there now.
Emscripten side of WebAssembly/binaryen#2366 (that must roll first), this tells binaryen to set the value in the wasm binary, which fixes standalone wasm module's sbrk() usage (as normally we set this is JS). This also disables eval-ctors for the wasm backend, see #9527 , which made an incorrect assumption about the sbrk initial location - JS may modify it during startup, so we can't assume it's constant. This affects only -Oz so it's probably not many users. After this PR we should be correct in both standalone and non-standalone modes, and later we can look into re-enabling eval-ctors.
Emscripten side of WebAssembly/binaryen#2366 (that must roll first), this tells binaryen to set the value in the wasm binary, which fixes standalone wasm module's sbrk() usage (as normally we set this is JS). This also disables eval-ctors for the wasm backend, see emscripten-core#9527 , which made an incorrect assumption about the sbrk initial location - JS may modify it during startup, so we can't assume it's constant. This affects only -Oz so it's probably not many users. After this PR we should be correct in both standalone and non-standalone modes, and later we can look into re-enabling eval-ctors.
We've had an option to set the location of the sbrk ptr, but not the value. Applying the value as well is necessary for standalone wasm, as otherwise we set it in JS.