dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.56k stars 4.54k forks source link

Enable support for NativeAOT targeting iOS via opt-in feature #80905

Open ivanpovazan opened 1 year ago

ivanpovazan commented 1 year ago

Overview

Supporting NativeAOT on iOS platforms as an experimental feature in .NET8 would enable our customers to try the NativeAOT toolchain and runtime with their iOS applications, in order to benefit from advantages mostly concentrated around application size savings and start-up performance. In .NET8 the default toolchain and runtime when targeting iOS platforms will remain to be Mono, while NativeAOT would become available as an option.

This issues tracks progress on the identified work required for enabling NativeAOT on iOS platforms. The work is organised and tracked with GitHub issues divided by upcoming .NET8 preview releases in which they should become available. Some of the listed items can be considered as user stories and will require further break-down of work, while the others are plain tasks.

NOTE: The breakdown of GitHub issues does not impose hard deadlines. If some of the functionality does not get upstreamed for a particular preview version, this issue will be updated accordingly.

Tasks

.NET8 Preview 5

.NET8 Preview 6

.NET8 Preview 7

.NET8 GA

.NET9+

Other relevant issues:


/cc: @marek-safar @SamMonoRT @steveisok @lambdageek @rolfbjarne @kotlarmilos @akoeplinger

ghost commented 1 year ago

Tagging subscribers to 'os-ios': @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.

Issue Details
## Overview Supporting NativeAOT on iOS platforms as an experimental feature in .NET8 would enable our customers to try the NativeAOT toolchain and runtime with their iOS applications, in order to benefit from advantages mostly concentrated around application size savings and start-up performance. In .NET8 the default toolchain and runtime when targeting iOS platforms will remain to be Mono, while NativeAOT would become available as an option. This issues tracks progress on the identified work required for enabling NativeAOT on iOS platforms. The work will be organised and tracked with GitHub issues which are prioritised by their importance below. Some of the listed items can be considered as user stories and will require further break-down of work, while the others are plain tasks. ## Tasks ### Priority 0 - [ ] Investigate limitations and document findings of enabling NativeAOT for MAUI iOS application - [ ] Enable building NativeAOT for iOS platforms - [ ] Support targeting iOS platforms with ILCompiler - [ ] Enable dotnet SDK to support targeting iOS with NativeAOT - [ ] Enable AppleAppBuilder to bundle applications compiled with NativeAOT - [ ] HelloiOS sample for NativeAOT - [ ] Introduce symbol stripping build task for HelloiOS sample - [ ] Include measuring HelloiOS application size without debug symbols - [ ] Static registrar with NativeAOT design – discussion - [ ] Static registrar with NativeAOT implementation - [ ] Enable start-up hooks to wrap managed entry points: https://github.com/dotnet/runtime/issues/77957 - [ ] Objective-C marshalling and GC support: https://github.com/dotnet/runtime/issues/77472 - [ ] Enable building/running dotnet/runtime libraries tests on a simulator and device with NativeAOT - [ ] Support NativeAOT as a third runtime variant with Xamarin (managed-to-native bridge and build system) ### Priority 1 - [ ] UnmanagedCallersOnly functions should be exposed from referenced libraries with NativeAOT - [ ] Marshalled delegates vs function pointers support with NativeAOT - [ ] Trimming and extensions compatibility design – discussion - [ ] Trimming and extensions compatibility implementation - [ ] Enable dotnet/runtime functional tests for iOS platforms to run with NativeAOT - [ ] Enable Xamarin iOS testing to run with NativeAOT ### Priority 2 - [ ] Investigate debugging support with NativeAOT - [ ] Improve methodology for start-up profiling and measuring SOD for iOS platforms - [ ] Completely move from marshalled delegates to function pointers throughout the Microsoft.iOS library - [ ] App size-regression tracking for NativeAOT iOS - [ ] App startup time tracking for NativeAOT iOS - [ ] App build time tracking for NativeAOT iOS --- /cc: @marek-safar @SamMonoRT @steveisok @lambdageek @rolfbjarne @kotlarmilos @akoeplinger
Author: ivanpovazan
Assignees: -
Labels: `Epic`, `os-ios`, `area-NativeAOT-coreclr`
Milestone: 8.0.0
SamMonoRT commented 1 year ago

/cc @agocke @jkotas @AaronRobinsonMSFT

AaronRobinsonMSFT commented 1 year ago

We should also have a note/item around diagnostics and document what the user experience will be on iOS. I believe it would be rather different and having a comprehensive list would help users make informed decisions about using NativeAOT and what to expect post deployment.

/cc @tommcdon

tommcdon commented 1 year ago

Adding @thaystg @lateralusX. It is my understanding that Mono uses an in-proc debugger model due to mobile diagnostics restrictions.

filipnavara commented 1 year ago

We should also have a note/item around diagnostics and document what the user experience will be on iOS. I believe it would be rather different and having a comprehensive list would help users make informed decisions about using NativeAOT and what to expect post deployment.

FWIW debugging with lldb on-device is possible, so in that sense it's comparable to the current model of debugging NativeAOT on Linux/macOS.

ivanpovazan commented 1 year ago

@AaronRobinsonMSFT thank you for the suggestion. I have added it to the list.

curia-damiano commented 1 year ago

Does this feature mean that it will be possible to export a .NET class library as a native iOS library?

lateralusX commented 1 year ago

Does this feature mean that it will be possible to export a .NET class library as a native iOS library?

See https://github.com/dotnet/runtime/issues/79377 for details on library build in .net8 for iOS/Android. Not sure if the experimental feature implemented here will have support for NativeLib=static|shared, since the main focus is building an iOS application, but the work done in https://github.com/dotnet/runtime/issues/79377 is specifically targeting building a static|shared native library out of a set of .net class libraries and it is integrated into regular .net CLI, so you can do a publish -p:NativeLib=shared using iOS or Android rid's supporting the same features as doing NativeAOT library build.

ivanpovazan commented 1 year ago

Does this feature mean that it will be possible to export a .NET class library as a native iOS library?

Thank you for the question @curia-damiano. In theory that would work as well, however, our current focus with NativeAOT is supporting full iOS applications.

Would you mind sharing what would be the use case that you have in mind for native iOS libraries?

filipnavara commented 1 year ago

Would you mind sharing what would be the use case that you have in mind for native iOS libraries?

https://github.com/dotnet/runtime/issues/79377#issuecomment-1556873513

curia-damiano commented 1 year ago

Sorry @ivanpovazan, I missed your request for comments. Thank you @filipnavara for the link!