[TrimmableTypeMap] Remove post-trim generation pass#11604
Open
simonrozsival wants to merge 1 commit into
Open
Conversation
Generate the trimmable typemap once before trimming and reuse the generated Java sources instead of running GenerateTrimmableTypeMap again after ILLink. Keep the linked/R2R typemap assembly packaging path from the previous fix, and remove diagnostics that only supported the deleted post-trim Java copy path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the “post-trim” TrimmableTypeMap Java generation/copy pass (and its associated task switches + error codes/docs), returning to a single pre-trim typemap generation model while keeping the previously-added single-RID CoreCLR packaging fix and its regression coverage.
Changes:
- Removed the CoreCLR post-trim
_GeneratePostTrimTrimmableTypeMapJavaSourcestarget and the second typemap generation pass after ILLink. - Simplified
GenerateTrimmableTypeMap+TrimmableTypeMapGeneratorby removing the “copy from input dir”/“skip assembly generation” modes and associated XA4254/XA4255 resources + docs. - Updated the regression test to focus on verifying the APK packages the linked/R2R typemap assemblies (dropping the post-trim R8/acw-map assertions).
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Removes post-trim R8/acw-map assertions from the single-RID trimmable CoreCLR packaging regression test. |
| src/Xamarin.Android.Build.Tasks/Tasks/GenerateTrimmableTypeMap.cs | Removes post-trim copy/clean switches and always writes typemap assemblies + Java sources in a single mode. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Removes XA4254/XA4255 resource strings tied to the deleted post-trim Java copy path. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Removes the generated accessors for XA4254/XA4255. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets | Removes linked-java path plumbing; always uses the pre-trim typemap Java output directory for stub copying. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.CoreCLR.targets | Deletes the post-trim typemap Java generation target that ran after ILLink. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.cs | Removes the optional “skip typemap assemblies” mode; generator always produces typemap assemblies. |
| Documentation/docs-mobile/messages/xa4254.md | Deletes docs for XA4254, now that the code path is removed. |
| Documentation/docs-mobile/messages/xa4255.md | Deletes docs for XA4255, now that the code path is removed. |
| Documentation/docs-mobile/messages/index.md | Removes XA4254/XA4255 from the error code index. |
Copilot's findings
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Language not supported
- Files reviewed: 9/10 changed files
- Comments generated: 1
Comment on lines
120
to
121
| Directory.CreateDirectory (OutputDirectory); | ||
| if (CleanJavaSourceOutputDirectory && Directory.Exists (JavaSourceOutputDirectory)) { | ||
| Directory.Delete (JavaSourceOutputDirectory, recursive: true); | ||
| } | ||
| Directory.CreateDirectory (JavaSourceOutputDirectory); |
This was referenced Jun 8, 2026
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.
Summary
This PR partially backs out #11499, but intentionally keeps the part that fixed single-RID CoreCLR packaging.
#11499 mixed two separate changes:
_GeneratePostTrimTrimmableTypeMapJavaSourcestargetGenerateTrimmableTypeMapinvocation after ILLinkJavaSourceInputDirectory,GenerateTypeMapAssemblies=false,CleanJavaSourceOutputDirectory,generateTypeMapAssemblies)typemap/linked-javaJava source copy/filtering pathResolvedFileToPublishtypemap/java/**/*.javaoutputs after the post-trim pass removalandroid/srccopies, and includestypemap/in intermediate cleanThe conceptual fix is: the trimmable typemap should be generated once before trimming and then reused. Running
GenerateTrimmableTypeMapagain after trimming invalidates the cache and defeats the point of the trimmable typemap design.The Java-source cleanup is intentionally scoped to the current whole-world generator model: when
_GenerateTrimmableTypeMapruns, the task has the full current desired Java source set, so files undertypemap/javathat were not emitted by that pass are stale and can be deleted. No-op incremental builds where_GenerateTrimmableTypeMapis skipped do not clean that directory.The future per-assembly incremental split is tracked separately by #11494; that design will need a more explicit Java-output ownership/reconciliation model before this can become partial per assembly.
Are single-RID builds still fixed?
Yes. The single-RID fix from #11499 is still present:
_AddTrimmableTypeMapToResolvedFileToPublishadds linked typemap assemblies to the publish pipeline, and_UseReadyToRunTrimmableTypeMapAssembliesForPublishswaps in R2R typemap assemblies when applicable.The retained regression test builds a trimmable CoreCLR single-RID APK (
RuntimeIdentifier=android-arm64,TrimMode=full,AndroidLinkTool=r8) and verifies the APK packages the linked/R2R typemap assemblies instead of stale pre-link typemap assemblies.Validation
Previous validation:
make prepare./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -c Debug -v:minimal./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name=ReleaseCoreClrTrimmableTypeMap_SingleRuntimeIdentifier_PackagesLinkedOrReadyToRunTypeMapAssemblies"Latest cleanup update:
git diff --checkExecute_DeletesStaleGeneratedJavaSourcesBuild_WithTrimmableTypeMap_DeletesStaleGeneratedJavaSourcesAndCopiesNote: local
make allstill fails in unrelated Java.Interop CMake setup becauseclang++cannot link libc++ (ld: library 'c++' not found).