Skip to content
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

[wasm-ld] How to specify a non-growable memory without --initial-memory and --max-memory #81932

Closed
sbc100 opened this issue Feb 15, 2024 · 1 comment · Fixed by #82890
Closed
Labels

Comments

@sbc100
Copy link
Collaborator

sbc100 commented Feb 15, 2024

Until recently the way to specify a non-growable memory was to specify both --initial-memory and --max-memory and set them to the same value. This is what emscripten currently does by default unless you opt into -sALLOW_MEMORY_GROWTH.

However, we recently added a new --initial-heap flag which allows the user to set and initial heap size and have the linker then derive the initial memory size based on the sum of stack size + heap size + static data size. See #75594.

When attempting to start using this flag in emscripten we discovered that there is no way to use the --initial-heap flag and still get a non-growable memory. See https://github.com/emscripten-core/emscripten/pull/21071/files#r1491731562.

It seems that we need some kind of flag like the existing --growable-table flag. It would be nice to add --growable-memory except that would mean changing the default to non-growable, which is perhaps too much of a breaking change. @sunfishcode WDYT?

Instead perhaps we can add --no-growable-memory?

Perhaps the existing --growable-table flag could also take a no- prefix so that they were symmetrical?

@EugeneZelenko EugeneZelenko added question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! lld:wasm and removed new issue labels Feb 15, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 15, 2024

@llvm/issue-subscribers-lld-wasm

Author: Sam Clegg (sbc100)

Until recently the way to specify a non-growable memory was to specify both `--initial-memory` and `--max-memory` and set them to the same value. This is what emscripten currently does by default unless you opt into `-sALLOW_MEMORY_GROWTH`.

However, we recently added a new --initial-heap flag which allows the user to set and initial heap size and have the linker then derive the initial memory size based on the sum of stack size + heap size + static data size. See #75594.

When attempting to start using this flag in emscripten we discovered that there is no way to use the --initial-heap flag and still get a non-growable memory. See https://github.com/emscripten-core/emscripten/pull/21071/files#r1491731562.

It seems that we need some kind of flag like the existing --growable-table flag. It would be nice to add --growable-memory except that would mean changing the default to non-growable, which is perhaps too much of a breaking change. @sunfishcode WDYT?

Instead perhaps we can add --no-growable-memory?

Perhaps the existing --growable-table flag could also take a no- prefix so that they were symmetrical?

sbc100 pushed a commit that referenced this issue Feb 25, 2024
We recently added `--initial-heap` - an option that allows one to up the
initial memory size without the burden of having to know exactly how
much is needed.

However, in the process of implementing support for this in Emscripten
(emscripten-core/emscripten#21071), we have
realized that `--initial-heap` cannot support the use-case of
non-growable memories by itself, since with it we don't know what to set
`--max-memory` to.

We have thus agreed to move the above work forward by introducing
another option to the linker (see
emscripten-core/emscripten#21071 (comment)),
one that would allow users to explicitly specify they want a
non-growable memory.

This change does this by introducing `--no-growable-memory`: an option
that is mutally exclusive with `--max-memory` (for simplicity - we can
also decide that it should override or be overridable by `--max-memory`.
In Emscripten a similar mix of options results in `--no-growable-memory`
taking precedence). The option specifies that the maximum memory size
should be set to the initial memory size, effectively disallowing memory
growth.

Closes #81932.
@EugeneZelenko EugeneZelenko removed the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants