dotnet / dotnet/android

AOT and `[UnmanagedCallersOnly]` integration

Open
#8,756 1 comment 0 reactions 0 assignees View on GitHub
Area: App+Library Build enhancement possibly-stale
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

### Affected platform version

.NET 9

### Description

https://github.com/dotnet/runtime/commit/73b5ac08472bba911fa96c8f2845acacc621376d added a new feature, where we can pass:

```xml

```

And if I have a method like:

```csharp
[UnmanagedCallersOnly(EntryPoint = "Hello")]
static void Hello() => Console.WriteLine("Hello, World!");
```

I get a file `obj\Release\net9.0-android\android-arm64\aot\helloandroid.exportsymbols`

With contents:
```
Hello
```

`@(_MonoAOTCompiledAssemblies->'%(ExportSymbolsFile)')` would be a list of these `.exportsymbols` files.

There are `.o` files for each .NET assembly like:
`obj\Release\net9.0-android\android-arm64\helloandroid.dll.tmp\temp.s.o`

But these seem to be deleted before `` completes

TODO:

* See if there is an option for the AOT compiler to keep `.o` temporary files -- not delete them.
* Create a `.a` archive and potentially pass it to the linker such as `-Wl,--whole-archive /path/to/libstuff.a -Wl,--no-whole-archive`
* Investigate next steps, how we can use this feature.

### Steps to Reproduce

Pass `EnableUnmanagedCallersOnlyMethodsExport="true"` to ``.

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.