-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Disable qcalls on wasm. Treat them as normal pinvokes. #43798
Conversation
@@ -34,6 +34,7 @@ | |||
<ItemGroup> | |||
<WasmPInvokeModule Include="libSystem.Native" /> | |||
<WasmPInvokeModule Include="libSystem.IO.Compression.Native" /> | |||
<WasmPInvokeModule Include="QCall" /> |
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.
Why is this needed?
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.
Because QCalls are implemented on the managed side as pinvokes with to the module 'QCall'.
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.
Wouldn't be better to handle that inside runtime?
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.
Wouldn't be better to handle that inside runtime?
We want to make it possible to remove the native code of pinvokes/qcalls that are not called anywhere in managed. If the runtime has an array of qcall functions, the native linker won't be able to drop them
@@ -154,6 +153,12 @@ private string GenPInvokeDecl(PInvoke pinvoke) | |||
{ | |||
var sb = new StringBuilder(); | |||
var method = pinvoke.Method; | |||
if (method.Name == "EnumCalendarInfo") { |
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.
There is a patch which adds a lot more of these so this won't work
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.
It's just intended as a temporary hack until that MetadataLoadContext bug is fixed though, so it might be fine for now? Unless you think that patch is landing soon.
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.
That patch landed yesterday so this does not work anymore
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.
catch NotSupportedException
and map to int
😬
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.
It looks like all the delegate* in that patch are in assemblies we don't support
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.
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: The "PInvokeTableGenerator" task failed unexpectedly.
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: System.Exception: The return type 'Interop+BOOL' of pinvoke callback method 'Interop+BOOL EnumCalendarInfoCallback(System.Char*, System.UInt32, System.IntPtr, System.Void*)' needs to be blittable.
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: at PInvokeTableGenerator.Error(String msg) in /Users/lewing/Source/runtime/tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 313
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: at PInvokeTableGenerator.EmitNativeToInterp(StreamWriter w, List`1 callbacks) in /Users/lewing/Source/runtime/tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 196
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: at PInvokeTableGenerator.GenPInvokeTable(String[] pinvokeModules, String[] assemblies) in /Users/lewing/Source/runtime/tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 53
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: at PInvokeTableGenerator.Execute() in /Users/lewing/Source/runtime/tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 28
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
/Users/lewing/Source/runtime/src/mono/wasm/wasm.proj(48,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
@lambdageek please review |
@@ -154,6 +153,12 @@ private string GenPInvokeDecl(PInvoke pinvoke) | |||
{ | |||
var sb = new StringBuilder(); | |||
var method = pinvoke.Method; | |||
if (method.Name == "EnumCalendarInfo") { |
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.
It's just intended as a temporary hack until that MetadataLoadContext bug is fixed though, so it might be fine for now? Unless you think that patch is landing soon.
tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Outdated
Show resolved
Hide resolved
tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Outdated
Show resolved
Hide resolved
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.
I think you also need to exclude entrypoints.c
from the sources in src/mono/mini/CMakeLists.txt. Otherwise gPalGlobalizationNative
will still build the array of all the globalization functions.
It will be built, but nothing will reference it. Will check. |
Removing it doesn't seem to matter. |
This is needed because they are stored in a separate table, so they cannot be linked out the same way as pinvokes/icalls.
…rator.cs Co-authored-by: Ryan Lucia <[email protected]>
…rator.cs Co-authored-by: Ryan Lucia <[email protected]>
This is needed because they are stored in a separate table, so they cannot be linked out the same
way as pinvokes/icalls.