emscripten-core / emscripten-core/emscripten
Splitting WASI into side modules, dynamic linking
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
As it is currently, it seems that applications using dynamic linking are required to place all library code (WASI) to the main module, which then exports functions for the dynamically linked modules.
However, is there any way currently to split WASI into different dynamically loadable modules?
If not, is this something that could be even considered? I see WASI itself has some [discussion and changes](https://github.com/WebAssembly/WASI/pull/98) related to modularity, however, it is unclear if it would allow the implementation to be split into dynamically loaded modules like this.
For example, could I somehow have `strcmp` and `rand` be implemented and exported in a side module? Currently trying to use the functions in side modules results in them being imported.
```C
void main() {
void* str_lib = dlopen("string_lib");
void* rand_lib = dlopen("rand_lib");
int (*rand)(void) = dlsym(rand_lib, "rand");
int (*strcmp)(const char * str1, const char * str2) = dlsym(str_lib, "strcmp");
}
```
```C
// string_lib; implement and export
int strcmp ( const char * str1, const char * str2 );
```
```C
// rand_lib; implement and export
int rand(void);
```
Contributor guide
Assessment
This issue has not been assessed yet.