Skip to content

Enable --compress-debug-sections in native linker #11304

Description

@sbomer

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

  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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions