Skip to content

Remove legacy LLVM IR type map build pipeline - #12889

Open
simonrozsival wants to merge 9 commits into
mainfrom
simonrozsival-remove-llvm-ir-typemap-build-pipeline
Open

simonrozsival wants to merge 9 commits into
mainfrom
simonrozsival-remove-llvm-ir-typemap-build-pipeline

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Stacked on #12887; base: simonrozsival-default-trimmable-typemap.

Summary

  • Remove the obsolete llvm-ir typemap targets and generators, native typemap output, marshal-method assembly rewriting, legacy Java-stub tasks, and dead after-link chain. Keep shared application configuration, NativeAOT bootstrap, Java remapping, and the empty native symbols still required until Remove legacy native typemap runtime support #12890.
  • Preserve the trimmable build behavior previously mixed into Default Android type maps to trimmable #12887 as six separate, scoped commits: CoreCLR additional process providers; pre-ILLink abstract-method repair on project-local assembly copies; effective-RID post-trim JCW selection and Proguard inputs; typemap assembly metadata and FastDeploy preference for linked/ReadyToRun DLLs; Java-library categorization before nested D8; and the deserialization callback trimmer root.
  • Keep the shared post-ILLink steps, LinkDescription, LinkerDumpDependencies, and incremental file tracking. Reject AndroidEnableMarshalMethods=true with XA1049 rather than accepting an unsupported path.

The default property and XA4265 validation remain in the small bottom PR. JVM-only test cleanup is in #12894; this PR does not replay the old bottom branch's broad CI and test-fixture changes.

Validation

  • 1,025 standalone trimmable typemap tests and 11 focused build-task tests passed (7 fixture-dependent cases skipped); the FastDeploy task project built without warnings or errors.
  • Changed XML and the target dependency graph were checked, as was the diff.
  • Full build-task, host, and device integration tests could not run here without the built in-tree Android SDK and generated generator.dll; CI must validate the combined path.

Copilot AI lite review requested due to automatic review settings September 23, 2026 06:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved provider-source generation and library llvm-ir runtime-jar issues remain, alongside a P/Invoke coverage gap.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This pull request removes the obsolete LLVM IR typemap and marshal-method pipelines while retaining trimmable typemaps, compatibility symbols, P/Invoke preservation, NativeAOT support, and remapping.

Changes:

  • Removes legacy typemap, Java-stub, marshal-rewriting, and post-link tasks.
  • Updates incremental native-source handling, tests, resources, and documentation.
  • Rejects unsupported marshal methods with XA1049.

Review findings:

  • Critical: Restore CoreCLR additional provider-source generation for secondary-process manifest providers.
  • Moderate: Add multi-ABI P/Invoke preservation coverage.
  • Moderate: Preserve or consistently reject legacy llvm-ir runtime-jar selection for libraries.
  • Nit: Update the native marshal source task description.
File Change
tests/​MSBuildDeviceIntegration/​Tests/​MarshalMethodsGCHangTests.cs Removes obsolete marshal-method device test.
tests/​MSBuildDeviceIntegration/​Tests/​InstallAndRunTests.cs Removes marshal-method test variants.
tests/​Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/​TypeDataBuilder.cs Adapts legacy entry generation.
tests/​Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/​ScannerRunner.cs Adds a legacy scanner entry helper.
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Removes legacy wiring and updates compatibility generation.
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Build.Tasks.csproj Removes obsolete sources and resources.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMappingReleaseNativeAssemblyGenerator.cs Deletes the legacy release generator.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMappingDebugNativeAssemblyGenerator.cs Deletes the legacy debug generator.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMappingAssemblyGenerator.cs Deletes the legacy generator base.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMapObjectsXmlFile.cs Deletes legacy typemap XML support.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMapGenerator.cs Deletes the legacy typemap generator.
src/​Xamarin.Android.Build.Tasks/​Utilities/​TypeMapCecilAdapter.cs Deletes the legacy Cecil adapter.
src/​Xamarin.Android.Build.Tasks/​Utilities/​PreservePinvokesNativeAssemblyGenerator.cs Decouples P/Invoke preservation from removed state.
src/​Xamarin.Android.Build.Tasks/​Utilities/​NativeTypeMappingData.cs Deletes legacy native mapping data.
src/​Xamarin.Android.Build.Tasks/​Utilities/​NativeCodeGenState.cs Deletes obsolete code-generation state.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MonoAndroidHelper.cs Simplifies assembly resolver setup.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MarshalMethodsState.cs Deletes obsolete marshal state.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MarshalMethodsNativeAssemblyGenerator.cs Generates compatibility native symbols.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MarshalMethodsHelpers.cs Deletes marshal helpers.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MarshalMethodsCollection.cs Deletes the marshal classifier collection.
src/​Xamarin.Android.Build.Tasks/​Utilities/​MarshalMethodCecilAdapter.cs Deletes marshal state conversion.
src/​Xamarin.Android.Build.Tasks/​Utilities/​ManifestDocument.cs Updates manifest-generation documentation.
src/​Xamarin.Android.Build.Tasks/​Utilities/​JCWGenerator.cs Deletes the legacy JCW generator.
src/​Xamarin.Android.Build.Tasks/​Utilities/​AssemblyPipeline.cs Removes marshal-method pipeline state.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​LlvmIrGeneratorTests.cs Tests compatibility stub generation.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​LinkerTests.cs Removes legacy typemap assertions.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​MarshalMethodTests.cs Deletes obsolete marshal tests.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​ManifestTest.cs Updates manifest-generation documentation.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​InvalidConfigTests.cs Removes an obsolete pipeline assertion.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​IncrementalBuildTest.cs Updates typemap paths and removes obsolete tests.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildTest2.cs Expands XA1049 validation coverage.
src/​Xamarin.Android.Build.Tasks/​Tasks/​RewriteMarshalMethods.cs Deletes the marshal rewriter task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​RemoveRegisterAttribute.cs Deletes the legacy attribute-removal task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​PreTrimmingFixLegacyDesigner.cs Deletes the legacy pre-trimming task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​PrepareAbiItems.cs Removes the legacy typemap mode.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GetMonoPlatformJar.cs Deletes the obsolete platform-jar task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateTypeMappings.cs Deletes the legacy mapping task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateNativeMarshalMethodSources.cs Retains compatibility and P/Invoke source generation.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateNativeApplicationConfigSources.cs Disables removed marshal state in app configuration.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateNativeAotLibraryLoadAssemblerSources.cs Updates resolver usage.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateNativeAotBootstrapSources.cs Simplifies bootstrap documentation.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateMainAndroidManifest.cs Deletes the legacy manifest task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateJavaStubs.cs Deletes the legacy Java-stub task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateJavaCallableWrappers.cs Deletes the legacy wrapper task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateEmptyTypemapStub.cs Retains stub generation with updated metadata handling.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateAdditionalProviderSources.cs Retains shared provider-generation helpers.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateACWMap.cs Deletes the legacy ACW map task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CreateTypeManagerJava.cs Deletes the obsolete Java resource task.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CollectTypeMapFilesForArchive.cs Deletes legacy archive collection.
src/​Xamarin.Android.Build.Tasks/​Tasks/​AssemblyModifierPipeline.cs Removes the marshal-method pipeline option.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.resx Updates XA1049 text.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.Designer.cs Updates generated XA1049 metadata.
src/​Xamarin.Android.Build.Tasks/​MSBuild/​Xamarin/​Android/​Xamarin.Android.Resource.Designer.targets Updates resource-designer trimming documentation.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.TypeMap.Trimmable.targets Preserves typemap stub items incrementally.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.BuildOrder.targets Removes obsolete post-link ordering.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.AssemblyResolution.targets Removes obsolete post-link dependency.
src/​Xamarin.Android.Build.Tasks/​Linker/​MonoDroid.Tuner/​FindTypeMapObjectsStep.cs Deletes the legacy linker scanner.
src/​Xamarin.Android.Build.Tasks/​Linker/​MonoDroid.Tuner/​FindJavaObjectsStep.cs Removes marshal-method-specific behavior.
Documentation/​docs-mobile/​messages/​xa1049.md Documents marshal-method removal.
Documentation/​docs-mobile/​messages/​index.md Updates the XA1049 index entry.
Documentation/​docs-mobile/​building-apps/​build-properties.md Documents obsolete property behavior.
Files not reviewed (1)
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file

@simonrozsival
simonrozsival force-pushed the simonrozsival-remove-llvm-ir-typemap-build-pipeline branch from 5866c12 to 6b8b57e Compare September 23, 2026 06:45
@simonrozsival
simonrozsival added this pull request to stack #12891 September 23, 2026 06:57
@simonrozsival
simonrozsival force-pushed the simonrozsival-remove-llvm-ir-typemap-build-pipeline branch 7 times, most recently from df2de16 to ab4d8d4 Compare September 24, 2026 08:22
@simonrozsival
simonrozsival force-pushed the simonrozsival-remove-llvm-ir-typemap-build-pipeline branch from 03fb13c to 31791c5 Compare September 24, 2026 13:46
Base automatically changed from simonrozsival-default-trimmable-typemap to main September 30, 2026 15:56
@simonrozsival
simonrozsival force-pushed the simonrozsival-remove-llvm-ir-typemap-build-pipeline branch from 85dd239 to 1ddbe25 Compare September 30, 2026 16:18
simonrozsival and others added 4 commits September 30, 2026 20:21
Keep native host compatibility stubs and P/Invoke preservation while removing unreachable typemap and marshal-method generation, rewriting, and linker steps.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use trimmable Java APIs for explicit library opt-ins without importing application type map targets, and retain the packaged CoreCLR/default jars for libraries without an implementation selection.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep generating additional Java runtime providers for trimmable CoreCLR apps after removing the legacy GenerateAdditionalProviderSources task. Register a dedicated task and track generated Java files for incremental Clean.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The shared CoreCLR provider generation is already supplied by main. Keep a single call while preserving the legacy typemap removals and upstream prelink fixes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the simonrozsival-remove-llvm-ir-typemap-build-pipeline branch from 1ddbe25 to d52cab0 Compare September 30, 2026 18:29
simonrozsival and others added 2 commits September 30, 2026 23:27
Exercise the supported typemap validation target instead of deleted build targets. Remove obsolete Cecil JCW/XML scanning from the no-shrink pipeline, retaining compatibility fixups and assembly copying, and update managed-typemap regression coverage.

Isolate relocation-test builds from persistent compiler and MSBuild servers without weakening move, incremental-build, or signing assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate main through c35205f, including PR #12976's collection-export and explicit-constructor JNI regressions. Resolve conflicts by retaining the deleted legacy scanners and unconditional assembly copying; preserve both managed typemap and JCW/Dex multi-TFM assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prior CoreCLR additional-provider finding is resolved. The deliberate LLVM-IR removal, unsupported marshal-method rejection and retained compatibility symbols are acceptable. The complete 67-file review and separate integration/completeness pass identify one conditional native-linking build blocker.

Filter or deduplicate typemap candidates before building the P/Invoke ABI dictionaries (GenerateNativeMarshalMethodSources.cs:163-174). With _AndroidEnableNativeRuntimeLinking=true, a trimmed CoreCLR build supplies both the final linked/ReadyToRun typemap assembly and its pre-trim copy to ScanPInvokes(). Final typemaps are published by CoreCLR.targets:317-329 and included in resolved assemblies by AssemblyResolution.targets:268-271; Trimmable.targets:419-430 additionally appends the pre-trim typemaps for the first ABI. Common.targets:1661-1666 passes that combined collection to the changed task.

Both copies of _Microsoft.Android.TypeMaps.dll, for example, have the same assembly-name key for arm64-v8a. GetPerArchAssemblies() calls Dictionary.Add for each input (MonoAndroidHelper.cs:758-768), so it throws before the subsequent framework-only filtering can exclude these non-framework candidates. validateCollection:false does not disable duplicate-key rejection. Native source generation therefore fails for this opt-in configuration. This is a concrete replacement-scanner/item-flow defect, not just the older request for more ABI test coverage, and does not require restoring any legacy LLVM behavior.

Exclude pre-trim/non-framework candidates before constructing the per-ABI dictionaries, or deduplicate by ABI and assembly name while preferring the final linked/ReadyToRun copy. Add a trimmed CoreCLR native-linking regression using the actual combined typemap inputs. The evidence comes from immutable task/target declarations and item-identity comparison; no MSBuild reproduction or repository tests were executed during this review.

Exclude non-framework assemblies through GetPerArchAssemblies' existing predicate before Dictionary.Add can encounter final/pre-trim typemap copies with the same ABI and name. Preserve framework-only scanning and per-ABI native symbols without changing packaging or native-config item collections.

Add linked/R2R task regressions with duplicate root/per-assembly typemap candidates, per-ABI framework PInvokes and ignored user PInvokes, plus trimmed multi-RID source-generation integration coverage. Both original task cases reproduced the duplicate _Microsoft.Android.TypeMaps key; both repaired production-source task cases pass. Full SDK integration tests require unavailable local Android build output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto Fixed the native-linking blocker in 872e037307.

ScanPInvokes() now uses the existing GetPerArchAssemblies(..., shouldSkip: ...) predicate to exclude non-framework assemblies before ABI/name dictionary insertion. This prevents linked/ReadyToRun and pre-trim typemap copies from colliding, while retaining ABI-specific framework scanning. Packaging and native-config item collections are unchanged; no legacy LLVM typemap code was restored.

Added two task regressions covering linked and R2R candidates for arm64/x64, duplicated root/per-assembly typemaps, separate per-ABI framework P/Invoke symbols, and exclusion of user/typemap P/Invokes. Both cases reproduce the original ArgumentException for duplicate key _Microsoft.Android.TypeMaps with the old task, and both pass with the fix. I executed the full task using production dictionary/helper methods, Cecil resolver/scanner, LLVM emitters and file-copy infrastructure in a temporary source-linked harness.

Also added TrimmedNativeLinkingScansCombinedTypeMapInputs with R2R on/off. It runs compilation and native-source generation for trimmed CoreCLR multi-RID builds, asserts that the actual input collection contains both pre-trim and final per-ABI root typemaps, and checks the generated preservation sources. These full-SDK integration cases were not run locally because the built Android SDK is absent; their assertion XML and the source diff checks passed. The task regressions were run locally; full integration confirmation remains for CI.

simonrozsival and others added 2 commits October 2, 2026 09:11
Compile defaults to DesignTimeBuild=true, which suppresses trimmable manifest generation before the explicit native-source target. Set DesignTimeBuild=false for this source-generation-only test invocation, preserving the linked/R2R and combined multi-ABI typemap assertions.

Verified both old invocations select design-time mode and both corrected invocations retain normal mode/stamp paths using the production Xamarin.Android.DesignTime.targets. Full Android SDK integration remains unavailable locally.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Scope Filename, Abi and _AndroidPreTrimTypeMapCandidate to _ResolvedAssemblies in the combined-typemap assertion. Missing optional metadata on resource-designer/framework/user items now evaluates per source item instead of raising MSB4096 during batching.

Ran the exact embedded assertion with linked and R2R item fixtures: reproduced both CI candidate-metadata errors, verified all three root selections with optional metadata absent, and confirmed six missing-root cases remain rejected. Full Android integration coverage still requires local SDK output unavailable here.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complete current cleanup and replacement paths are consistent with the accepted trimmable/NativeAOT design. The native-linking duplicate-key blocker is fixed by excluding non-framework inputs before ABI dictionary construction; supported provider, packaging, native configuration and compatibility-symbol paths remain integrated. No remaining high-confidence blockers found.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants