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 PrepareForILLink → ILLink
_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.
Summary
_AndroidComputeIlcCompileInputsinMicrosoft.Android.Sdk.NativeAOT.targetshardcodes the assumption that ILLink ran before ILC. It manually reads trimmed assemblies from$(IntermediateLinkDir)linked/and populatesIlcCompileInputandIlcReferencefrom there, bypassing the standardResolvedFileToPublishcontract.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
IlcCompileDependsOnunconditionally chainsPrepareForILLink→ILLink_AndroidBeforeIlcCompiledepends on_PrepareLinking(defined inTypeMap.LlvmIr.targets)_AndroidComputeIlcCompileInputsreads from$(IntermediateLinkDir)and@(ManagedAssemblyToLink)instead of@(ResolvedFileToPublish)_AndroidRunNativeCompiledepends on_PreTrimmingFixLegacyDesignerUpdateItems(also fromTypeMap.LlvmIr.targets)Proposed design
_AndroidComputeIlcCompileInputsshould populateIlcCompileInputandIlcReferencefrom@(ResolvedFileToPublish), matching the SDK's_ComputeIlcCompileInputscontract inMicrosoft.NETCore.Native.Publish.targets. When ILLink ran,ResolvedFileToPublishalready points at trimmed assemblies. When ILLink did not run, it has the originals.IlcCompileDependsOnshould conditionally includePrepareForILLink/ILLinkbased on_AndroidTypeMapImplementationRunILLink,SuppressTrimAnalysisWarnings,_ExtraTrimmerArgs) should be conditioned on_AndroidTypeMapImplementation != trimmableTypeMap.LlvmIr.targets(_PrepareLinking,_PreTrimmingFixLegacyDesignerUpdateItems) should be removed or conditionedContext
This content was created with assistance from AI.