dotnet / dotnet/android

Create managed version of `llvm-objcopy`

Open
#9,692 9 comments 0 reactions 0 assignees View on GitHub
Area: App+Library Build Area: Performance enhancement
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 19h
Merged PRs (30d)
252

Description

Context: https://github.com/dotnet/android/issues/9455

For each assembly/pdb/config/others file we wrap as a `.so` in order to place in the `/lib` directory of an APK, we shell out twice to `llvm-objcopy`:

```
llvm-objcopy.EXE --add-section payload=obj\Debug\net9.0-android\android\assets\arm64-v8a\myproject.dll obj\Debug\net9.0-android\android-arm64\wrapped\lib_myproject.dll.so
llvm-objcopy.EXE --set-section-flags payload=readonly,data --set-section-alignment payload=16384 obj\Debug\net9.0-android\android-arm64\wrapped\lib_myproject.dll.so
```

There is considerable overhead to this process.

In this example we spend ~42 seconds in this step:

```
dotnet new android
dotnet build -p:EmbedAssembliesIntoApk=true
```

A managed version that did not need to shell out to external processes of this would likely be faster.

Some potential options:
- https://github.com/xoofx/LibObjectFile (.NET 8+ 😢)
- Porting [`llvm-objcopy`](https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-objcopy/llvm-objcopy.cpp) to managed code using managed LLVM bindings (potentially [`LLVMSharp`](https://github.com/dotnet/LLVMSharp))

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.