Skip to content

Make ILLink task output ownership explicit - #135064

Open
sbomer wants to merge 2 commits into
mainfrom
sbomer/illink-output-ownership
Open

sbomer wants to merge 2 commits into
mainfrom
sbomer/illink-output-ownership

Conversation

@sbomer

@sbomer sbomer commented Oct 1, 2026

Copy link
Copy Markdown
Member

Make the ILLink task clear its output directory before execution instead of having the SDK targets delete only selected outputs. This prevents stale files from surviving a link and establishes the output ownership needed for whole-invocation caching.

Move the incremental-build semaphore outside that directory and give per-library trimming a dedicated output directory. Callers must keep inputs and unrelated intermediate files outside the task-owned directory; direct command-line linker behavior is unchanged.

This content was created with assistance from AI.

Move the incremental semaphore outside the output directory, let the task prepare a clean output directory, and give per-library trimming a dedicated output directory.

Assisted-by: Copilot:gpt-6-astra
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 561d1c87-e14b-46f8-be7f-a08f544ec537
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Oct 1, 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 dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Oct 1, 2026
@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.

Copilot review overview

🟡 Changes recommended

ExtraArgs can redirect output after the task cleans a different directory, defeating the ownership guarantee.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Makes ILLink task output ownership explicit by clearing dedicated output directories before execution.

Changes:

  • Cleans and recreates task output directories with failure handling and tests.
  • Moves incremental semaphores and per-library trim outputs outside task-owned directories.
  • Documents the new ownership contract.

One blocking issue remains: ExtraArgs can override -out, causing ILLink to write to an uncleared directory.

File Description
LinkTask.cs Adds output-directory cleanup.
Microsoft.NET.ILLink.targets Moves and invalidates the link semaphore.
eng/​illink.targets Introduces dedicated per-library output staging.
ILLink.Tasks.Tests.cs Tests cleanup, failures, and repeated execution.
Mock.cs Captures task errors for assertions.
illink-tasks.md Documents output ownership behavior.

Comment thread src/tools/illink/src/ILLink.Tasks/LinkTask.cs
@agocke

agocke commented Oct 2, 2026

Copy link
Copy Markdown
Member

Does iltrim need the same change?

…opt-out

Keep OutputDirectory authoritative over extra arguments when cleanup is enabled. Add an undocumented ClearOutputDirectory escape hatch that preserves legacy cleanup and argument precedence behavior.

Assisted-by: GitHub Copilot CLI:gpt-6-astra
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 561d1c87-e14b-46f8-be7f-a08f544ec537
@sbomer

sbomer commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

I don't think we have an ILTrim task yet, but once we do it should inherit this behavior.

@sbomer
sbomer requested a review from a team October 2, 2026 17:10

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.

4 participants