Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IL Trimmer error when publishing linux self-contained exe with "trim unused code" #3162

Closed
NeilMacMullen opened this issue Dec 13, 2022 · 7 comments

Comments

@NeilMacMullen
Copy link

NeilMacMullen commented Dec 13, 2022

image

See attached build log for full details
build_log.txt

Relevant portion appears to be this....


37>IL Trimmer has encountered an unexpected error. Please report the issue at https://github.com/dotnet/linker/issues
37>Fatal error in IL Linker
37>Unhandled exception. System.NotImplementedException: Unhandled intrinsic
37>   at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.HandleCall(Instruction operation, MethodReference calledMethod, ValueSet`1 instanceValue, ImmutableArray`1 argumentValues, DiagnosticContext diagnosticContext, ReflectionMarker reflectionMarker, LinkContext context, MarkStep markStep, ValueSet`1& methodReturnValue)
37>   at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.HandleCall(MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams, ValueSet`1& methodReturnValue)
37>   at Mono.Linker.Dataflow.MethodBodyScanner.HandleCall(MethodBody callingMethodBody, Instruction operation, Stack`1 currentStack, Dictionary`2 locals, InterproceduralState& interproceduralState, Int32 curBasicBlock)
37>   at Mono.Linker.Dataflow.MethodBodyScanner.Scan(MethodBody methodBody, InterproceduralState& interproceduralState)
37>   at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.Scan(MethodBody methodBody, InterproceduralState& interproceduralState)
37>   at Mono.Linker.Dataflow.MethodBodyScanner.InterproceduralScan(MethodBody startingMethodBody)
37>   at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.InterproceduralScan(MethodBody methodBody)
37>   at Mono.Linker.Steps.MarkStep.MarkReflectionLikeDependencies(MethodBody body, Boolean requiresReflectionMethodBodyScanner)
37>   at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
37>   at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason, MessageOrigin& origin)
37>   at Mono.Linker.Steps.MarkStep.ProcessQueue()
37>   at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
37>   at Mono.Linker.Steps.MarkStep.Process()
37>   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
37>   at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
37>   at Mono.Linker.Pipeline.Process(LinkContext context)
37>   at Mono.Linker.Driver.Run(ILogger customLogger)
37>   at Mono.Linker.Driver.Main(String[] args)
37>Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.

Dotnet info...


➜ dotnet --info
.NET SDK:
 Version:   7.0.100
 Commit:    e12b7af219

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100\

Host:
  Version:      7.0.0
  Architecture: x64
  Commit:       d099f075e4

.NET SDKs installed:
  5.0.404 [C:\Program Files\dotnet\sdk]
  6.0.201 [C:\Program Files\dotnet\sdk]
  7.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
 ~                                                                                                                                                                          11:07:24
➜
@NeilMacMullen
Copy link
Author

Disabling "Trim unused code" enables the publish operation to succeed (probably not very surprising given the error is with the trimmer!)

@NeilMacMullen NeilMacMullen changed the title IL Trimmer error when attempting to publish linux self-contained exe IL Trimmer error when publishing linux self-contained exe with "trim unused code" Dec 13, 2022
@marek-safar
Copy link
Contributor

@vitek-karas can we guess which intrinsic is missing or do we need a repro?

@vitek-karas
Copy link
Member

This looks identical to #3072
Which has a pending 7.0 fix in #3109

Does the app use a library which is build for netstandard1.6 (or basically anything older than netstandard2.0?
If it's the same problem, then a workaround is to rebuild such library to netstandard2.0 - and it should work.

@NeilMacMullen
Copy link
Author

Does the app use a library which is build for netstandard1.6 (or basically anything older than netstandard2.0?

No. All libraries are targetting "netstandard2.0" or "net6.0"

@vitek-karas
Copy link
Member

Hmm - that would point this to NOT be the same issue as I mention above (or it's unlikely).

Can you try the process described here: #3160
That will let you run the latest trimmer - to see if we have this fixed in main.

Would it be possible to get a repro project?

@NeilMacMullen
Copy link
Author

Would it be possible to get a repro project?
Unfortunately it's a fairly complicated proprietary project so unlikely I can cut it down to a repro case. I'll try out the suggested process and let you know results but may take a few days...

@jhimes144
Copy link

For the record, I had the same issue in my very large avalonia android app. It uses many nuget packages so I haven't yet combed through all of them and their dependencies to see which version of .net standard they use.

Doing the process in #3106 seemed to fix my issue.

@sbomer sbomer added this to AppModel Apr 25, 2024
@agocke agocke closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

5 participants