demystifyfp / FsToolkit.ErrorHandling

An opinionated F# Library for error handling
https://demystifyfp.gitbook.io/fstoolkit-errorhandling
MIT License
462 stars 59 forks source link

Cannot AOT on Android, iOS and MacCatalyst #276

Open Juriyx opened 1 month ago

Juriyx commented 1 month ago

Describe the bug

[FsToolkit.ErrorHandling.IcedTasks.dll] Exec (with response file contents expanded) in C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App: MONO_PATH=C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App\obj\Release\net8.0-android\android-x86\linked; MONO_ENV_OPTIONS= c:\program files\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86\8.0.5\Sdk\..\tools\mono-aot-cross.exe --debug --nollvm "--aot=asmwriter,temp-path=obj\Release\net8.0-android\android-x86\aot\x86\FsToolkit.ErrorHandling.IcedTasks,profile-only,profile=c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\dotnet.aotprofile,mtriple=i686-linux-android,tool-prefix=c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\tools\binutils\bin\i686-linux-android-,outfile=obj\Release\net8.0-android\android-x86\aot\FsToolkit.ErrorHandling.IcedTasks.dll.so,temp-path=obj\Release\net8.0-android\android-x86\FsToolkit.ErrorHandling.IcedTasks.dll.tmp,ld-name=ld,ld-flags=--no-relax -s" "obj\Release\net8.0-android\android-x86\linked\FsToolkit.ErrorHandling.IcedTasks.dll"
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Precompiling failed for C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App\obj\Release\net8.0-android\android-x86\linked\FsToolkit.ErrorHandling.IcedTasks.dll with exit code 1.
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Mono Ahead of Time compiler - compiling assembly C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App\obj\Release\net8.0-android\android-x86\linked\FsToolkit.ErrorHandling.IcedTasks.dll
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : AOTID BBBE58D8-93CA-B764-523F-676B69DC7019
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Using profile data file 'c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\dotnet.aotprofile'
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : TypeRef ResolutionScope not yet handled (10) for .CancellableTaskStateMachineData`1 in image C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App\obj\Release\net8.0-android\android-x86\linked\FsToolkit.ErrorHandling.IcedTasks.dll
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Failed to load method 0x600000c from 'C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App\obj\Release\net8.0-android\android-x86\linked\FsToolkit.ErrorHandling.IcedTasks.dll' due to Could not resolve type with token 0100000b from typeref (expected class 'CancellableTaskStateMachineData`1' in assembly '') assembly: type:CancellableTaskStateMachineData`1 member:(null).
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Run with MONO_LOG_LEVEL=debug for more information.
1>c:\program files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : AOT of image C:\Users\juriy\source\repos\eCierge\PropertyManagement\Console\App\obj\Release\net8.0-android\android-x86\linked\FsToolkit.ErrorHandling.IcedTasks.dll failed.

To Reproduce Steps to reproduce the behavior:

  1. Create MAUI app.
  2. Install FsToolkit.ErrorHandling.IcedTasks library.
  3. Switch to "Release" configuration.
  4. Build.

Expected behavior Builds successfully.

Desktop (please complete the following information):

Juriyx commented 4 weeks ago

@TheAngryByrd Is there any workaround we can use to fix it at the moment?

TheAngryByrd commented 4 weeks ago

Not that I know of. I've never really used the AOT features in .NET.

TheAngryByrd commented 4 weeks ago

@vzarytovskii is this something the F# team has seen at all?

xperiandri commented 4 weeks ago

What steps would you propose? Should we provide you a minimum reproduction?

vzarytovskii commented 4 weeks ago

@vzarytovskii is this something the F# team has seen at all?

Haven't seen, no, @vitek-karas @sbomer, what would be the easiest way of figuring out why does it fail to compile? State machines is highly generic code, so I assume something related to that?

vitek-karas commented 4 weeks ago

I can't repro this (tried on windows as mac). Could you please:

xperiandri commented 3 weeks ago

Try this https://github.com/Ecierge/FsToolkit.ErrorHandling_AOT_repro

xperiandri commented 3 weeks ago

/Users/runner/.dotnet/packs/Microsoft.MacCatalyst.Sdk/17.2.8053/targets/Xamarin.Shared.Sdk.targets(877,3): error : ILStrip failed for obj/Release/net8.0-maccatalyst/maccatalyst-arm64/linked/FsToolkit.ErrorHandling.dll: Must be of type CilStrip.Mono.Cecil.TypeReference

vzarytovskii commented 3 weeks ago

This needs to be over at dotnet/runtime (if it's not already).

vitek-karas commented 2 weeks ago

+1 - please create an issue in dotnet/runtime for this. Thank you!

Juriyx commented 2 weeks ago

Hello. I found it already exists: https://github.com/dotnet/runtime/issues/87867