dotnet / linker

387 stars 126 forks source link

ILLink : error IL1012 with macOS, .NET 7.0 #3157

Open nilaoda opened 1 year ago

nilaoda commented 1 year ago
  Optimizing assemblies for size. This process might take a while.
ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://github.com/dotnet/linker/issues [/Users/runner/work/N_m3u8DL-RE/N_m3u8DL-RE/src/N_m3u8DL-RE/N_m3u8DL-RE.csproj]
  Fatal error in IL Linker
  Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'target')
     at Mono.Cecil.Cil.ILProcessor.InsertAfter(Instruction target, Instruction instruction)
     at Mono.Linker.LinkerILProcessor.InsertAfter(Instruction target, Instruction instruction)
     at Mono.Linker.Steps.MarkStep.ProcessPendingTypeChecks()
     at Mono.Linker.Steps.MarkStep.Process()
     at Mono.Linker.Steps.MarkStep.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)

Detail here:
https://github.com/nilaoda/N_m3u8DL-RE/actions/runs/3663371272/jobs/6193112246

vitek-karas commented 1 year ago

This was fixed by https://github.com/dotnet/linker/pull/3088 but that fix is only available in .NET 8.0 SDK. Unfortunately the fix is rather large so it raises the risk of taking the fix for servicing. I'll look into it.

In theory there might be a workaround as the bug is order dependent - if the trimmer sees the code in different order it might work, but it's really hard to guess which order will work and which won't.

nilaoda commented 1 year ago

Sad...Thank you for your efforts.

vitek-karas commented 1 year ago

https://github.com/dotnet/linker/pull/3161 is the 7.0 port of the fix.

vitek-karas commented 1 year ago

Note that this issue is only in the trimmer, it doesn't apply to NativeAOT (which also does triming), so if you manage to get your app working in NativeAOT, this issue should not impact that.