-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Mono linker failed with function pointer delegates #41866
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@vitek-karas should this transfer to linker repo? |
both Android and iOS samples from src/mono/netcore/sample directory fail to build because of this error. |
This has been already fixed - see the original linker bug dotnet/linker#1345. I just tried the repro from this issue with latest 5.0.100-rc.1.20453.7 and I don't see any errors. Can you please try with the latest RC build? |
For the Android/iOS samples we build with the SDK specified in global.json which is still using a preview8 SDK: Line 3 in a196d53
|
@akoeplinger @vitek-karas updating |
@akoeplinger isn't the rollout scheduled for Monday? |
Tagging subscribers to this area: @vitek-karas, @agocke |
yeah but it looks like it's not as simple as bumping the version, see #41684. So I'd let Viktor handle it. /cc @ViktorHofer |
Thanks for looping me in. Yes, the plan is that I update the SDK as part of September's monthly rollout. Will send out a mail later today about the rollout. Thanks |
@akoeplinger the plan was to update the P8 final. What's the minimum required version that you need? |
Fixes broken samples for Android and iOS. `InvariantGlobalization` fixes the issue described in #41866 because otherwise ILLink fails on Interop.Globalization.EnumCalendarInfo (with a function pointer).
@ViktorHofer it looks like the error still happens with 5.0.100-preview.8.20359.7 SDK but is fixed in 5.0.100-rc.1.20453.7 based on the comments in dotnet/linker#1345, so I think a Preview8 SDK is probably not enough. |
@EgorBo can you try whether it happens with 5.0.100-preview.8.20417.9 which is the released preview 8 SDK? |
Let's baseline on P8 final (min version) but use an RC1 build as the target version. |
I did a quick check with the code from #41866 (comment) and it indeed still fails with 5.0.100-preview.8.20417.9. |
Tagging subscribers to this area: @ViktorHofer |
I tested this on latest and it's working. I needed to update the syntax per: https://github.com/dotnet/csharplang/blob/master/proposals/csharp-9.0/function-pointers.md Now it is using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Test
{
unsafe class Program
{
[DllImport("./Test.dll")]
static extern string InvokeFun(delegate* unmanaged[Cdecl]<int, IntPtr> fun);
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
public static IntPtr Foo(int x)
{
var str = Enumerable.Repeat("x", x).Aggregate((a, b) => $"{a}{b}");
return Marshal.StringToHGlobalAnsi(str);
}
static void Main(string[] args)
{
var callback = (delegate* unmanaged[Cdecl]<int, nint>)(delegate* managed<int, nint>)&Foo;
Console.WriteLine(InvokeFun(callback));
}
}
} Running on
|
Description
Mono linker failed with function pointer delegates.
Code:
Now run dotnet publish with PublishTrimmed:
Got exception from mono lnker:
Configuration
.NET 5 preview 8
The text was updated successfully, but these errors were encountered: