Skip to content

Support NativeAOT as a runtime variant for iOS platforms #17339

Closed

Description

@ivanpovazan

Description

To enable Supporting NativeAOT on iOS platforms as an experimental feature in .NET8 it is required to adjust Xamarin runtime, build system and SDK accordingly.

Tasks

The following list of tasks give a top-level overview of work that is required to enable this feature:

.NET 8

.NET 9

UPDATE: .NET9 tasks are moved to the top-level tracking issue:


PS The list of tasks is not complete. Feel free to extend it, change it and add more context.

Activity

  1. self-assigned this
    on Jan 23, 2023
  2. added this to the .NET 8 milestone on Jan 23, 2023
  3. added
    dotnet
    feature
    on Jan 23, 2023
  4. ivanpovazan commented on Jan 24, 2023

    @ivanpovazan
    MemberAuthor
    • Introduce new managed-to-native bridge for NativeAOT runtime

    The bridge will be responsible for properly initialising the NativeAOT runtime, invoking any managed code initialisation e.g.: https://github.com/xamarin/xamarin-macios/blob/608765e2c9e474c494958844a94354f90fa42f36/src/ObjCRuntime/Runtime.cs#L232 , and finally invoking the managed Main method.

    See this comment for more information: dotnet/runtime#77957 (comment)

  5. jkotas commented on Jan 24, 2023

    @jkotas
    Member

    Introduce new managed-to-native bridge for NativeAOT runtime

    Why is this bridge better than just injecting static constructor into the app with default bootstrapper? Injecting static constructor into the app looks more composable.

  6. ivanpovazan commented on Jan 26, 2023

    @ivanpovazan
    MemberAuthor

    Why is this bridge better than just injecting static constructor into the app with default bootstrapper? Injecting static constructor into the app looks more composable.

    Thanks for the suggestion, but at the moment there seem to be some limitations around it. If you are referring to the default bootstrapper provided by NativeAOT, it currently cannot be used from a native hosting app, when the managed executable is compiled as a static library, as the ILCompiler will not expose its managed Main method entry point (reported here: dotnet/runtime#81097).

    @rolfbjarne also gave an explanation on why it is required Xamarin to act as a native hosting application here: dotnet/runtime#77957 (comment)

    Finally, the requirement for:

    Introduce new managed-to-native bridge for NativeAOT runtime

    is written in more general terms, as mono and coreCLR runtimes have their dedicated bridges, so supporting NativeAOT would use the same logic without changing current implementation much.

    Afaik, injecting static constructor does not allow the method to have parameters, so if we would want to use it for initializing Xamarin's ObjCRuntime, we would have to change the code to PInvoke into the native to get the required parameters. It is not my call and I could be wrong, but this sounds like more work (especially making sure that the change does not break what is already supported).

  7. changed the title [-]Support NativeAOT as a third runtime variant with Xamarin for iOS platforms[/-] [+]Support NativeAOT as a runtime variant for iOS platforms[/+] on Jan 27, 2023
  8. 5 remaining items

  9. ivanpovazan commented on Sep 20, 2023

    @ivanpovazan
    MemberAuthor

    Closing this issue as all subtasks have been completed for the .NET8 timeframe.
    The remaining 2 issues for .NET9 milestone are moved to the top-level tracking issue.

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

Metadata

Metadata

Assignees

Labels

dotnetfeature

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions