Skip to content

[BUG] neither ndk-build nor CMake toolchain file uses --gc-sections for shared libraries by default #1717

@DanAlbert

Description

@DanAlbert

Description

Neither ndk-build nor CMake toolchain file uses --gc-sections for shared libraries by default (they both do for executables). This is contrary to our own docs: https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Controlling-Binary-Size

This seems to have always been the case (checking all the way back to r10 shows the same behavior). I'm not sure if the author back then did that intentionally or if it was an oversight, but afaik there's no downside to using this flag, so it should be on by default.

Test case

Affected versions

r23, r24, r25, Canary

Canary version

TOT

Host OS

Linux, Mac, Windows

Host OS version

all

Affected ABIs

armeabi-v7a, arm64-v8a, x86, x86_64

Build system

CMake

Other build system

No response

minSdkVersion

any

Device API level

N/A

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions