[dotnet] Add support for setting the exception marshalling mode in the GenerateMain step. (#9517)
* [dotnet] Pass exception marshaling options to the linker configuration, and pass it along to the Application instance. * [dotnet] Write the selected exception marshaling modes to the generated main file. * [dotnet-linker] Set the default cooperative GC mode. The code to select the default exception marshalling mode needs it.
This commit is contained in:
Родитель
3a0580750d
Коммит
15ae4595b9
|
@ -143,6 +143,8 @@
|
|||
ItemsDirectory=$(_LinkerItemsDirectory)
|
||||
IsSimulatorBuild=$(_SdkIsSimulator)
|
||||
LinkMode=$(_LinkMode)
|
||||
MarshalManagedExceptionMode=$(_MarshalManagedExceptionMode)
|
||||
MarshalObjectiveCExceptionMode=$(_MarshalObjectiveCExceptionMode)
|
||||
PartialStaticRegistrarLibrary=$(_LibPartialStaticRegistrar)
|
||||
Platform=$(_PlatformName)
|
||||
PlatformAssembly=$(_PlatformAssemblyName).dll
|
||||
|
|
|
@ -108,6 +108,20 @@ namespace Xamarin.Linker {
|
|||
throw new InvalidOperationException ($"Unable to parse the {key} value: {value} in {linker_file}");
|
||||
Application.LinkMode = lm;
|
||||
break;
|
||||
case "MarshalManagedExceptionMode":
|
||||
if (!string.IsNullOrEmpty (value)) {
|
||||
if (!Application.TryParseManagedExceptionMode (value, out var mode))
|
||||
throw new InvalidOperationException ($"Unable to parse the {key} value: {value} in {linker_file}");
|
||||
Application.MarshalManagedExceptions = mode;
|
||||
}
|
||||
break;
|
||||
case "MarshalObjectiveCExceptionMode":
|
||||
if (!string.IsNullOrEmpty (value)) {
|
||||
if (!Application.TryParseObjectiveCExceptionMode (value, out var mode))
|
||||
throw new InvalidOperationException ($"Unable to parse the {key} value: {value} in {linker_file}");
|
||||
Application.MarshalObjectiveCExceptions = mode;
|
||||
}
|
||||
break;
|
||||
case "PartialStaticRegistrarLibrary":
|
||||
PartialStaticRegistrarLibrary = value;
|
||||
break;
|
||||
|
@ -168,6 +182,7 @@ namespace Xamarin.Linker {
|
|||
Application.CreateCache (significantLines.ToArray ());
|
||||
Application.Cache.Location = CacheDirectory;
|
||||
Application.DeploymentTarget = DeploymentTarget;
|
||||
Application.EnableCoopGC ??= Platform == ApplePlatform.WatchOS;
|
||||
Application.SdkVersion = SdkVersion;
|
||||
|
||||
switch (Platform) {
|
||||
|
@ -183,6 +198,9 @@ namespace Xamarin.Linker {
|
|||
|
||||
if (Driver.TargetFramework.Platform != Platform)
|
||||
throw ErrorHelper.CreateError (99, "Inconsistent platforms. TargetFramework={0}, Platform={1}", Driver.TargetFramework.Platform, Platform);
|
||||
|
||||
Application.SetManagedExceptionMode ();
|
||||
Application.SetObjectiveCExceptionMode ();
|
||||
}
|
||||
|
||||
public void Write ()
|
||||
|
@ -197,6 +215,8 @@ namespace Xamarin.Linker {
|
|||
Console.WriteLine ($" ItemsDirectory: {ItemsDirectory}");
|
||||
Console.WriteLine ($" IsSimulatorBuild: {IsSimulatorBuild}");
|
||||
Console.WriteLine ($" LinkMode: {LinkMode}");
|
||||
Console.WriteLine ($" MarshalManagedExceptions: {Application.MarshalManagedExceptions} (IsDefault: {Application.IsDefaultMarshalManagedExceptionMode})");
|
||||
Console.WriteLine ($" MarshalObjectiveCExceptions: {Application.MarshalObjectiveCExceptions}");
|
||||
Console.WriteLine ($" PartialStaticRegistrarLibrary: {PartialStaticRegistrarLibrary}");
|
||||
Console.WriteLine ($" Platform: {Platform}");
|
||||
Console.WriteLine ($" PlatformAssembly: {PlatformAssembly}.dll");
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Xamarin {
|
|||
var registration_methods = Configuration.RegistrationMethods;
|
||||
var items = new List<MSBuildItem> ();
|
||||
|
||||
var app = Configuration.Application;
|
||||
foreach (var abi in Configuration.Abis) {
|
||||
|
||||
var file = Path.Combine (Configuration.CacheDirectory, $"main.{abi.AsArchString ()}.mm");
|
||||
|
@ -38,6 +39,9 @@ namespace Xamarin {
|
|||
contents.WriteLine ("();");
|
||||
}
|
||||
}
|
||||
if (!app.IsDefaultMarshalManagedExceptionMode)
|
||||
contents.WriteLine ("\txamarin_marshal_managed_exception_mode = MarshalManagedExceptionMode{0};", app.MarshalManagedExceptions);
|
||||
contents.WriteLine ("\txamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionMode{0};", app.MarshalObjectiveCExceptions);
|
||||
contents.WriteLine ("}");
|
||||
contents.WriteLine ();
|
||||
contents.WriteLine ("void xamarin_initialize_callbacks () __attribute__ ((constructor));");
|
||||
|
|
Загрузка…
Ссылка в новой задаче