ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

[v2.1.1] Compile error in .NET6 iOS AOT builds #516

Closed tipa closed 1 year ago

tipa commented 1 year ago

Both the version 2.1.1 and the 2.1.2-preview of SQLitePCLRaw.bundle_green cause compile errors in a .NET iOS app. Example project: test.zip

Simply navigate to the folder and run dotnet publish -c Release

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile SQLitePCLRaw.provider.sqlite3.dll, the AOT compiler exited with code 134 [/Users/.../test.csproj]

Downgrading to 2.1.0 resolves the problem

ericsink commented 1 year ago

I'm away from my Mac. I'm curious. Can you try using bundle_e_sqlite3 instead of bundle_green? Does it show the same problem?

tipa commented 1 year ago

Changing it to SQLitePCLRaw.bundle_e_sqlite3 still errors out, but with a slightly different error:

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile SQLitePCLRaw.provider.internal.dll, the AOT compiler exited with code 134 [/Users/.../test.csproj]

ericsink commented 1 year ago

OK. Thanks. I'll take a closer look as soon as I get a chance.

ericsink commented 1 year ago

Confirming: I can reproduce this. It happens for 2.1.1, but not for 2.1.0. Unfortunately, the error message is exceedingly unhelpful.

@filipnavara The only change between 2.1.0 and 2.1.1 that looks remotely relevant here is your changes for the calling convention of unmanaged function pointers, in #507 -- any idea how that could be causing the AOT failure seen here? Are you able to do AOT iOS builds with your code change?

filipnavara commented 1 year ago

any idea how that could be causing the AOT failure seen here? Are you able to do AOT iOS builds with your code change?

It could be a MonoVM bug. We should raise the issue on dotnet/runtime repo with a small self-contained repro. I won't be able to look into it until next week.

ericsink commented 1 year ago

I condensed the repro down to not need SQLitePCLRaw. It's basically a single function with an UnmanagedCallersOnly attribute that fails when CallConvs is provided. I posted that repro in a bug report to dotnet/runtime and linked to this issue as shown above.

ericsink commented 1 year ago

I believe this is fixed in 2.1.2-pre20220916165053.

freever commented 1 year ago

I can confirm this is fixed for me. I have a .NET Maui app for which the iOS builds started breaking once I upgraded SQLitePCLRaw to 2.1.1. Builds are working again with 2.1.2-pre20220916165053.

ericsink commented 1 year ago

Fixed in 2.1.2, which is now on nuget