Fix DuplicateRootAssembly assert failure#125032
Open
sbomer wants to merge 1 commit intodotnet:mainfrom
Open
Conversation
…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.
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/illink |
Contributor
There was a problem hiding this comment.
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.SetEntryPointAssemblydebug assert to allow setting the sameAssemblyDefinitionmore than once. - Emit IL1048 and stop processing when multiple distinct
entrypointroot 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,
jtschuster
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.