Skip to content

Use explicit references for runtime library trimming - #137520

Open
sbomer wants to merge 3 commits into
mainfrom
sbomer/illink-explicit-references
Open

sbomer wants to merge 3 commits into
mainfrom
sbomer/illink-explicit-references

Conversation

@sbomer

@sbomer sbomer commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Runtime library trimming passes the existing selected reference files to ILLink through ReferenceAssemblyPaths instead of turning their directories into -d search paths. Reference selection and project-reference precedence remain unchanged. This lets task-cache eligibility track declared reference files and sidecars rather than scan directory contents. Custom extra arguments still run unchanged but are uncached; the linker CLI's -d option remains supported.

In the Linux runtime CI build, I compared 114 trim invocations (4,456 explicit references across 116 directories): there were no missing references or directories, unlisted directory candidates, or precedence differences. Modeled lookups for 678 assembly-reference names in the corresponding final runtime artifacts selected the same candidates for explicit-file and directory resolution, including a case-insensitive directory-lookup simulation. This evidence is limited to that Linux artifact, not every platform or the original pre-trim inputs. The local CoreCLR/libraries build was stopped by the host-memory safeguard, so a same-input linker replay was not run.

The ILLink task tests passed on Linux: 371 passed, 0 failed.

The unrelated Windows NET481 CS2012 generator-output race has since been fixed on main: #138062.

Note

This content was created with assistance from GitHub Copilot.

Preserve reference selection and project precedence while limiting task-cache input discovery to selected files. Keep custom directory arguments uncached and retain linker CLI directory resolution.

Assisted-by: GitHub Copilot CLI:Auto
Co-authored-by: Copilot <[email protected]>
Copilot-Session: cddd017d-74e2-49b6-827b-ccfada96f562
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Nov 13, 2026
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 13, 2026
@azure-pipelines

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.

Pass the selected references through ReferenceAssemblyPaths for custom
arguments too, removing the remaining -d construction. Remove the test that
imported eng/illink.targets; the linker fails on unresolved references, and
runtime library builds exercise the targets.

Assisted-by: GitHub Copilot CLI:Auto
Co-authored-by: Copilot <[email protected]>
Copilot-Session: cddd017d-74e2-49b6-827b-ccfada96f562

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.

🟡 Changes recommended

IgnoreUnresolved defaults to true, allowing missing dependencies to pass without failing the build; strict dependency validation and a regression test are still needed.

1 open issue
What changed in this PR

This PR switches runtime library trimming to explicit assembly references, narrowing ILLink cache inputs instead of scanning entire search directories.

Changes:

  • Pass selected references through ReferenceAssemblyPaths, keeping project references first.
  • Remove cache support for -d arguments while preserving uncached execution.
  • Update tests and documentation for explicit-reference hashing and cache bypass behavior.

Validation was limited to source inspection; no builds or tests were run.

File Description
src/​tools/​illink/​test/​ILLink.Tasks.Tests/​ILLink.Tasks.Tests.cs Tests reference sidecar hashing and search-directory cache bypass.
src/​tools/​illink/​src/​ILLink.Tasks/​LinkTask.cs Removes search-directory inventory from cache input discovery.
eng/​illink.targets Supplies explicit references with project-first ordering.
docs/​tools/​illink/​illink-tasks.md Documents supported cache inputs and -d bypass behavior.
docs/​design/​tools/​illink/​task-cache.md Updates the cache design for explicit references.

Review effort: Balanced

Comment thread eng/illink.targets Resolved

@am11 am11 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once the unresolved-assembly thread is addressed.

@sbomer
sbomer requested a review from jtschuster November 25, 2026 00:26
@sbomer

sbomer commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

/ba-g "Known failure, fixed by #138062"

@sbomer
sbomer enabled auto-merge (squash) November 25, 2026 00:26

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.

3 participants