Skip to content

Replay linker diagnostics on ILLink task cache hits - #136405

Merged
sbomer merged 12 commits into
mainfrom
sbomer/illink-cache-warning-replay
Nov 11, 2026
Merged

sbomer merged 12 commits into
mainfrom
sbomer/illink-cache-warning-replay

Conversation

@sbomer

@sbomer sbomer commented Oct 23, 2026

Copy link
Copy Markdown
Member

Replay linker diagnostics through normal task logging on cache hits, so MSBuild's current warning policy still applies. Previously, a successful warning-producing invocation could seed the cache and a later -warnaserror build would incorrectly succeed because the hit omitted the warnings.

This is the same class of issue as dotnet/roslyn#86198.

Note

This content was created with assistance from AI.

Assisted-by: GitHub Copilot CLI:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83c1f7dd-040c-4e6a-b365-9c4493526616
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Oct 23, 2026
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Oct 23, 2026
@azure-pipelines

azure-pipelines Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

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.

🔵 Needs a closer look

Human confirmation is needed for warning escalation against real MSBuild because builds and regression tests were not run during this review.

No open issues 🎉

What changed in this PR

This PR makes ILLink task cache hits replay linker diagnostics through normal task logging, allowing MSBuild’s current warning policy to apply to cached results.

Changes:

  • Capture linker output and persist it with integrity metadata in cache entries.
  • Replay diagnostics after successful restoration and fail cache hits when logging reports errors.
  • Add regression coverage for warning policies, malformed diagnostics, and restore failures, and update cache documentation.
File Description
src/​tools/​illink/​test/​ILLink.Tasks.Tests/​Mock.cs Records warnings and adds a warning-policy build engine mock.
src/​tools/​illink/​test/​ILLink.Tasks.Tests/​ILLink.Tasks.Tests.cs Adds diagnostic replay, warning escalation, and cache validation tests.
src/​tools/​illink/​src/​ILLink.Tasks/​LinkTask.cs Captures tool output and replays it using normal task logging.
src/​tools/​illink/​src/​ILLink.Tasks/​ILLinkCache.cs Stores, validates, and restores cached diagnostics.
docs/​tools/​illink/​illink-tasks.md Documents diagnostic replay and current warning-policy behavior.
docs/​design/​tools/​illink/​task-cache.md Updates cache interfaces, entry layout, and replay guarantees.

Review effort: Balanced

Assisted-by: GitHub Copilot CLI:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83c1f7dd-040c-4e6a-b365-9c4493526616

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.

🔵 Needs a closer look

Cached message importance can override current task logging settings and hide output that fresh execution would display.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Cache replay ignores current output importance settings

src/​tools/​illink/​src/​ILLink.Tasks/​ILLinkCache.cs:142

Replaying the saved importance ignores the current StandardOutputImportance and StandardErrorImportance, neither of which is included in TryComputeCacheKey. An entry populated with stdout at Low still replays at Low after the caller requests High, hiding ordinary messages that a fresh invocation would display. Include these settings in the cache key, or preserve each line's originating stream and apply its current importance during replay.

Review effort: Balanced

Assisted-by: GitHub Copilot CLI:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83c1f7dd-040c-4e6a-b365-9c4493526616

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.

🔵 Needs a closer look

The new tests were not executed, leaving warning-policy behavior under a real MSBuild host unverified and requiring human confirmation.

No open issues 🎉

Review effort: Balanced

Record original stdout/stderr lines independently of task logging policy. Apply the current stream importance, stderr-as-error setting, and MSBuild warning policy on hits rather than keying logging settings.

Assisted-by: GitHub Copilot CLI:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83c1f7dd-040c-4e6a-b365-9c4493526616

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.

🔵 Needs a closer look

Asynchronous output capture and MSBuild warning-policy parity need execution-level validation; builds and tests were not run.

No open issues 🎉

Review effort: Balanced

sbomer and others added 2 commits October 29, 2026 11:06
Preserve warning capture and replay in the shared invocation cache. Update the shared manifest test to validate the diagnostics record.

Assisted-by: GitHub Copilot CLI:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
Capture and store stdout and stderr separately, preserving line order within each stream and replaying them in a fixed stream order. Return diagnostics from execution and restore while keeping capture lifetime and logging policy in the task.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
sbomer and others added 2 commits October 30, 2026 11:36
Let the cache trigger replay after successful restoration while CachedToolTask owns capture and ToolTask logging policy. Keep ILLink-specific discovery and output preparation in ILLink.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
Return cache-owned capture buffers only on misses and narrow replay to the diagnostic streams. Store successful tool results even when current MSBuild logging policy fails the task, while preserving failure and replay behavior.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
sbomer and others added 4 commits November 10, 2026 11:52
Move cache creation and lazy input discovery into CachedToolTask, passing the description directly to the cache instance. Keep TryCreateFromEnvironment unchanged and retain cache-owned validation, timestamping, hashing, and restoration.

Build and test validation deferred because the shared-host memory reserve was unavailable.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
Capture eligible executions without live logging, then replay raw stdout and stderr through the current ToolTask policy on both misses and hits. Preserve EOF notifications and partial output on exceptions, and keep bypass logging unchanged.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
Replace pending invocation preparation and completion with a cache execution callback returning the task-owned capture result. Preserve unified replay, uncached execution, and partial-output replay and cleanup on exceptions.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144
Use sequential cache guards and one uncached execution call site without wrapping uncached output in an invocation result. Preserve logging-based exit normalization, simplify capture allocation, and document buffer ownership and replay ordering rationale.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1816be82-3e42-462e-a6e3-76e479aa7144

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.

🔵 Needs a closer look

Runtime validation was unavailable for ToolTask’s asynchronous output interception, leaving cancellation, timeout, callback completion, and MSBuild warning-policy behavior unverified.

No open issues 🎉

Review effort: Balanced

@sbomer

sbomer commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

/ba-g "deadletter"

@sbomer
sbomer merged commit 54c361f into main Nov 11, 2026
158 of 161 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 11, 2026
@sbomer
sbomer deleted the sbomer/illink-cache-warning-replay branch November 11, 2026 23:04
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants