Fix NativeAOT assembly name mangling collisions#130012
Draft
Copilot wants to merge 5 commits into
Draft
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix AOT compilation error related to duplicate keys
Fix NativeAOT assembly name mangling collisions
Jun 30, 2026
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Contributor
Author
|
Addressed the review feedback in b4734ac89: the mangler now keys by EcmaAssembly, and the unit test was replaced with an end-to-end NativeAOT test under src/tests. |
| /// Dictionary given a mangled name for a given <see cref="TypeDesc"/> | ||
| /// </summary> | ||
| private Dictionary<TypeDesc, Utf8String> _mangledTypeNames = new Dictionary<TypeDesc, Utf8String>(); | ||
| private Dictionary<EcmaAssembly, Utf8String> _mangledAssemblyNames = new Dictionary<EcmaAssembly, Utf8String>(); |
Member
There was a problem hiding this comment.
Look like making this keyed on EcmaAssembly is problematic because we cannot load everything that is getting passed as input (some of the -r parameters specify garbage). Switch this back to being keyed on string where the string is the assembly file name without extension ("simple name").
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Remove="ManglerCollision.*\**" /> |
| @@ -0,0 +1,6 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
| <ItemGroup> | |||
Member
There was a problem hiding this comment.
Suggested change
| <ItemGroup> | |
| <PropertyGroup> | |
| <OutputType>Exe</OutputType> | |
| <CLRTestPriority>0</CLRTestPriority> | |
| </PropertyGroup> | |
| <ItemGroup> |
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
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.
Summary of changes
NativeAOT could generate duplicate mangled type names when different assembly names sanitized to the same C identifier, causing ILCompiler to fail with a duplicate-key exception.
System.Private.*assembly names.System.Private.*→S.P.*mangling without disambiguation.src/testswith colliding assembly names (A.BandA_B).Validation
./build.sh clr+libs+host./build.sh clr+libs+host./build.sh clr.aot+libs -rc Release -lc Releasesrc/tests/build.sh -nativeaot -test:nativeaot/SmokeTests/AssemblyNameCollision/AssemblyNameCollision.csproj x64 releaseartifacts/tests/coreclr/linux.x64.Release/nativeaot/SmokeTests/AssemblyNameCollision/AssemblyNameCollision.shPR Checklist
Issues in this repository are used to track work and discussions. Please create or link to an issue.