Repository navigation
Closed
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers
Milestone
Description
Description
Hi!
We're migrating our iOS project from .NET 8 to .NET 10 and we're seeing a lot of trimmer warnings. Of course we should aim to get this down to 0, but our projects work with .NET 8 so we're hoping this to be a simple upgrade for now. However, we're encountering an error when building the project:
ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://aka.ms/report-illink
Fatal error in IL Linker
Unhandled exception. System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
at Mono.Linker.MessageOrigin.ToString()
at Mono.Linker.MessageContainer.ToMSBuildString()
at Mono.Linker.LinkContext.LogMessage(MessageContainer message)
at Mono.Linker.LinkContext.FlushCachedWarnings()
at Mono.Linker.Steps.ProcessWarningsStep.Process()
at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
/Users/smgi/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/Microsoft.NET.ILLink.targets(103,5): error NETSDK1144: Optimizing assemblies for size failed.
It looks like one of the warning messages are breaking the process.
Reproduction Steps
- Clone + checkout smoogipoo/osu@1a3eb1c.
- Go into the
osu.iOSsubdirectory. dotnet workload restore+dotnet build.
Expected behavior
The build to pass, albeit with warnings.
Actual behavior
The build fails with the exception above.
Regression?
This build previously worked in .NET 8.
Known Workarounds
Compiling with /p:SuppressTrimAnalysisWarnings=true fixes the issue.
Configuration
$ dotnet --info
.NET SDK:
Version: 10.0.300
Commit: caa81fa497
Workload version: 10.0.301.1
MSBuild version: 18.6.3+caa81fa49
Runtime Environment:
OS Name: Mac OS X
OS Version: 26.3
OS Platform: Darwin
RID: osx-arm64
Base Path: /Users/smgi/.dotnet/sdk/10.0.300/
.NET workloads installed:
[ios]
Installation Source: SDK 10.0.300
Manifest Version: 26.5.10284/10.0.100
Manifest Path: /Users/smgi/.dotnet/sdk-manifests/10.0.100/microsoft.net.sdk.ios/26.5.10284/WorkloadManifest.json
Install Type: FileBased
Configured to use workload sets when installing new manifests.
Host:
Version: 10.0.8
Architecture: arm64
Commit: 94ea82652c
.NET SDKs installed:
8.0.421 [/Users/smgi/.dotnet/sdk]
10.0.300 [/Users/smgi/.dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.27 [/Users/smgi/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.8 [/Users/smgi/.dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.27 [/Users/smgi/.dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.8 [/Users/smgi/.dotnet/shared/Microsoft.NETCore.App]
Other information
No response
Metadata
Metadata
Assignees
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers
Type
Projects
- StatusShow more project fieldsNo status
Activity
sbomer commentedon Jun 25, 2026
I was able to reproduce and narrow this down.
The crash happens while ILLink is formatting cached trim warnings, not while performing the trim analysis itself. Specifically,
MessageOrigin.ToString()assumes there is at least one PDB sequence point at or before the warning's IL offset:For this repro, there are
IL2026warnings from Realm-woven backlink getters:Both generated getters call:
The warning origin points at the
AsQueryablecall at IL offset41/0x29, but the method's first PDB sequence point is at offset51/0x33. That makes the filtered sequence-point set empty, soLast()throws:Suppressing only
IL2026avoids the crash in the repro, while suppressing the other emitted trim-warning codes does not.SuppressTrimAnalysisWarnings=trueworks because it prevents these cached trim-analysis warnings from being flushed/formatted.Likely fix: make
MessageOrigin.ToString()tolerate IL offsets before the first sequence point, e.g. useLastOrDefault()and fall back to method-level/no-source origin or the first non-hidden sequence point instead of assuming a matching sequence point exists.This content was created with assistance from AI.
Handle ILLink origins before first sequence point (#129869)
Handle ILLink origins before first sequence point (#129869)