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

Mac Catalyst: AOT for ARM64 #11724

Closed
Tracked by #44736
rolfbjarne opened this issue May 28, 2021 · 0 comments · Fixed by #12211
Closed
Tracked by #44736

Mac Catalyst: AOT for ARM64 #11724

rolfbjarne opened this issue May 28, 2021 · 0 comments · Fixed by #12211
Assignees
Labels
dotnet An issue or pull request related to .NET (6) dotnet-external-dependency .NET: this issue/pull request is blocked on external work dotnet-pri0 .NET 6: required for stable release Mac Catalyst Issues affecting Mac Catalyst
Milestone

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented May 28, 2021

Mac Catalyst doesn't support the JIT on ARM64 (dotnet/runtime#52635 (comment)), so we need to AOT-compile instead, like we do for iOS device.

Depends on dotnet/runtime#53579.

@rolfbjarne rolfbjarne added dotnet An issue or pull request related to .NET (6) Mac Catalyst Issues affecting Mac Catalyst dotnet-pri0 .NET 6: required for stable release labels May 28, 2021
@rolfbjarne rolfbjarne added this to the .NET 6 milestone May 28, 2021
@rolfbjarne rolfbjarne added the dotnet-external-dependency .NET: this issue/pull request is blocked on external work label Jun 2, 2021
@rolfbjarne rolfbjarne self-assigned this Jun 23, 2021
rolfbjarne added a commit that referenced this issue Jul 27, 2021
 and #11724. (#12211)

* Add support for the interpreter everywhere.
* Add support for the AOT compiler everywhere we didn't support it before,
  because the interpreter needs it (at least System.Private.CoreLib.dll must
  be AOT-compiled when using the interpreter).
* Do FullAOT compilation on Mac Catalyst/ARM64 if we're not using the
  interpreter, since we can't use the JIT.
* Fix monotouch-test to be green on Mac Catalyst/ARM64.

Fixes #11724.
Fixes #11421.
rolfbjarne added a commit that referenced this issue Jul 28, 2021
… AOT when needed. Fixes #11421 and #11724. (#12237)

* [dotnet] Refactor and extend the logic to determine whether we should run the AOT compiler or not.

We also can't link dynamically with libmonosgen-2.0.dylib if we AOT compile anything,
so make sure we don't do that.

* [runtime] AOT is no longer limited to device builds.

* [runtime/tools] Implement finding native mono lib for Mac Catalyst. This also meant propagating how libmono is linked from the MSBuild code to the Application class so that our existing logic is able to correctly determine which native mono lib to use.

* [tools] Implement interpreter + AOT compilation for simulator + Mac Catalyst.

The interpreter requires running the AOT compiler for System.Private.CoreLib.dll,
so the first step in implementing the interpreter is to implement support for the
AOT compiler as well.

For .NET the logic is now as follows:

* If the interpreter is enabled, AOT compile System.Private.CoreLib.dll.
* If the interpreter is disabled, AOT everything on device + Mac Catalyst on ARM64.

* [tests] Add a MyInterpretedApp test solution

* [dotnet] Parse --dlsym and pass it to the dotnet-linker tasks.

* [dotnet] Only list linker flags for assemblies after we've computed them.

This means not listing per-assembly linker flags for only binding projects, but delay
it until we've computed the linker flags for all assemblies (and reflect this in
variable names as well).

* [dotnet-linker] Add native references to libSystem.Security.Cryptography.Native.Apple for Mac Catalyst.

Fixes these test failures:

    Ctor_Trust: System.DllNotFoundException : libSystem.Security.Cryptography.Native.Apple
    MailX1: System.DllNotFoundException : libSystem.Security.Cryptography.Native.Apple
    Encrypt_Empty: System.DllNotFoundException : libSystem.Security.Cryptography.Native.Apple
    KeyRecordTest: System.DllNotFoundException : libSystem.Security.Cryptography.Native.Apple
    Basic_Leaf_Only: System.DllNotFoundException : libSystem.Security.Cryptography.Native.Apple

which are all because of

    Xamarin.MacCatalyst: Unable to resolve P/Invoke 'AppleCryptoNative_X509GetContentType' in the library 'libSystem.Security.Cryptography.Native.Apple'

which happens because without this change we're not linking with the static version
of libSystem.Security.Cryptography.Native.Apple.

* [monotouch-test] Fix some formatting and add assert messages

* [tools] Disable direct-pinvoke for AOT-compiled code on Mac Catalyst.

Using 'direct-pinvoke' will tell the AOT compiler to emit a direct call to the
native function declared in the DllImport, which doesn't work when we want to
redirect to a different native funcion (in our xamarin_pinvoke_override/PINVOKE_OVERRIDE
implementation).

This fixes our exception marshalling tests in monotouch-test.

* [monotouch-test] Improve the MTLDeviceTest to work on Mac Catalyst.

* [tools] Always use '__Internal' as the native library for .NET.

This is not the final fix, but this code will be reworked extensively, and
this fix works for now to make the interpreter work.

* [monotouch-test] Ignore the MTLDeviceTest.ReturnReleaseTest on Mac Catalyst.

It requires a backport of other test fixes (which we're not really interested in), so just ignore it.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dotnet An issue or pull request related to .NET (6) dotnet-external-dependency .NET: this issue/pull request is blocked on external work dotnet-pri0 .NET 6: required for stable release Mac Catalyst Issues affecting Mac Catalyst
Projects
None yet
1 participant