未验证 提交 dbe6447a 编写于 作者: Z Zoltan Varga 提交者: GitHub

Disable qcalls on wasm. Treat them as normal pinvokes. (#43798)

* Disable qcalls on wasm. Treat them as normal pinvokes.

This is needed because they are stored in a separate table, so they cannot be linked out the same
way as pinvokes/icalls.

* Update tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Co-authored-by: NRyan Lucia <ryan@luciaonline.net>

* Update tools-local/tasks/mobile.tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Co-authored-by: NRyan Lucia <ryan@luciaonline.net>
Co-authored-by: NRyan Lucia <ryan@luciaonline.net>
上级 b2dba8d9
......@@ -1596,6 +1596,9 @@
/* Icall tables disabled */
#cmakedefine DISABLE_ICALL_TABLES 1
/* QCalls disabled */
#cmakedefine DISABLE_QCALLS 1
/* Have __thread keyword */
#cmakedefine MONO_KEYWORD_THREAD 1
......
......@@ -52,6 +52,7 @@ option (DISABLE_EVENTPIPE "Disable EventPipe support")
option (DISABLE_EXECUTABLES "Disable the build of the runtime executables")
option (DISABLE_CRASH_REPORTING "Disable crash reporting subsystem")
option (DISABLE_ICALL_TABLES "Enable separate icall table library")
option (DISABLE_QCALLS "Disable support for QCalls")
option (ENABLE_ICALL_EXPORT "Export icall functions")
option (ENABLE_ICALL_SYMBOL_MAP "Generate tables which map icall functions to their C symbols")
option (ENABLE_PERFTRACING "Enables support for eventpipe library")
......
......@@ -182,7 +182,7 @@
</ItemGroup>
<!-- WASM specific options -->
<ItemGroup Condition="'$(TargetsBrowser)' == 'true'">
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,full_messages,appdomains,shadowcopy,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,logging,remoting,shared_perfcounters,sgen_debug_helpers,sgen_binary_protocol,soft_debug,interpreter,assert_messages,cleanup,mdb,gac,threads,eventpipe,aot,interpreter"/>
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,full_messages,appdomains,shadowcopy,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,logging,remoting,shared_perfcounters,sgen_debug_helpers,sgen_binary_protocol,soft_debug,interpreter,assert_messages,cleanup,mdb,gac,threads,eventpipe,aot,interpreter,qcalls"/>
<_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/>
<_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/>
<_MonoCMakeArgs Include="-DDISABLE_CRASH_REPORTING=1"/>
......
......@@ -27,9 +27,11 @@ const void* gPalGlobalizationNative[] = { (void*)func_flag_end_of_array };
static const MonoQCallDef c_qcalls[] =
{
#ifndef DISABLE_QCALLS
#define FCClassElement(name,namespace,funcs) {name, namespace, funcs},
#include "mono/metadata/qcall-def.h"
#undef FCClassElement
#endif
};
const int c_nECClasses = sizeof (c_qcalls) / sizeof (c_qcalls[0]);
......
......@@ -1321,6 +1321,8 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou
new_import = g_strdup (orig_import);
#endif
/* If qcalls are disabled, we fall back to the normal pinvoke code for them */
#ifndef DISABLE_QCALLS
if (strcmp (new_scope, "QCall") == 0) {
piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, status_out);
if (!piinfo->addr) {
......@@ -1332,6 +1334,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou
}
return piinfo->addr;
}
#endif
#ifdef ENABLE_NETCORE
#ifndef HOST_WIN32
......
......@@ -34,6 +34,7 @@
<ItemGroup>
<WasmPInvokeModule Include="libSystem.Native" />
<WasmPInvokeModule Include="libSystem.IO.Compression.Native" />
<WasmPInvokeModule Include="QCall" />
<WasmPInvokeAssembly Include="@(LibrariesRuntimeFiles)" Condition="'%(Extension)' == '.dll' and '%(IsNative)' != 'true'" />
</ItemGroup>
......
......@@ -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") {
// 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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册