Skip to content

Fix DuplicateRootAssembly assert failure#125032

Open
sbomer wants to merge 1 commit intodotnet:mainfrom
sbomer:duplicateRoot
Open

Fix DuplicateRootAssembly assert failure#125032
sbomer wants to merge 1 commit intodotnet:mainfrom
sbomer:duplicateRoot

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Mar 2, 2026

and add IL1048 error for multiple entrypoint roots

The Debug.Assert(entry_assembly is null) added in PR #116555 did not account for the same assembly being specified twice via different paths (e.g. 'test.exe' and '../input/test.exe'), which broke the existing DuplicateRootAssembly test.

Relax the assert to tolerate the same AssemblyDefinition object being set again, and add a proper IL1048 error when two different assemblies are both specified with 'entrypoint' root mode.

…tiple entrypoint roots

The Debug.Assert(entry_assembly is null) added in PR dotnet#116555 did not
account for the same assembly being specified twice via different paths
(e.g. 'test.exe' and '../input/test.exe'), which broke the existing
DuplicateRootAssembly test.

Relax the assert to tolerate the same AssemblyDefinition object being
set again, and add a proper IL1048 error when two *different* assemblies
are both specified with 'entrypoint' root mode.
Copilot AI review requested due to automatic review settings March 2, 2026 05:10
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Mar 2, 2026
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Mar 2, 2026
@dotnet-policy-service
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an illink debug assert regression when the same entrypoint root assembly is specified multiple times via different paths, and introduces a new diagnostic (IL1048) when different assemblies are both rooted using entrypoint mode.

Changes:

  • Relax Annotations.SetEntryPointAssembly debug assert to allow setting the same AssemblyDefinition more than once.
  • Emit IL1048 and stop processing when multiple distinct entrypoint root assemblies are specified.
  • Add a new command-line test case (and generated analyzer test hook) covering the multiple-entrypoint-roots error.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tools/illink/src/linker/Linker/Annotations.cs Allows re-setting the same entrypoint assembly without triggering a debug assert.
src/tools/illink/src/linker/Linker.Steps/RootAssemblyInputStep.cs Detects conflicting entrypoint roots and logs IL1048.
src/tools/illink/src/ILLink.Shared/DiagnosticId.cs Adds MultipleEntryPointRoots = 1048.
src/tools/illink/src/ILLink.Shared/SharedStrings.resx Adds title/message resources for IL1048.
src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/MultipleEntryPointRoots.cs New test verifying IL1048 is produced for multiple entrypoint roots.
src/tools/illink/test/Mono.Linker.Tests.Cases/CommandLine/Dependencies/MultipleEntryPointRoots_Lib.cs Dependency assembly used to create a second entrypoint root.
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/**/CommandLineTests.g.cs Adds generated test runner entry for the new test case.
Comments suppressed due to low confidence (1)

src/tools/illink/src/ILLink.Shared/DiagnosticId.cs:61

  • New diagnostic ID IL1048 was added, but docs/tools/illink/error-codes.md currently lists error codes only up through IL1046. Please add an entry documenting IL1048 (and consider also adding the missing IL1047 entry) so users can look up the new error code/message.
        MultipleEntryPointRoots = 1048,

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