Skip to content

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

@sbomer

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssues that need to be assigned.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions