emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.79k stars 3.31k forks source link

Splitting WASI into side modules, dynamic linking #13566

Open Rochet2 opened 3 years ago

Rochet2 commented 3 years ago

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 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.

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");
}
// string_lib; implement and export
int strcmp ( const char * str1, const char * str2 );
// rand_lib; implement and export
int rand(void);
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.