emscripten-core / emscripten-core/emscripten
emscripten::val::call in SIDE_MODULE fails with 'BindingError' unknown type 'N10emscripten3valE'
- 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.2 (a77b559a8b40b7e89fc8c17e41034128df9543e4)
clang version 14.0.0 (https://github.com/llvm/llvm-project 782c0dd1a1c235afb09a34e7da4a1267ead14765)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/derthorsten/src/emsdk/upstream/bin
```
When using `emscripten::val` in a `SIDE_MODULE` code like this:
```c++
emscripten::val obj = emscripten::val::global("some_object");
emscripten::val obj_b = emscripten::val::global("some_other_object");
emscripten::val res = obj.call("bind", obj_b);
```
fails with:
```
Uncaught (in promise) BindingError {name: 'BindingError', message: 'parameter 0 has unknown type N10emscripten3valE', stack: 'BindingError: parameter 0 has unknown type N10emsc…/lib_worker_js.e8cf5fed7a565fe8ca73.js:110:35742)'}
```
While using the same code in the main module works fine.
This seems to be the same issue as https://stackoverflow.com/questions/53397450/emscripten-and-dynamic-linking-how-to-link-with-embind.
A tiny bit of context:
I want this as a side Module since we are doing the following:
We are setting up a conda/mamba-based packaging system (ie smth like [conda-forge](https://conda-forge.org/)) for emscripten-packages. Atm this is called **[emscripten-forge](https://github.com/emscripten-forge/recipes)**.
Our main interest is to build python packages with emscripten (as **[pyodide](https://pyodide.org/en/stable/)** does, but we want to build/package everything with a conda based system).
I would like to have a tiny python package (ie a SIDE_MODULE) which contains "JavaScript-from-Python" functionality. This is mostly done by making the `emscripten::val` class available as a python class with **[pybind11](https://github.com/pybind/pybind11)**.
The code I have works well when I directly embed it in the MAIN_MODULE. But this means having the `Python-from-JavaScript` package must be directly included in my Python interpreter which I would like to avoid.
Happy for any suggestions!
Greetings Thorsten
Contributor guide
Assessment
This issue has not been assessed yet.