dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.87k stars 781 forks source link

UWP and .NET native compiler crash #11742

Closed xperiandri closed 2 years ago

xperiandri commented 3 years ago

Some time ago there was an issue about inability to compile F# with .NET native https://github.com/dotnet/corert/issues/6055#issuecomment-421050834

The .NET Native compiler will emit a couple warnings about unsupported LDTOKEN instructions to stdout (there's several places in FSharp.Core.dll where the IL is doing LDTOKEN of an uninstantiated generic method, such as in static System.Void <StartupCode$FSharp-Core>.$Query..cctor() - this is not currently supported by the native code generator backend we use. Then the compiler will crash with an internal error.

We can likely fix this easily in a future FSharp.Core (e.g. change to emit ldtoken of an instantiated generic method and then call GetGenericMethodDefinition() )

Was it fixed? As .NET native compiler still crashes.

Repro steps

  1. Clone https://github.com/xperiandri/Elmish.Uno/tree/template_fixes
  2. Switch to branch template_fixes
  3. Open SolutionTemplate.sln
  4. Switch to Release
  5. Enable .NET native toolchain in UWP project properties
  6. Build

Expected behavior

Builds successfully

Actual behavior

Compiler crashes

Related information

Happypig375 commented 3 years ago

https://github.com/fsharp/fslang-suggestions/issues/919#issuecomment-855800637

These are bugs in the .NET native systems - TBH I'm not a fan of buggy and incomplete implementations of things calling themselves .NET that are not .NET, and feeel it's a bit of a waste of time trying to chase them down.

charlesroddie commented 3 years ago

@xperiandri so far the only reproduction of a .net netnative compiler crash is when compiling x86 (as discussed in the linked thread). I can see references to x86 in your project file. I don't know much about builds but perhaps removing these references would work. If you can confirm that the crash happens outside x86, or want to discuss x86 support, then best to comment in that thread [Edit: thread is locked because corert is archived so would need to be a new issue in dotnet/runtimelab].

dsyme commented 2 years ago

This doesn't appear to be a bug in this repo, and the general topic is covered at https://github.com/fsharp/fslang-suggestions/issues/919#issuecomment-855800637