New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wasm] Add support for P/Invoke through dynamic linking #14259
Conversation
So this PR can't be merged as-is because of the dlopen call that I included, which makes emscripten call abort when To be able to have an optional runtime, and avoid having to do
I'll make some tests to determine the size of |
We already have a pinvoke callback in driver.c called wasm_dl_load ()/wasm_dl_symbol () maybe the dlopen() etc. can be added there. |
Well, adding MAIN_MODULE=1 makes mono.wasm release go from 1.8MB to 2.6MB, so that's not an option. I'll look for altering the driver, and most probably build it for each configuration to alter dlopen's behavior. |
@vargaz would something like this be acceptable ? mono_dl_fallback_register (gboolean allow_dlopen, MonoDlFallbackLoad load_func, MonoDlFallbackSymbol symbol_func, MonoDlFallbackClose close_func, void *user_data) so dlopen is controled from there, or another method that would be in |
Can't wasm_dl_load () in driver.c call dlopen () if some define is set ? |
Ah I see. You'd redirect dlopen from there, I'll try that, thanks! |
I need to make another change to avoid dlopen ordering issues. |
The Linux WebAssembly tests did not pass because they ran out of time (20 minutes). They pass locally on my machine in a container built using the same parameters the CI uses, in 13 minutes. Could it be that the build machine running it is too slow now that the number of tests has grown and that the timeouts should be larger ? |
@monojenkins build failed |
1 similar comment
@monojenkins build failed |
Good, the wasm test suite passed, the android one is an app crash on android with debugger test suite it seems. |
@monojenkins build OS X x64 Android SDK |
@monojenkins build failed |
@jeromelaban unfortunately this was stuck while I landed the m2n changes. Can you rebase and regenerate? |
This will avoid emscripten to call abort() because MAIN_MODULE is not defined.
e358d9d
to
ff4839d
Compare
Thanks for the notice. FWIW, your m2n changes may have a positive performance impact for dllimport calls. Trampolines are called very often, particularly in sqlite and skia. |
Thanks for the update! Yeah, it turns out the m2n stuff had measurable impact in several cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thank you.
@monojenkins build Linux AArch64 Interpreter |
@monojenkins build Linux x64 Interpreter |
@monojenkins build OS X x64 iOS SDK |
release-dynamic
which includes-s MAIN_MODULE=1
and-s EXPORT_ALL=1
based on emscripten's linking docs. This is a new configuration to avoid paying the additional cost of exporting all symbols. The runtime goes from 1.8MB to 3.6MB with these options.dynamicLibraries
, e.g.Module.dynamicLibraries = ['./canvaskit.wasm']
System.Native
is worked-around explicitly for now.