Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am trying to link a C++ library compiled with Emscripten to a Blazor wasm application, and use pinvoke. Thus far, the only way to link the two is to use static linking via NativeFileReference, but emcc contains functionality to dynamically link side modules and a main module.
Comparing the generated JS in an app where both the lib and main app are written in C++ to one with Blazor Wasm and NativeFileReference, it seems that the code responsible for loading the functions into the Module object is missing, thus when the app tries to call them when they are uninitialized and abort is called and the whole thing breaks.
Trying a different approach of statically linking a part of the C++ code containing C wrapper functions that are PInvoked and dynamically linking the C++ class that is wrapped, the same issue happened after the C function reached a function call.
Describe the solution you'd like
NativeFileReference other than accepting relocatable wasm files for static linking, would accept native libs compiled with Emscripten's SIDE_MODULE flag and expand the generated javascript to load them at loadtime.
Additional context
https://github.com/Devsh-Graphics-Programming/GPU-With-C-Sharp-Angular-WASM
Thus far this app is on the small end, but we are considering making a robust native wasm library that contains the Nabla engine. For that dynamic linking is preferable.
Emscripten doc
https://emscripten.org/docs/compiling/Dynamic-Linking.html
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am trying to link a C++ library compiled with Emscripten to a Blazor wasm application, and use pinvoke. Thus far, the only way to link the two is to use static linking via
NativeFileReference, but emcc contains functionality to dynamically link side modules and a main module.Comparing the generated JS in an app where both the lib and main app are written in C++ to one with Blazor Wasm and
NativeFileReference, it seems that the code responsible for loading the functions into theModuleobject is missing, thus when the app tries to call them when they are uninitialized andabortis called and the whole thing breaks.Trying a different approach of statically linking a part of the C++ code containing C wrapper functions that are PInvoked and dynamically linking the C++ class that is wrapped, the same issue happened after the C function reached a function call.
Describe the solution you'd like
NativeFileReferenceother than accepting relocatable wasm files for static linking, would accept native libs compiled with Emscripten's SIDE_MODULE flag and expand the generated javascript to load them at loadtime.Additional context
https://github.com/Devsh-Graphics-Programming/GPU-With-C-Sharp-Angular-WASM
Thus far this app is on the small end, but we are considering making a robust native wasm library that contains the Nabla engine. For that dynamic linking is preferable.
Emscripten doc
https://emscripten.org/docs/compiling/Dynamic-Linking.html