Migrate StripEmbeddedLibraries from ILLink step#10695
Open
Conversation
Member
|
There are |
Member
Author
|
And similarly on linux: |
…ded-step # Conflicts: # src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
There was a problem hiding this comment.
Pull request overview
This PR migrates the StripEmbeddedLibraries class from an ILLink custom step to an IAssemblyModifierPipelineStep. The class is renamed to StripEmbeddedLibrariesStep and refactored to work with the AssemblyModifierPipeline infrastructure instead of relying on ILLink's BaseStep and Annotations API.
Changes:
- Renamed and refactored
StripEmbeddedLibrariestoStripEmbeddedLibrariesStepimplementingIAssemblyModifierPipelineStep - Integrated the step into
AssemblyModifierPipeline.BuildPipelinebetweenFindJavaObjectsStepandSaveChangedAssemblyStep - Removed ILLink custom step registration from
Microsoft.Android.Sdk.TypeMap.LlvmIr.targets
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj |
Added StripEmbeddedLibrariesStep.cs to compilation |
src/Xamarin.Android.Build.Tasks/Tasks/AssemblyModifierPipeline.cs |
Integrated the new step into the pipeline before SaveChangedAssemblyStep |
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets |
Removed the ILLink custom step registration for StripEmbeddedLibraries |
src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/StripEmbeddedLibrariesStep.cs |
Refactored from BaseStep to IAssemblyModifierPipelineStep, updated to use StepContext and TaskLoggingHelper |
…g to separate output directory _AfterILLinkAdditionalSteps was reading and writing assemblies to the same file path (@(ResolvedAssemblies) for both SourceFiles and DestinationFiles). This caused a crash in Mono.Cecil when SaveChangedAssemblyStep wrote a modified assembly back to the same memory-mapped file it was read from, triggering an AccessViolationException in PatchRawMethodBody. Fix by writing outputs to $(MonoAndroidIntermediateAssemblyDir), matching the pattern used by _LinkAssembliesNoShrink. This also enables proper file-list-based incrementalism and preserves ILLink outputs for correct incremental builds.
…pping mixed-mode metadata Mono.Cecil cannot write mixed-mode assemblies, throwing NotSupportedException. Before writing, strip R2R metadata (set ILOnly, clear ILLibrary, reset Architecture) matching ILLink's OutputStep behavior. The native R2R code is discarded since the assembly was modified and would need re-crossgen anyway.
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.
Changes this from an ILLink step to run in AssemblyModifierPipeline.
I'm hitting some failures locally that might have to do with the modiifier pipeline modifying assemblies in-place - opening this to see if it repros in ci.