Skip to content

[NativeAOT] Decouple ILC input wiring from ILLink output #11182

@sbomer

Description

@sbomer

Summary

_AndroidComputeIlcCompileInputs in Microsoft.Android.Sdk.NativeAOT.targets hardcodes the assumption that ILLink ran before ILC. It manually reads trimmed assemblies from $(IntermediateLinkDir)linked/ and populates IlcCompileInput and IlcReference from there, bypassing the standard ResolvedFileToPublish contract.

This prevents the trimmable type map path from working with NativeAOT, because the trimmable path does not run ILLink — ILC should do its own trimming directly.

Current behavior

  • IlcCompileDependsOn unconditionally chains PrepareForILLinkILLink
  • _AndroidBeforeIlcCompile depends on _PrepareLinking (defined in TypeMap.LlvmIr.targets)
  • _AndroidComputeIlcCompileInputs reads from $(IntermediateLinkDir) and @(ManagedAssemblyToLink) instead of @(ResolvedFileToPublish)
  • _AndroidRunNativeCompile depends on _PreTrimmingFixLegacyDesignerUpdateItems (also from TypeMap.LlvmIr.targets)

Proposed design

  • _AndroidComputeIlcCompileInputs should populate IlcCompileInput and IlcReference from @(ResolvedFileToPublish), matching the SDK's _ComputeIlcCompileInputs contract in Microsoft.NETCore.Native.Publish.targets. When ILLink ran, ResolvedFileToPublish already points at trimmed assemblies. When ILLink did not run, it has the originals.
  • IlcCompileDependsOn should conditionally include PrepareForILLink/ILLink based on _AndroidTypeMapImplementation
  • ILLink-specific settings (RunILLink, SuppressTrimAnalysisWarnings, _ExtraTrimmerArgs) should be conditioned on _AndroidTypeMapImplementation != trimmable
  • Dependencies on targets from TypeMap.LlvmIr.targets (_PrepareLinking, _PreTrimmingFixLegacyDesignerUpdateItems) should be removed or conditioned

Context

This content was created with assistance from AI.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions