emscripten-core / emscripten-core/emscripten
combining -WASM=0 and --memory-init-file 1 breaks lembind bindings
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
**Version of emscripten/emsdk:**
Please include the output `emcc -v` here
emsdk:3.1.24
emsdk:3.1.34
**Failing command line in full:**
```bash
emcc src/file.cpp \
--pre-js src/worker.js \
-s TEXTDECODER=2 \
-s WASM=0 \
-s ENVIRONMENT=worker \
-s NO_EXIT_RUNTIME=1 \
-lembind \
-s ALLOW_MEMORY_GROWTH=1 \
-s FILESYSTEM=0 \
-s AUTO_JS_LIBRARIES=0 \
-s AUTO_NATIVE_LIBRARIES=0 \
-s HTML5_SUPPORT_DEFERRING_USER_SENSITIVE_REQUESTS=0 \
-s USE_SDL=0 \
-s STRICT_JS=1 \
-s EXPORTED_FUNCTIONS="['_malloc']" \
-s MINIMAL_RUNTIME=1 \
-s MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION=1 \
-s INCOMING_MODULE_JS_API="[]" \
-O3
-o $@
```
**Describe the issue:**
When using -lembind, -WASM=0 and -O3, the O3 flag enables --memory-init-file 1 and breaks bindings by [I assume] removing all strings created by the bindings which at eval throws or by incorrectly reading the strings from the memory init file, forcing --memory-init-file 0 with -O3 enabled works fine
```
BindingError: Cannot register public name '' twice
```
as all bindings it tries to register are simply empty strings, to reproduce this simply create any 2 bindings using lembind
```cpp
EMSCRIPTEN_BINDINGS(bindings) {
emscripten::class_("ClassOne");
emscripten::class_("ClassTwo");
}
```
Contributor guide
Assessment
This issue has not been assessed yet.