Skip to content

[dotnet] Add support for the interpreter + AOT when needed. Fixes #11421 and #11724.#12211

Merged
rolfbjarne merged 12 commits intodotnet:mainfrom
rolfbjarne:dotnet-interpreter-aot
Jul 27, 2021
Merged

[dotnet] Add support for the interpreter + AOT when needed. Fixes #11421 and #11724.#12211
rolfbjarne merged 12 commits intodotnet:mainfrom
rolfbjarne:dotnet-interpreter-aot

Conversation

@rolfbjarne
Copy link
Member

  • 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.

… 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.
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.
…atalyst.

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.
…hem.

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).
…phy.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.
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.
@rolfbjarne rolfbjarne requested review from emaf and spouliot as code owners July 23, 2021 19:29
@rolfbjarne rolfbjarne added not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests labels Jul 23, 2021
@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [PR Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (no change)

GitHub pages

Results can be found in the following github pages (it might take some time to publish):

Test results

27 tests failed, 91 tests passed.

Failed tests

  • monotouch-test/Mac [dotnet]/Debug (CoreCLR, static registrar) [dotnet]: Failed (Test run failed.
    Tests run: 2457 Passed: 2396 Inconclusive: 10 Failed: 1 Ignored: 60)
  • monotouch-test/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 2629 Passed: 2487 Inconclusive: 35 Failed: 2 Ignored: 140)
  • monotouch-test/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (LinkSdk) [dotnet]: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Debug (static registrar) [dotnet]: Failed
  • monotouch-test/iOS Unified 64-bits - simulator/Release (all optimizations) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug (LinkSdk) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Release (all optimizations) [dotnet]: Failed
  • interdependent-binding-projects/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • introspection/tvOS - simulator/Debug [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 11.4) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 11.4) [dotnet]: Failed
  • dont link/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • dont link/iOS Unified 64-bits - simulator/Release [dotnet]: Failed
  • dont link/tvOS - simulator/Debug [dotnet]: Failed
  • dont link/tvOS - simulator/Release [dotnet]: Failed
  • link all/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • link all/iOS Unified 64-bits - simulator/Release [dotnet]: Failed
  • link all/tvOS - simulator/Debug [dotnet]: Failed
  • link all/tvOS - simulator/Release [dotnet]: Failed
  • link sdk/iOS Unified 64-bits - simulator/Debug [dotnet]: Failed
  • link sdk/iOS Unified 64-bits - simulator/Release [dotnet]: Failed
  • link sdk/tvOS - simulator/Debug [dotnet]: Failed
  • link sdk/tvOS - simulator/Release [dotnet]: Failed

Pipeline on Agent XAMBOT-1108.BigSur'
Merge c898f19 into 62a9fd9

This is not the final fix, but this code will be reworked extensively, and
this fix works for now to make the interpreter work.
@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [PR Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (no change)

GitHub pages

Results can be found in the following github pages (it might take some time to publish):

Test results

2 tests failed, 116 tests passed.

Failed tests

  • monotouch-test/Mac Catalyst/Debug [dotnet]: Failed (Tests run: 2629 Passed: 2486 Inconclusive: 35 Failed: 3 Ignored: 140)
  • link sdk/Mac Catalyst/Debug [dotnet]: TimedOut (Execution timed out after 1200 seconds.
    No test log file was produced)

Pipeline on Agent XAMBOT-1100.BigSur'
Merge 233675a into e67f4de

@rolfbjarne
Copy link
Member Author

Test failures are unrelated

@rolfbjarne rolfbjarne merged commit 0549af9 into dotnet:main Jul 27, 2021
@rolfbjarne rolfbjarne deleted the dotnet-interpreter-aot branch July 27, 2021 05:39
@rolfbjarne
Copy link
Member Author

/sudo backport release/6.0.1xx-preview7

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Backport Job to branch release/6.0.1xx-preview7 Created! The magic is happening here

@rolfbjarne

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Hooray! Backport succeeded! Please see https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=5024059 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mac Catalyst: AOT for ARM64 [dotnet] Support interpreter-only mode in the simulator

5 participants