-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,12 @@ public class PInvokeTableGenerator : Task | |
|
||
public override bool Execute() | ||
{ | ||
Log.LogMessage(MessageImportance.Normal, $"Generating pinvoke table to '{OutputPath}'."); | ||
GenPInvokeTable(Modules!.Select(item => item.ItemSpec).ToArray(), Assemblies!.Select(item => item.ItemSpec).ToArray()); | ||
return true; | ||
} | ||
|
||
private void GenPInvokeTable(string[] pinvokeModules, string[] assemblies) | ||
public void GenPInvokeTable(string[] pinvokeModules, string[] assemblies) | ||
{ | ||
var modules = new Dictionary<string, string>(); | ||
foreach (var module in pinvokeModules) | ||
|
@@ -46,8 +47,6 @@ private void GenPInvokeTable(string[] pinvokeModules, string[] assemblies) | |
CollectPInvokes(pinvokes, callbacks, type); | ||
} | ||
|
||
Log.LogMessage(MessageImportance.Normal, $"Generating pinvoke table to '{OutputPath}'."); | ||
|
||
using (var w = File.CreateText(OutputPath!)) | ||
{ | ||
EmitPInvokeTable(w, modules, pinvokes); | ||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. catch There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// FIXME: System.Reflection.MetadataLoadContext can't decode function pointer types | ||
// https://github.com/dotnet/runtime/issues/43791 | ||
sb.Append($"int {pinvoke.EntryPoint} (int, int, int, int, int);"); | ||
return sb.ToString(); | ||
} | ||
sb.Append(MapType(method.ReturnType)); | ||
sb.Append($" {pinvoke.EntryPoint} ("); | ||
int pindex = 0; | ||
|
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.
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