-
Notifications
You must be signed in to change notification settings - Fork 561
[coreclr] Initial support of R2R builds #10007
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a3e300
Enable R2R builds
ivanpovazan 772de8e
Add R2R build tests
ivanpovazan de98b73
Update src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Te…
ivanpovazan 619186b
Use better verification method that app assembly in the apk has R2R i…
ivanpovazan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,12 +156,27 @@ public void BasicApplicationPublishReadyToRun (bool isComposite, string rid) | |
| proj.SetProperty ("UseMonoRuntime", "false"); // Enables CoreCLR | ||
| proj.SetProperty ("_IsPublishing", "true"); // Make "dotnet build" act as "dotnet publish" | ||
| proj.SetProperty ("PublishReadyToRun", "true"); // Enable R2R | ||
| proj.SetProperty ("AndroidEnableAssemblyCompression", "false"); | ||
|
|
||
| if (isComposite) | ||
| proj.SetProperty ("PublishReadyToRunComposite", "true"); // Enable R2R composite | ||
|
|
||
| var b = CreateApkBuilder (); | ||
| Assert.IsTrue (b.Build (proj), "Build should have succeeded."); | ||
|
|
||
| var assemblyName = proj.ProjectName; | ||
| var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, rid, $"{proj.PackageName}-Signed.apk"); | ||
| FileAssert.Exists (apk); | ||
|
|
||
| var helper = new ArchiveAssemblyHelper (apk, true); | ||
| var abi = MonoAndroidHelper.RidToAbi (rid); | ||
| Assert.IsTrue (helper.Exists ($"assemblies/{abi}/{assemblyName}.dll"), $"{assemblyName}.dll should exist in apk!"); | ||
|
|
||
| using var stream = helper.ReadEntry ($"assemblies/{assemblyName}.dll"); | ||
| stream.Position = 0; | ||
| using var peReader = new System.Reflection.PortableExecutable.PEReader (stream); | ||
| Assert.IsTrue (peReader.PEHeaders.CorHeader.ManagedNativeHeaderDirectory.Size > 0, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonathanpeppers I used the recommendation from: dotnet/runtime#38440 (comment) to verify that the app main assembly that gets packed into the .apk has R2R image in it. |
||
| $"ReadyToRun image not found in {assemblyName}.dll! ManagedNativeHeaderDirectory should not be empty!"); | ||
| } | ||
|
|
||
| [Test] | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you update this line for when
$(PublishReadyToRun)is true:android/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets
Line 34 in 747041d
I would expect
dotnet build -c Release -p:PublishReadyToRun=trueto work by default on Android.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.
We could make this as a temporary workaround for R2R as well.
However, on the long run we shouldn't force
dotnet build -c Release -p:PublishReadyToRun=trueto do publishing as that would not match the behavior on other platforms.On desktop and on iOS, triggering NativeAOT builds only happens with
dotnet publish,dotnet builduses "regular" default runtimes/builds -> CoreCLR desktop, Mono iOSThere 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.
Just for reference, MAUI on Windows uses
PublishReadyToRun=trueby default onReleasebuilds since .NET 7:If R2R is what makes the startup performance reasonable, I think we have to use it by default on Android as well? So,
dotnet build -c Releaseon Android would use R2R?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.
That only applies if you are publishing your app through Visual Studio, or manually through
dotnet publish.dotnet buildwill not / should not run publish targets whenPublishReadyToRun=true.On a regular console app if you add
PublishReadyToRun=trueto the project and rundotnet buildit will not run R2R AOT compiler. But if you rundotnet publishit will.So to come back to my previous comment, we should not force
_IsPublishing=truefor NativeAOT nor R2R just so we would makedotnet build -p:PublishAOT=trueordotnet build -p:PublishReadyToRun=trueto run/act likedotnet publish, it is against the behavior we have on other platforms (e.g., on macios we solved it with yet another property: https://github.com/dotnet/macios/blob/7cef45367161ca26d3a68e2e096639194ed4df1f/dotnet/targets/Xamarin.Shared.Sdk.props#L39)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.
The difference is people can actually ship their app with
dotnet build -c Releasefor Android today (and they are). There is currently no requirement to usedotnet publishon Android.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.
As per our offline discussion, we will address this in the follow-up work of fully enabling R2R builds