# wasm-ld: Append \`\-\-stack-first\` by default · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/975049e96e2245022a90368360fe7f3617e5f194)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 975049e96e2245022a90368360fe7f3617e5f194

Requested commit: 975049e96e2245022a90368360fe7f3617e5f194

Commit: 975049e96e2245022a90368360fe7f3617e5f194

Tree: 3622e219db6c2ffa73f0541f4ec1fe101ab0cbb4

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm-ld: Append `--stack-first` by default

By placing the stack at the start of the memory section, we prevent the runtime
from silently overwriting the global declarations and instead trap.

We do however, allow users to overwrite this behavior by setting the global-base,
which puts the stack at the end of the memory section and the static data at the base that was specified.
The reason a user would want to do this, is when they are sure the stack will not overflow and they want
to decrease the binary size as the offsets to the static memory are generally smaller.
(Having the stack in front, means that accessing the memory after the stack has a bigger offset when loading/storing from memory).

```

## Parents

- [f767f8e3dc158a74debdd288884458b860d2ebc9](https://git.cafe/gitcafe/zig/commit/f767f8e3dc158a74debdd288884458b860d2ebc9?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/975049e96e2245022a90368360fe7f3617e5f194?format=markdown)
