Description
Description
dotnet native aot build as static library does not work
call function export from native aot will crash on osx-arm64 and ios-arm64
Reproduction Steps
this is an csproj build static library for osx-arm64, and try to link and call fucntion from an simple C program
running result: segmentation fault
reproduce steps:
run from bash: run-static.sh <net9|net10>
just a simple function to export
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
public static class Program
{
[UnmanagedCallersOnly(EntryPoint = nameof(TestStaticFunc), CallConvs = new Type[] { typeof(CallConvCdecl) })]
public static void TestStaticFunc()
{
}
}
call from C program
#include <stdio.h>
extern void TestStaticFunc();
int main() {
printf("test static start...\n");
TestStaticFunc();
printf("test static successfully.\n");
return 0;
}
Expected behavior
expected running output:
test static start...
test static successfully.
Actual behavior
segmentation fault, program crash after outpu: test static start...
Regression?
No response
Known Workarounds
dynamic libraray works well
I make dynamic libraray runs correctly on win-x64 (.dll) osx-arm64 (.dylib) and android (.so)
but AppStore reject my dylib build for ios-arm64, so I have to build it as static lib, but it crash in my ios app
Configuration
my computer is mac book with Apple M1 Pro chip
my ios device is iphone 12 with iOS 16.3.1
VSCode is 1.101.0 (Universal)
dotnet SDK installed is 9.0.6 and 10.0.0-preview.5.25277.114
dotnet --info
.NET SDK:
Version: 10.0.100-preview.5.25277.114
Commit: ddf39a1b46
Workload version: 10.0.100-manifests.35d2efbf
MSBuild version: 17.15.0-preview-25277-114+ddf39a1b4
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.5
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/10.0.100-preview.5.25277.114/
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
Workloads are configured to install and update using workload versions, but none were found. Run "dotnet workload restore" to install a workload version.
Host:
Version: 10.0.0-preview.5.25277.114
Architecture: arm64
Commit: ddf39a1b46
.NET SDKs installed:
9.0.301 [/usr/local/share/dotnet/sdk]
10.0.100-preview.5.25277.114 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0-preview.5.25277.114 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0-preview.5.25277.114 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Other information
No response
Metadata
Metadata
Assignees
Type
Projects
Status