emscripten-core / emscripten-core/emscripten

INITIAL_MEMORY error when trying to set MAXIMUM_MEMORY

Open
#23,211 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.73 (https://github.com/emscripten-core/emscripten/commit/ac676d5e437525d15df5fd46bc2c208ec6d376a3)

**Issue**
When trying to allocate maximal initial memory, there is an error:
`em++: error: MAXIMUM_MEMORY cannot be less than INITIAL_MEMORY`

As I've inspected the code behind, it's due to the fact that INITIAL_MEMORY can be incremented withing the `link.py -> inc_initial_memory` which is quite a big increment in case of `-phtread` and `-fsanitize=address`, which is my case.

Can we make this more user friendly? Maybe some kind of check that it's capped to MAXIMUM_MEMORY.

**Failing command line in full:**
```cpp
// cat main.cpp
int main() {
return 0;
}
```

```
em++ main.cpp -o main.html -stdlib=libc++ -fsanitize=address -pthread -sSHARED_MEMORY=1 -sINITIAL_MEMORY=4288413696 -sMAXIMUM_MEMORY=4294967296 -sALLOW_MEMORY_GROWTH=1

em++: warning: -pthread + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271 [-Wpthreads-mem-growth]
(print from link.py) INITIAL_MEMORY 4902027264
(print from link.py) MAXIMUM_MEMORY 4294967296
em++: error: MAXIMUM_MEMORY cannot be less than INITIAL_MEMORY
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.