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

NativeAOT: Enable building app extensions with NativeAOT #20872

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

ivanpovazan
Copy link
Contributor

@ivanpovazan ivanpovazan commented Jul 11, 2024

Description

This PR enables building app extensions with NativeAOT.

App extensions are class libraries and to build them with NativeAOT we must not specify CustomNativeMain=true. If we do, ILC would expect that the input assembly has a managed Main as the module entry point.

Additionally, when building class libraries (with the absence of a managed Main entry point), our static reference from:

return __managed__Main (argc, argv);

requires build-time symbol resolution. To avoid linking errors, we generate an empty __managed__Main
in the native bootstrapping code of the app extension (e.g., in main.arm64.mm).

Testing

The unit tests have been introduced to test building app extensions with both Mono and NativeAOT.
Executing an iOS app TodayExtension built with NativeAOT has been verified manually on an actual device.


Fixes: #20653

@ivanpovazan ivanpovazan added this to the .NET 9 milestone Jul 11, 2024
@ivanpovazan ivanpovazan self-assigned this Jul 11, 2024
@ivanpovazan ivanpovazan requested a review from rolfbjarne as a code owner July 11, 2024 13:07
Copy link
Contributor

⚠️ Your code has been reformatted. ⚠️

If this is not desired, add the actions-disable-autoformat label, and revert the reformatting commit.

If files unrelated to your change were modified, try reverting the reformatting commit + merging with the target branch (and push those changes).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

tools/dotnet-linker/LinkerConfiguration.cs Outdated Show resolved Hide resolved
dotnet/targets/Xamarin.Shared.Sdk.props Outdated Show resolved Hide resolved
Comment on lines +1105 to +1108
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
Copy link
Member

Choose a reason for hiding this comment

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

Does it work with universal apps?

Suggested change
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
[TestCase (ApplePlatform.MacOSX, "osx-x64;osx-arm64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64;osx-arm64", true)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not work with the universal apps.
In fact, I discovered that we have a more general issue when building universal apps with NativeAOT and opened: #20903 about it.
For now, I commented out universal app extension tests with NativeAOT.

Comment on lines +1072 to +1073
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
Copy link
Member

Choose a reason for hiding this comment

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

Does it work with universal apps?

Suggested change
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64", true)]
[TestCase (ApplePlatform.MacOSX, "osx-x64;osx-arm64", false)]
[TestCase (ApplePlatform.MacOSX, "osx-x64;osx-arm64", true)]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@ivanpovazan ivanpovazan force-pushed the dev/ivanpovazan/naot-app-extensions branch from c0610d4 to 8866177 Compare July 12, 2024 14:34
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent
Hash: [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 1f368ca80e33545981dc37e5175e858ac2c197af [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 1f368ca80e33545981dc37e5175e858ac2c197af [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 1f368ca80e33545981dc37e5175e858ac2c197af [PR build]

@ivanpovazan
Copy link
Contributor Author

@mandel-macaque @dalexsoto
could you please take a look?

Regarding Rolf's comment about including universal app extensions tests with NativeAOT I opened: #20903 for tracking as we don't seem to properly support building regular universal apps with NativeAOT either.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [CI Build] Windows Integration Tests failed ❌

❌ Failed ❌

Pipeline on Agent
Hash: 1f368ca80e33545981dc37e5175e858ac2c197af [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 170 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 6 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ install-source: All 1 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 7 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac-binding-project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 6 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (watchOS): All 4 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 1f368ca80e33545981dc37e5175e858ac2c197af [PR build]

@dalexsoto dalexsoto requested a review from rolfbjarne July 18, 2024 22:50
@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 1f368ca80e33545981dc37e5175e858ac2c197af [PR build]

@dalexsoto dalexsoto merged commit 374e902 into net9.0 Jul 19, 2024
28 checks passed
@dalexsoto dalexsoto deleted the dev/ivanpovazan/naot-app-extensions branch July 19, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants