Skip to content

Replay linker diagnostics on ILLink task cache hits - #136405

Draft
sbomer wants to merge 7 commits into
mainfrom
sbomer/illink-cache-warning-replay
Draft

sbomer wants to merge 7 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

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 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
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

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

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants