Enable --compress-debug-sections in native linker
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 579
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 252
Description
*This content was created with assistance from AI.*
`NativeLinker.cs` has a commented-out TODO to pass `--compress-debug-sections=zstd` to `ld.lld`:
https://github.com/dotnet/android/blob/main/src/Xamarin.Android.Build.Tasks/Utilities/NativeLinker.cs#L20
This would reduce `.so` size in debug builds by compressing DWARF debug sections. Currently neither the CoreCLR/Mono nor NativeAOT link steps compress debug sections.
### Blockers
The workload-shipped LLD (from [dotnet/android-native-tools](https://github.com/dotnet/android-native-tools), version `L_18.1.6-8.0.0-1`) was built without `LLVM_ENABLE_ZLIB` and `LLVM_ENABLE_ZSTD`, so it errors with:
```
ld: error: --compress-debug-sections: LLVM was not built with LLVM_ENABLE_ZLIB or did not find zlib at build time
```
The NDK's LLD supports `zlib` but not `zstd`.
### Steps
1. Rebuild the android-native-tools package with `LLVM_ENABLE_ZLIB=ON` (and optionally `LLVM_ENABLE_ZSTD=ON`)
2. Uncomment the flag in `NativeLinker.cs` (use `zlib` for broadest compatibility, or `zstd` if the toolchain supports it)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.