-
Notifications
You must be signed in to change notification settings - Fork 560
[nativeaot] Next steps for the NAOT runtime #10476
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
Conversation
c830a14
to
2d7ffcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements compatibility improvements for the NativeAOT runtime to align it more closely with MonoVM and CoreCLR runtime hosts. It adds support for setting environment variables via <AndroidEnvironment>
MSBuild items and local system properties, while also optimizing package size and startup performance by switching from shared to static libc++.
Key changes include:
- Unified environment variable and system property handling across runtime hosts
- Infrastructure for NativeAOT to process environment files and system properties
- Static linking of libc++ instead of shared library to reduce package size (~9MB) and improve startup
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/native/nativeaot/runtime-base/android-system.cc | Updates system property lookup to use shared HostEnvironment implementation |
src/native/nativeaot/include/host/host-environment-naot.hh | Adds NativeAOT-specific environment structure declarations and extern symbols |
src/native/nativeaot/include/host/host-environment.hh | Removes old NativeAOT-only environment class (file deleted) |
src/native/nativeaot/host/host.cc | Updates include to use new NativeAOT-specific header |
src/native/nativeaot/host/host-environment.cc | Refactors environment initialization to use templated approach for both variables and properties |
src/native/clr/xamarin-app-stub/application_dso_stub.cc | Updates system properties structure and adds JNI library flags to DSO cache entries |
src/native/clr/runtime-base/android-system.cc | Refactors to use shared HostEnvironment methods for setting variables and properties |
src/native/clr/include/xamarin-app.hh | Changes system properties from string array to AppEnvironmentVariable structure |
src/native/clr/include/host/host-environment.hh | Adds new shared HostEnvironment class with templated setter methods |
src/native/clr/include/host/host-environment-clr.hh | Minimal header to include CLR-specific environment dependencies |
src/Xamarin.Android.Build.Tasks/Utilities/NativeAotEnvironmentNativeAssemblyGenerator.cs | Adds system property generation using same structure as environment variables |
src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGeneratorCLR.cs | Refactors CLR system property generation to use unified structure |
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeAOT.targets | Switches from shared libc++ to static linking and removes conflicting libraries |
samples/NativeAOT/run.sh | Uncomments debug logging for testing |
samples/NativeAOT/environment.txt | Adds test system property |
samples/NativeAOT/NativeAOT.csproj | Includes environment.txt as AndroidEnvironment item |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Tested on our app and it still launches. The size decrease is ~2Mb (for single RID; compressed size). Before: com.emclient.mailclient-Signed.apk 71998960 (-9MB for the uncompressed |
Builds, installs, does nothing yet.
Linking seems to work, not tested yet
NativeAOT sample now links without errors about missing symbols (added linker options for it to fail if missing symbols are detected)
Need to have a think about it next week
5bf16bc
to
f3e1b3b
Compare
Context: # 8000 10461
A follow up to #10461 which adds some more compatibility with the "standard"
MonoVM and CoreCLR runtime hosts, namely:
(
<AndroidEnvironment>
MSBuild item)level) system properties
In addition to the above, it makes NativeAOT use static libc++ instead of the
shared one, which not only shrinks the package size (
libc++_shared.so
isaround 9mb), but it also makes startup slightly faster.