By default, LLVM adopts this memory model:
| Globals | <-- Stack | Heap --> |++
This means when the stack runs out of space, it will start trampling over global memory before causing a stack overflow.
Appending --stack-first will flip where the stack and the globals are located, so stack overflow will error out immediately instead of corrupting globals.
Rust has made a similar decision: rustwasm/team#81 (comment)
By default, LLVM adopts this memory model:
This means when the stack runs out of space, it will start trampling over global memory before causing a stack overflow.
Appending
--stack-firstwill flip where the stack and the globals are located, so stack overflow will error out immediately instead of corrupting globals.Rust has made a similar decision: rustwasm/team#81 (comment)