emscripten-core / emscripten-core/emscripten

3.0.0 and later have incorrect embind pointers to names

Open
#16,170 10 comments 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.1 (1934a98e709b57d3592b8272d3f1264a72c089e4)
clang version 14.0.0 (https://github.com/llvm/llvm-project f142c45f1e494f8dbdcc1bcf14122d128ac8f3fe)
Target: wasm32-unknown-emscripten
Thread model: posix
```

Version 3.0.0 and later throws `"Cannot register public name '' twice"` at runtime using code that runs fine when compiled in 2.0.32 and 2.0.34. When stepping through the code with DWARF info, `__embind_register_function` for "readFile" shown below calls `readLatin1String` and retrieves "gle", possibly from "Angle" defined later. `readLatin1String` for "deleteFile" returns "Angle" and "saveToPrint" returns a snippet of source code. Eventually the incorrect names end up with a duplicate and execution stops.

Please advise if there's anything I can try to track down the root of the problem.

```C++
EMSCRIPTEN_BINDINGS(api)
{
// Functions
function("readFile", &ReadFile);
function("deleteFile", &DeleteFile);
function("saveToPrint", &SaveToPrint);
function("getDataLocation", &GetDataLocation);
function("getSettingsLocation", &GetSettingsLocation);
function("getAppController", &GetInstance);

// Enums
auto e1 = enum_("UnitType");
e1.value("Undefined", UnitType::Undefined);
e1.value("Angle", UnitType::Angle);
e1.value("Percent", UnitType::Percent);
```

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.