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

[Mono] Add osx aot offsets & generate aot compiler packs for x64 and arm64 #55506

Closed
wants to merge 3 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
2 changes: 2 additions & 0 deletions eng/pipelines/runtime-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ stages:
- mono_tvos_offsets
- mono_ios_offsets
- mono_maccatalyst_offsets
- mono_osx_offsets
monoCrossAOTTargetOS:
- Android
- Browser
- tvOS
- iOS
- MacCatalyst
- OSX
isOfficialBuild: ${{ variables.isOfficialBuild }}
extraStepsTemplate: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
extraStepsParameters:
Expand Down
3 changes: 3 additions & 0 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ jobs:
- tvOS_arm64
- iOS_arm64
- MacCatalyst_x64
- OSX_x64
jobParameters:
condition: >-
or(
Expand Down Expand Up @@ -643,12 +644,14 @@ jobs:
- mono_tvos_offsets
- mono_ios_offsets
- mono_maccatalyst_offsets
- mono_osx_offsets
monoCrossAOTTargetOS:
- Android
- Browser
- tvOS
- iOS
- MacCatalyst
- OSX
condition: >-
or(
eq(dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'], true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+tvos+'))">$(MonoAotTargets);tvossimulator-x64;tvossimulator-arm64;tvos-arm64</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+ios+'))">$(MonoAotTargets);iossimulator-x64;iossimulator-arm64;iossimulator-x86;ios-arm64;ios-arm</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+maccatalyst+'))">$(MonoAotTargets);maccatalyst-x64;maccatalyst-arm64</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+osx+'))">$(MonoAotTargets);osx-x64;osx-arm64</MonoAotTargets>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
set(MONO_OFFSETS_FILE "${AOT_OFFSETS_FILE}")
endif()
if(AOT_TARGET_TRIPLE STREQUAL "x86_64-apple-darwin10")
set(TARGET_SYSTEM_NAME "iOS")
if(REAL_TARGET_OS STREQUAL "osx")

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need it. I was trying to fit within what was there and it felt weird to set the TARGET_SYSTEM_NAME to iOS when I know it should be Darwin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I am misreading what is happening. We set AOT_TARGET_TRIPLE from the outside. And then that sets TARGET_SYSTEM_NAME and then TARGET_SYSTEM_NAME is used to set other target properties. So it's not redundant. The triple is the source of truth.

It's unfortunate that we use the same triple for ios and mac. Did we do that in mono/mono, too? @vargaz ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We has no cross compiler to osx previously, probably just used the normal host mono. If we need it, it should use a separate triple.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything you would suggest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like x86_64-apple-macos

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to https://reviews.llvm.org/D40998 they use x86_64-apple-macosx (note the x at the end) for clang's -target but if I understand correctly we're not passing the triple down to clang here so this is just for us?

set(TARGET_SYSTEM_NAME "Darwin")
else()
set(TARGET_SYSTEM_NAME "iOS")
endif()
set(TARGET_ARCH "x86_64")
elseif(AOT_TARGET_TRIPLE STREQUAL "i386-apple-darwin10")
set(TARGET_SYSTEM_NAME "iOS")
Expand All @@ -138,6 +142,9 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
set(TARGET_SYSTEM_NAME "Darwin")
set(TARGET_ARCH "arm64")
set(TARGET_MACCAT 1)
elseif(AOT_TARGET_TRIPLE STREQUAL "aarch64-apple-darwin20")
set(TARGET_SYSTEM_NAME "Darwin")
set(TARGET_ARCH "arm64")
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-none")
set(TARGET_SYSTEM_NAME "Emscripten")
set(TARGET_ARCH "wasm")
Expand Down
13 changes: 11 additions & 2 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<BuildMonoAOTCrossCompiler Condition="'$(TargetsiOS)' == 'true'">true</BuildMonoAOTCrossCompiler>
<BuildMonoAOTCrossCompiler Condition="'$(TargetstvOS)' == 'true'">true</BuildMonoAOTCrossCompiler>
<BuildMonoAOTCrossCompiler Condition="'$(TargetsMacCatalyst)' == 'true'">true</BuildMonoAOTCrossCompiler>
<BuildMonoAOTCrossCompiler Condition="'$(TargetsOSX)' == 'true'">true</BuildMonoAOTCrossCompiler>
<BuildMonoAOTCrossCompiler Condition="'$(TargetsBrowser)' == 'true'">true</BuildMonoAOTCrossCompiler>
<BuildMonoAOTCrossCompiler Condition="'$(TargetsAndroid)' == 'true'">true</BuildMonoAOTCrossCompiler>
<MonoObjCrossDir>$([MSBuild]::NormalizeDirectory('$(MonoObjDir)', 'cross'))</MonoObjCrossDir>
Expand Down Expand Up @@ -524,7 +525,7 @@
<Target Name="BuildMonoCross" Condition="'$(BuildMonoAOTCrossCompiler)' == 'true'" DependsOnTargets="BuildMonoRuntime">

<!-- iOS specific options -->
<PropertyGroup Condition="'$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true'">
<PropertyGroup Condition="'$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsOSX)' == 'true'">
<!-- FIXME: Disable for simulator -->
<MonoUseCrossTool>true</MonoUseCrossTool>
<MonoAotCMakeSysroot Condition="'$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' != 'true'">$(XcodeDir)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(iOSVersion).sdk</MonoAotCMakeSysroot>
Expand All @@ -544,8 +545,16 @@
<MonoAotAbi Condition="'$(Platform)' == 'arm64'">aarch64-apple-maccatalyst</MonoAotAbi>
<MonoAotAbi Condition="'$(Platform)' == 'x64'">x86_64-apple-maccatalyst</MonoAotAbi>
</PropertyGroup>
<ItemGroup Condition="'$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">
<PropertyGroup Condition="'$(TargetsOSX)' == 'true'">
<MonoUseCrossTool>true</MonoUseCrossTool>
<MonoAotCMakeSysroot>$(XcodeDir)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk</MonoAotCMakeSysroot>
<MonoAotOffsetsFile>$(MonoObjCrossDir)offsets-$(Platform)-darwin.h</MonoAotOffsetsFile>
<MonoAotAbi Condition="'$(Platform)' == 'arm64'">aarch64-apple-darwin20</MonoAotAbi>
<MonoAotAbi Condition="'$(Platform)' == 'x64'">x86_64-apple-darwin10</MonoAotAbi>
</PropertyGroup>
<ItemGroup Condition="'$(TargetstvOS)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsOSX)' == 'true'">
<MonoAOTCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(macOSVersionMin)" />
<MonoAOTCMakeArgs Include="-DREAL_TARGET_OS=$(RealTargetOS.ToLowerInvariant())" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetOS)' == 'Linux' and '$(Platform)' == 'arm64'">
Expand Down
8 changes: 8 additions & 0 deletions src/mono/mono/tools/offsets-tool/offsets-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ def require_emscipten_path (args):
self.target = Target ("TARGET_ARM64", "TARGET_MACCAT", IOS_DEFINES)
self.target_args += ["-target", "arm64-apple-ios14.2-macabi"]
self.target_args += ["-isysroot", args.sysroot]

# MacOS
elif "aarch64-apple-darwin20" == args.abi:
require_sysroot (args)
self.target = Target ("TARGET_ARM64", "TARGET_OSX", IOS_DEFINES)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOS_DEFINES sounds a bit weird here if we're using it for macOS too. We should probably rename it to APPLE_DEFINES. Also if we're using a different AOT_TARGET_TRIPLE for macOS then we need to also add the case for x86_64 here that is covered by the iOS case on L149 now.

self.target_args += ["-arch", "arm64"]
self.target_args += ["-isysroot", args.sysroot]

# watchOS
elif "armv7k-apple-darwin" == args.abi:
Expand Down Expand Up @@ -222,6 +229,7 @@ def run_clang(self):
args.mono_path + "/mono",
args.mono_path + "/mono/eglib",
args.target_path,
args.target_path + "/mono",
args.target_path + "/mono/eglib"
]

Expand Down
2 changes: 2 additions & 0 deletions src/mono/monoaotcross.proj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
<_MonoCrossAOTTargetOS Condition="$(_MonoGenerateOffsetsOSGroups.contains('+tvos+'))">$(_MonoCrossAOTTargetOS)+tvos+</_MonoCrossAOTTargetOS>
<_MonoCrossAOTTargetOS Condition="$(_MonoGenerateOffsetsOSGroups.contains('+ios+'))">$(_MonoCrossAOTTargetOS)+ios+</_MonoCrossAOTTargetOS>
<_MonoCrossAOTTargetOS Condition="$(_MonoGenerateOffsetsOSGroups.contains('+maccatalyst+'))">$(_MonoCrossAOTTargetOS)+maccatalyst+</_MonoCrossAOTTargetOS>
<_MonoCrossAOTTargetOS Condition="$(_MonoGenerateOffsetsOSGroups.contains('+osx+'))">$(_MonoCrossAOTTargetOS)+osx+</_MonoCrossAOTTargetOS>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+android+'))">$(MonoAotTargets);Android-x64;Android-arm64;Android-x86;Android-arm</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+browser+'))">$(MonoAotTargets);Browser-wasm</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+tvos+'))">$(MonoAotTargets);tvOSSimulator-x64;tvOSSimulator-arm64;tvOS-arm64</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+ios+'))">$(MonoAotTargets);iOSSimulator-x64;iOSSimulator-arm64;iOSSimulator-x86;iOS-arm64;iOS-arm</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+maccatalyst+'))">$(MonoAotTargets);MacCatalyst-x64;MacCatalyst-arm64</MonoAotTargets>
<MonoAotTargets Condition="$(_MonoCrossAOTTargetOS.contains('+osx+'))">$(MonoAotTargets);osx-x64;osx-arm64</MonoAotTargets>
</PropertyGroup>

<ItemGroup>
Expand Down