[TrimmableTypeMap] Fix trimmable typemap single-RID release builds#11499
Open
simonrozsival wants to merge 9 commits into
Open
Conversation
Add a Release CoreCLR HelloWorld comparison test that builds llvm-ir and trimmable typemap APKs, prints managed and dex diagnostics, and asserts the trimmable typemap does not retain extra typemap-eligible managed or Java entries. Pass all generated typemap assemblies to ILLink as typemap entry assemblies and mark them trimmable so conditional typemap entries are honored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generate proguard keep rules for the CoreCLR trimmable typemap path from the linked assemblies, matching the llvm-ir path, and make the APK comparison test use R8 so dex contents are actually shrunk. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Limit --typemap-entry-assembly arguments to generated per-assembly *.TypeMap.dll assemblies that contain TypeMapAttribute entries, instead of treating the root typemap loader assembly as an entry assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep SDK framework ACWs conditional unless they are explicitly rooted, and pass framework assembly names through trimmable typemap generation. This allows Mono.Android implementor entries to be trimmed while preserving app ACWs and scanner-rooted components. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Emit array typemap sentinels when dynamic code support is explicitly disabled so CoreCLR trimmable typemap builds can use the no-dynamic-code array path. Keep DynamicCodeSupport enabled by default and cover the explicit opt-out path in tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the APK comparison test scaffolding from this split branch while keeping the DynamicCodeSupport coverage for trimmable typemaps.
Scan linked assemblies after ILLink to filter generated Java wrappers and acw-map inputs before R8, while packaging only linked typemap assemblies for single-RID builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CoreCLR Release builds using the trimmable typemap when building with a single RuntimeIdentifier, ensuring that packaging/R8 inputs are based on the linked (post-ILLink) view of the app rather than unlinked typemap artifacts. It also adds dedicated XA42xx coded errors and documentation for new failure modes, plus a regression test covering the single-RID scenario.
Changes:
- Add a Release CoreCLR single-RID regression test to ensure unlinked typemap assemblies are not packaged and post-trim R8 inputs exclude dead framework implementors.
- Extend
GenerateTrimmableTypeMapto optionally skip typemap assembly generation, clean Java output directories safely, and copy Java sources from a pre-trim directory (with XA4254/XA4255 errors). - Update trimmable typemap MSBuild targets to support post-trim Java/acw-map regeneration and to locate linked typemap DLLs for both single- and multi-RID layouts.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Adds end-to-end Release CoreCLR single-RID test and APK/DEX assertions. |
| src/Xamarin.Android.Build.Tasks/Tasks/GenerateTrimmableTypeMap.cs | Adds post-trim Java source copy mode, output cleanup, and XA4254/XA4255 errors. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Adds XA4254/XA4255 messages. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Regenerates strongly-typed resources for XA4254/XA4255. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets | Introduces post-trim Java output/stamp properties for CoreCLR PublishTrimmed flows. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.CoreCLR.targets | Adds post-trim typemap scan target and fixes linked typemap DLL discovery for single-RID builds. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.cs | Allows skipping typemap assembly generation while still producing peer scan results/Java source lists. |
| Documentation/docs-mobile/messages/xa4254.md | Documents XA4254. |
| Documentation/docs-mobile/messages/xa4255.md | Documents XA4255. |
| Documentation/docs-mobile/messages/xa4253.md | Fixes code block formatting. |
| Documentation/docs-mobile/messages/index.md | Adds XA4254/XA4255 entries to the message index. |
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Language not supported
Comment on lines
+28
to
+32
| <_TypeMapJavaStubsSourceDirectory Condition=" '$(_TypeMapJavaStubsSourceDirectory)' == '' and '$(_AndroidRuntime)' == 'CoreCLR' and '$(PublishTrimmed)' == 'true' ">$(_PostTrimTypeMapJavaOutputDirectory)</_TypeMapJavaStubsSourceDirectory> | ||
| <_TypeMapJavaStubsSourceDirectory Condition=" '$(_TypeMapJavaStubsSourceDirectory)' == '' ">$(_TypeMapJavaOutputDirectory)</_TypeMapJavaStubsSourceDirectory> | ||
| <_PostTrimTrimmableTypeMapJavaStamp>$(_TypeMapBaseOutputDir)stamp/_GeneratePostTrimTrimmableTypeMapJavaSources.stamp</_PostTrimTrimmableTypeMapJavaStamp> | ||
| <_TrimmableJavaSourceStamp Condition=" '$(_TrimmableJavaSourceStamp)' == '' and '$(_AndroidRuntime)' == 'CoreCLR' and '$(PublishTrimmed)' == 'true' ">$(_PostTrimTrimmableTypeMapJavaStamp)</_TrimmableJavaSourceStamp> | ||
| <_TrimmableJavaSourceStamp Condition=" '$(_TrimmableJavaSourceStamp)' == '' ">$(_TypeMapOutputDirectory)$(_TypeMapAssemblyName).dll</_TrimmableJavaSourceStamp> |
Copy Java stubs from the selected typemap source directory so CoreCLR trimmed builds use the post-link source set instead of stale pre-trim Java files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment was marked as low quality.
This comment was marked as low quality.
ac57cc4 to
2c25481
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Splits the single-RID build fix out of #11346.
This PR is stacked on #11498 and includes the post-trim trimmable typemap scan/R8 input fixes plus coded task errors.