Skip to content

Commit f1713bc

Browse files
authored
[dotnet] Only do Mono AOT stuff when we're using Mono (#24204)
1 parent 345ea9c commit f1713bc

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,8 @@
11541154
<!-- Don't run the AOT compiler by default -->
11551155
<_RunAotCompiler>false</_RunAotCompiler>
11561156
</PropertyGroup>
1157-
<!-- We don't run Mono's AOT compiler if we're using NativeAOT -->
1158-
<PropertyGroup Condition="'$(_UseNativeAot)' != 'true'" >
1157+
<!-- We don't run Mono's AOT compiler if we're not using Mono (aka if we're using NativeAOT or CoreCLR) -->
1158+
<PropertyGroup Condition="'$(UseMonoRuntime)' == 'true'" >
11591159
<!-- We need it for device builds for mobile platforms -->
11601160
<_RunAotCompiler Condition="'$(_SdkIsSimulator)' != 'true' And '$(_PlatformName)' != 'macOS' And '$(_PlatformName)' != 'MacCatalyst'">true</_RunAotCompiler>
11611161
<!-- We need it if the interpreter is enabled, no matter where -->

tools/common/Application.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,18 +1354,13 @@ public bool IsInterpreted (string assembly)
13541354
return true;
13551355
}
13561356

1357-
// For mobile device builds: returns whether an assembly is AOT-compiled.
1358-
// For macOS: while AOT is supported for macOS, this particular method was not written for macOS, and would need
1359-
// revision/testing to be used so desired.
1357+
// Returns whether an assembly is Mono AOT-compiled.
13601358
public bool IsAOTCompiled (string assembly)
13611359
{
1362-
#if NET && !LEGACY_TOOLS
1363-
if (Platform == ApplePlatform.MacOSX)
1364-
return false; // AOT on .NET for macOS hasn't been implemented yet.
1365-
#else
1366-
if (Platform == ApplePlatform.MacOSX)
1367-
throw ErrorHelper.CreateError (99, Errors.MX0099, "IsAOTCompiled isn't a valid operation for macOS apps.");
1368-
#endif
1360+
// We're never AOT compiled if we're using CoreCLR
1361+
if (XamarinRuntime == XamarinRuntime.CoreCLR)
1362+
return false;
1363+
13691364
if (!UseInterpreter) {
13701365
if (Platform == ApplePlatform.MacCatalyst)
13711366
return IsArchEnabled (Abi.ARM64);

tools/common/Target.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void GenerateIOSMain (StringWriter sw, Abi abi)
613613
var assembly_location_count = 0;
614614
var enable_llvm = (abi & Abi.LLVM) != 0;
615615

616-
if (app.XamarinRuntime != XamarinRuntime.NativeAOT) {
616+
if (app.XamarinRuntime == XamarinRuntime.MonoVM) {
617617
register_assemblies.AppendLine ("\tGCHandle exception_gchandle = INVALID_GCHANDLE;");
618618
foreach (var s in assemblies) {
619619
if (!s.IsAOTCompiled)
@@ -725,6 +725,8 @@ void GenerateIOSMain (StringWriter sw, Abi abi)
725725
}
726726
} else if (app.XamarinRuntime == XamarinRuntime.NativeAOT) {
727727
// don't call mono_jit_set_aot_mode
728+
} else if (app.XamarinRuntime == XamarinRuntime.CoreCLR) {
729+
// don't call mono_jit_set_aot_mode
728730
} else if (app.IsDeviceBuild) {
729731
sw.WriteLine ("\tmono_jit_set_aot_mode (MONO_AOT_MODE_FULL);");
730732
} else if (app.Platform == ApplePlatform.MacCatalyst && ((abi & Abi.ARM64) == Abi.ARM64)) {

0 commit comments

Comments
 (0)