Repository navigation
[xabt] Invalidate linker cache when Android properties change - #13218
Conversation
Port the linker-cache fix from #13158 to main. Runtime switches share RID-specific linked outputs, but ILLink does not track build.props. Delete each RID's link semaphore when the Android property cache is newer so a CoreCLR-to-Mono switch cannot reuse incompatible assemblies. Keep unchanged builds incremental and leave MSBuildAllProjects alone. Add focused MSBuild coverage using the Android cache target and the SDK's linker incremental contract for both arm64 and x64. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2766caf5-8f62-405b-be06-72cebd330d0c
There was a problem hiding this comment.
🔵 Needs a closer look
Reported standalone tests pass, but the blocked SDK build leaves actual trimming and Mono AOT integration unverified.
No open issues 🎉
What changed in this PR
Prevents stale linked assemblies from being reused when Android build properties change, including switches between CoreCLR and MonoVM.
Changes:
- Invalidates each RID’s linker semaphore when the Android property cache is newer.
- Adds regression coverage for runtime switches, first builds, and unchanged-build skips across two RIDs.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets | Adds property-cache-driven linker invalidation. |
| src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/LinkerCacheTargetsTests.cs | Tests runtime-switch invalidation and incremental skips. |
Review effort: Balanced
Remove the separate target test and extend the existing post-trimming incremental build test. Check cached property changes and unchanged builds for arm64 and x64 using the real app build pipeline. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2766caf5-8f62-405b-be06-72cebd330d0c
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
The pre-link target invalidates each RID's linker semaphore when Android's property cache is newer, while unchanged property sets retain incremental skips. The extended CoreCLR regression covers changed and unchanged builds for arm64 and x64, and the actual SDK import/order and NativeAOT exclusion contracts remain consistent. Source review only; no linking or AOT execution is certified.
Port the linker-cache fix from #13158 to main.
When Android build properties change,
build.propschanges, but_RunILLinkdoes not track it. On the release branch, switching from CoreCLR to Mono can therefore reuse incompatible linked assemblies and fail Mono AOT withRuntime critical type System.Diagnostics.MonoStackFrame not found.Add the Android-owned
_AndroidInvalidateLinkerCachetarget from commit 3dd8d4e. Before linking, it deletes each RID's semaphore ifbuild.propsis newer. Unchanged builds still skip linking. No changes toMSBuildAllProjects. Main already has the runtime cache entries and the timestamp fix from #13144.Extend
PostTrimmingPipelineIsSkippedOnSecondBuildinIncrementalBuildTest.csto check cached property changes and subsequent unchanged builds for arm64 and x64. No new test file or test helpers.Validation:
.\dotnet-local.cmd test src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj --filter Name~PostTrimmingPipelineIsSkippedOnSecondBuild -v minimal -bl:bin\BuildDebug\incremental-linker-tests.binlog: test project builds, but both cases fail on the first app build with NETSDK1147: the local SDK is missingandroidandwasm-tools-net11workloads. Confirmed withbinlogtool search bin\TestDebug\temp\PostTrimmingPipelineIsSkippedOnSecondBuildarm64-v8a\build.binlog '$error'. The new assertions remain unverified..\build.cmd: previously attempted twice; SDK preparation stops at MSB3027/MSB3021 because a Java.Interop MSBuild task process locksXamarin.Android.Tools.AndroidSdk.dll. Full SDK and device validation remain blocked.git diff --cached --check: passed before commit.Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: