Strip native libraries as part of `Package` target
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 579
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 257
Description
Context: https://github.com/dotnet/runtime/issues/45013
Currently, the native libraries in the .NET 6 Runtime Pack are not `strip`d, which means:
1. They contain debug symbols, and thus
2. Are bigger.
*Much* bigger:
```
% ls -lh ~/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.20560.10/runtimes/android-arm64/native/libmonosgen-2.0.so
-rwxr--r-- 1 jon staff 17M Nov 11 02:20 /Users/jon/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.20560.10/runtimes/android-arm64/native/libmonosgen-2.0.so
% cp ~/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.20560.10/runtimes/android-arm64/native/libmonosgen-2.0.so libmono-stripped.so
% /Library/Frameworks/Xamarin.Android.framework/Versions/Current//lib/xamarin.android/xbuild/Xamarin/Android/Darwin/ndk/aarch64-linux-android-strip libmono-stripped.so
% ls -lh libmono-stripped.so
-rwxr--r-- 1 jon staff 2.9M Jan 28 11:24 libmono-stripped.so
```
The un-`strip`d `libmonosgen-2.0.so` is 17MB, while the `strip`d version is 2.9MB.
Quite a size difference!
There is a suggestion that the .NET 6 runtime packs should contain `strip`d binaries.
A problem with that is that un`-strip`d binaries are useful! If the app crashes, debug symbols will provide *useful information* about where the crash occurred. If the .NET 6 runtime pack binaries are `strip`d, then *some other mechanism* will need to be provided so that un-`strip`d binaries can be obtained.
*Instead*, let's update the `Package` target to (optionally!) `strip` *all* `.so` files that are added to the `.apk`.
This means that if 3rd party native libraries are shipped as un-`strip`d binaries, they can *also* be handled automagically.
Additionally, the current Xamarin.Android SDK "handles" this problem by shipping both `strip`d `.so` files, and un-`strip`d `.d.so` files:
```
% ls -lh /Library/Frameworks/Xamarin.Android.framework/Versions/Current//lib/xamarin.android/xbuild/Xamarin/Android/lib/arm64-v8a/ | grep monosgen
-rwxr-xr-x 1 root wheel 18M Oct 12 18:11 libmonosgen-2.0.d.so
-rwxr-xr-x 1 root wheel 3.8M Oct 12 18:11 libmonosgen-2.0.so
```
If we uniformly did the `strip` at `Package` time, then we could ship only the debug version, named `libmonosgen-2.0.so`, thus saving ~3.8MB * 4 = ~15MB from our installation size.
(Downside: it means that the `Package` target takes longer, as it'll be doing more work.)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.