Skip to content

Enable root-relative ILLink task cache sharing - #135320

Draft
sbomer wants to merge 1 commit into
sbomer/illink-task-cachefrom
sbomer/illink-cache-worktree-sharing
Draft

sbomer wants to merge 1 commit into
sbomer/illink-task-cachefrom
sbomer/illink-cache-worktree-sharing

Conversation

@sbomer

@sbomer sbomer commented Oct 7, 2026

Copy link
Copy Markdown
Member

Allow eligible ILLink task cache entries to be shared across worktrees with equivalent layouts. Map declared source roots into stable cache identities while retaining full content hashing, and run single-root invocations from that root with structured relative arguments rather than rewriting raw command strings.

Caching remains opt-in, with compiler and symbol-preservation defaults unchanged. Unsupported inputs run uncached with their original arguments and working directory. Runtime's existing raw arguments still bypass caching on this base; structured runtime integration is separate. Validated with 281 task tests, both task build targets, and a two-worktree hit matching independently linked DLL/PDB bytes; Windows execution and full runtime builds were not run.

Note

This pull request description was created with assistance from GitHub Copilot.

Map declared source roots into structured cache identity and use relative execution arguments for eligible single-root invocations. Retain full content hashing, conservative symbol and resolution checks, and original execution for uncached requests.

Assisted-by: Copilot:gpt-6.1-sol
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: cf203c67-3550-4744-a063-3f1230546d53
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Oct 7, 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.

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

Untracked assembly-resolution paths and Windows drive-root rewriting can produce unsound cache keys.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Adds root-relative ILLink cache identities so equivalent worktrees can share eligible cached outputs.

Changes:

  • Maps source-root paths into stable cache keys and relative invocations.
  • Expands cache eligibility checks and input hashing.
  • Adds target wiring, documentation, and extensive tests.
File Description
LinkTask.cs Implements path mapping and cache validation.
Microsoft.NET.ILLink.targets Forwards SDK source roots.
Mock.cs Captures cache invocation details.
ILLink.Tasks.Tests.cs Tests sharing, eligibility, and fallback behavior.
eng/​illink.targets Defines the runtime repository source root.
sfx-finish.proj Forwards source roots for framework trimming.
oob-trim.proj Forwards source roots for OOB trimming.
illink-tasks.md Documents task behavior and configuration.
task-cache.md Updates cache design decisions.

Comment on lines +458 to +459
foreach (var argument in extraPaths)
cacheableExtraArgs.Append(argument.Option).Append(' ').AppendLine(Quote(renderPath(argument.Path)));
Comment on lines +561 to +567
foreach (AssemblyReferenceHandle reference in metadata.AssemblyReferences)
{
if (HasPathSyntax(metadata.GetString(metadata.GetAssemblyReference(reference).Name)))
{
Log.LogMessage(MessageImportance.Low, "ILLink cache bypassed: Path-shaped assembly references can resolve outside the input inventory.");
return false;
}
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Oct 7, 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.

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