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, 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
- Rebuild the android-native-tools package with
LLVM_ENABLE_ZLIB=ON (and optionally LLVM_ENABLE_ZSTD=ON)
- Uncomment the flag in
NativeLinker.cs (use zlib for broadest compatibility, or zstd if the toolchain supports it)
This content was created with assistance from AI.
NativeLinker.cshas a commented-out TODO to pass--compress-debug-sections=zstdtold.lld:https://github.com/dotnet/android/blob/main/src/Xamarin.Android.Build.Tasks/Utilities/NativeLinker.cs#L20
This would reduce
.sosize 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, version
L_18.1.6-8.0.0-1) was built withoutLLVM_ENABLE_ZLIBandLLVM_ENABLE_ZSTD, so it errors with:The NDK's LLD supports
zlibbut notzstd.Steps
LLVM_ENABLE_ZLIB=ON(and optionallyLLVM_ENABLE_ZSTD=ON)NativeLinker.cs(usezlibfor broadest compatibility, orzstdif the toolchain supports it)