Skip to content
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

Switch MacCatalyst interpreter runs to use AOT JustInterp #52848

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion eng/pipelines/runtime-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
platforms:
- iOSSimulator_x64
- tvOSSimulator_x64
- MacCatalyst_x64
variables:
# map dependencies variables to local variables
- name: librariesContainsChange
Expand Down Expand Up @@ -96,6 +95,48 @@ jobs:
eq(variables['monoContainsChange'], true),
eq(variables['isFullMatrix'], true))

#
# MacCatalyst interp - requires AOT Compilation and Interp flags
# Build the whole product using Mono and run libraries tests
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
buildConfig: Release
runtimeFlavor: mono
platforms:
- MacCatalyst_x64
- MacCatalyst_arm64
variables:
# map dependencies variables to local variables
- name: librariesContainsChange
value: $[ dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
- name: monoContainsChange
value: $[ dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'] ]
jobParameters:
testGroup: innerloop
nameSuffix: AllSubsets_Mono
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunAOTCompilation=true /p:MonoForceInterpreter=true
timeoutInMinutes: 180
condition: >-
or(
eq(dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true),
eq(dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'], true),
eq(dependencies.evaluate_paths.outputs['SetPathVars_installer.containsChange'], true),
eq(variables['isFullMatrix'], true))
# extra steps, run tests
extraStepsTemplate: /eng/pipelines/libraries/helix.yml
extraStepsParameters:
creator: dotnet-bot
interpreter: true
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
condition: >-
or(
eq(variables['librariesContainsChange'], true),
eq(variables['monoContainsChange'], true),
eq(variables['isFullMatrix'], true))

#
# Build the whole product using Mono and run libraries tests
#
Expand Down
12 changes: 10 additions & 2 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,16 @@
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == ''">AppleTestRunner.dll</MainLibraryFileName>
<_MobileIntermediateOutputPath Condition="'$(RunAOTCompilation)' == 'true'">$(IntermediateOutputPath)mobile</_MobileIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup>
<AOTMode Condition="'$(TargetOS)' != 'MacCatalyst'">Full</AOTMode>
<AOTMode Condition="'$(TargetOS)' == 'MacCatalyst' and '$(MonoForceInterpreter)' != 'true'">Full</AOTMode>
<AOTMode Condition="'$(TargetOS)' == 'MacCatalyst' and '$(MonoForceInterpreter)' == 'true'">JustInterp</AOTMode>
</PropertyGroup>
<ItemGroup>
<AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(PublishDir)*.dll" Exclude="$(PublishDir)System.Runtime.WindowsRuntime.dll">
<_AotExcludeAssemblies Include="$(PublishDir)System.Runtime.WindowsRuntime.dll" />
<_AotExcludeAssemblies Include="@(NativeLibraries->'$(PublishDir)%(Identity)')" />

<AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(PublishDir)*.dll" Exclude="@(_AotExcludeAssemblies)">
<AotArguments>@(MonoAOTCompilerDefaultAotArguments, ';')</AotArguments>
<ProcessArguments>@(MonoAOTCompilerDefaultProcessArguments, ';')</ProcessArguments>
</AotInputAssemblies>
Expand All @@ -175,7 +183,7 @@
<MonoAOTCompiler Condition="'$(RunAOTCompilation)' == 'true'"
CompilerBinaryPath="$(MonoAotCrossCompilerPath)"
OutputDir="$(_MobileIntermediateOutputPath)"
Mode="Full"
Mode="$(AOTMode)"
OutputType="AsmOnly"
Assemblies="@(AotInputAssemblies)"
AotModulesTablePath="$(BundleDir)\modules.m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(RunAOTCompilation)' == 'true'">
<!-- Identifies native libraries that should be skipped during AOT -->
<NativeLibraries Include="NativeLibrary.dll" />
<NativeLibraries Include="SecondNativeLibrary.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="FileVersionInfoTest.cs" />
<Compile Include="AssemblyInfo.cs" />
Expand Down
9 changes: 3 additions & 6 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
elseif(AOT_TARGET_TRIPLE STREQUAL "x86_64-apple-maccatalyst")
set(TARGET_SYSTEM_NAME "Darwin")
set(TARGET_ARCH "x86_64")
set(CMAKE_SYSTEM_VARIANT "MacCatalyst")
set(TARGET_MACCAT 1)
elseif(AOT_TARGET_TRIPLE STREQUAL "aarch64-apple-maccatalyst")
set(TARGET_SYSTEM_NAME "Darwin")
set(TARGET_ARCH "arm64")
set(CMAKE_SYSTEM_VARIANT "MacCatalyst")
set(TARGET_MACCAT 1)
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-none")
set(TARGET_SYSTEM_NAME "Emscripten")
set(TARGET_ARCH "wasm")
Expand Down Expand Up @@ -296,9 +296,6 @@ if(TARGET_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_MACH 1)
set(TARGET_OSX 1)
set(TARGET_DARWIN 1)
if(CMAKE_SYSTEM_VARIANT STREQUAL "MacCatalyst")
set(TARGET_MACCAT 1)
endif()
elseif(TARGET_SYSTEM_NAME STREQUAL "iOS" OR TARGET_SYSTEM_NAME STREQUAL "tvOS")
set(TARGET_MACH 1)
set(TARGET_IOS 1)
Expand Down Expand Up @@ -744,7 +741,7 @@ set(FULL_VERSION ${product_version_string})
######################################
# OS SPECIFIC CHECKS
######################################
if(TARGET_IOS OR TARGET_ANDROID OR TARGET_MACCAT)
if(HOST_IOS OR HOST_ANDROID OR HOST_MACCAT)
# FIXME: the mobile products use mono_dllmap_insert so allow this
unset(DISABLE_DLLMAP)
else()
Expand Down
3 changes: 2 additions & 1 deletion src/mono/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<watchOSVersionMin>2.0</watchOSVersionMin>
<watchOS64_32VersionMin>5.1</watchOS64_32VersionMin>
<macOSVersionMin>10.13</macOSVersionMin>
<macOSVersionMin Condition="'$(TargetOS)' == 'OSX' and '$(TargetArchitecture)' == 'arm64'">11.0</macOSVersionMin>
<!-- FIXME: when we're building ios or tvOS cross-compilers hosted on OSX/arm64 targeting ios/arm64 we should set the min macOS version to 11.0, also -->
<macOSVersionMin Condition="('$(TargetOS)' == 'OSX' or '$(TargetOS)' == 'MacCatalyst') and '$(TargetArchitecture)' == 'arm64'">11.0</macOSVersionMin>

<!-- Version of the OS SDK we target -->
<iOSVersion></iOSVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
}
if ((flags & MONO_MMAP_JIT) && (use_mmap_jit || is_hardened_runtime == 1))
mflags |= MAP_JIT;
#if defined(HOST_ARM64)
#if defined(HOST_ARM64) && !defined(HOST_MACCAT)
/* Patching code on apple silicon seems to cause random crashes without this flag */
/* No __builtin_available in old versions of Xcode that could be building Mono on x86 or amd64 */
if (__builtin_available (macOS 11, *))
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/AppleAppBuilder/AppleAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public override bool Execute()
throw new InvalidOperationException("Need list of AOT files for device builds.");
}

if (ForceInterpreter && ForceAOT)
if (TargetOS != TargetNames.MacCatalyst && ForceInterpreter && ForceAOT)
{
throw new InvalidOperationException("Interpreter and AOT cannot be enabled at the same time");
}
Expand Down
10 changes: 9 additions & 1 deletion src/tasks/AppleAppBuilder/Templates/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,22 @@

monovm_initialize (sizeof (appctx_keys) / sizeof (appctx_keys [0]), appctx_keys, appctx_values);

#if FORCE_INTERPRETER
#if (FORCE_INTERPRETER && !FORCE_AOT)
// interp w/ JIT fallback. Assumption is that your configuration can JIT
os_log_info (OS_LOG_DEFAULT, "INTERP Enabled");
mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP_ONLY);
#elif (!TARGET_OS_SIMULATOR && !TARGET_OS_MACCATALYST) || FORCE_AOT
register_dllmap ();
// register modules
register_aot_modules ();

#if (FORCE_INTERPRETER && TARGET_OS_MACCATALYST)
os_log_info (OS_LOG_DEFAULT, "AOT INTERP Enabled");
mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP);
#else
mono_jit_set_aot_mode (MONO_AOT_MODE_FULL);
#endif

#endif

mono_debug_init (MONO_DEBUG_FORMAT_MONO);
Expand Down
3 changes: 2 additions & 1 deletion src/tasks/AppleAppBuilder/Xcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public string GenerateXCode(
{
defines.AppendLine("add_definitions(-DFORCE_INTERPRETER=1)");
}
else if (forceAOT)

if (forceAOT)
{
defines.AppendLine("add_definitions(-DFORCE_AOT=1)");
}
Expand Down