-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NativeAOT] improve build logic, part 2 (#9631)
Context: 8d77130 Context: #9630 We're exploring how to get .NET for Android apps to build and run using [Native AOT][0]. Default to `$(TrimMode)=Full` for NativeAOT, this enables trimmer warnings and should be the default mode for NativeAOT. Ensure the `_PrepareLinking` MSBuild target runs at the appropriate time. Failure to do so was causing `Android.App.Activity.GetOnCreate_Landroid_os_Bundle_Handler()` to be trimmed away. Various fixes to avoid `java.lang.UnsatisfiedLinkError` errors: * Set `$(LinkerFlavor)=lld` by default to avoid: E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__start___modules" referenced by "/data/app/~~_ggpMC4foLk_jUUycm0CfA==/net.dot.hellonativeaot-fvszIWroqgweLHYgULxVoQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a/libNativeAOT.so"... * Include `libc++_shared.so` within the app, as Native AOT output requires C++: E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found: needed by /data/app/~~_W0B9EE3hhajnFvCHyUKSg==/net.dot.hellonativeaot-zlXemqHdkbHaLu60oYPVQQ==/lib/arm64/libNativeAOT.so in namespace clns-6 Emit `JavaPeerStyle.JavaInterop1` java stubs for NativeAOT, as it is easier to get working in place of `JavaPeerStyle.XAJavaInterop1`. Specifically, we need to be able to avoid P/Invokes related to typemaps/etc. XAJavaInterop1 hits `JNIEnvInit.RegisterJniNatives()`, which is full of P/Invokes such as `TypeManager.GetClassName()`, while `JavaInterop1` hits `ManagedPeer.RegisterNativeMembers()` which goes through `JniRuntime` abstractions, allowing for a P/Invoke-free code path. I updated `BuildTest2.NativeAOT()` to assert for these changes where possible. [0]: https://learn.microsoft.com/dotnet/core/deploying/native-aot/
- Loading branch information
1 parent
df9ab24
commit 5f4d223
Showing
5 changed files
with
28 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters