Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Add -fvisibility=hidden param to Android build - #5656

Merged
tmpsantos merged 1 commit into
masterfrom
5656-android_visibility
Jul 13, 2016
Merged

tmpsantos merged 1 commit into
masterfrom
5656-android_visibility

Conversation

@tmpsantos

Copy link
Copy Markdown
Contributor

This piece from Realm on Reducing your Android APK size When Using Native Libraries suggests the following approach to reducing library size:

At that point both our core (libtightdb) and the JNI code was compiled with GCC with the -Os flag, which tries to optimize the library for size while maintaining decent performance. We also enabled -visibility=hidden to hide most of the unneeded ELF symbols.

Per convo with @tmpsantos we don't use the -Os flag as we optimize for performance, but we could benefit from -visibility=hidden as Qt does.

It'd be interesting to compare library size before and after adding those flags.

@zugaldia zugaldia added the Android Mapbox Maps SDK for Android label Jul 12, 2016
@zugaldia zugaldia added this to the android-v4.2.0 milestone Jul 12, 2016
@1ec5

1ec5 commented Jul 12, 2016

Copy link
Copy Markdown
Contributor

we don't use the -Os flag as we optimize for performance

On iOS, we found in #3183 that using -Os instead of -O3 did greatly reduce the binary’s size (by about half) while incurring no noticeable performance hit. -O3 basically inlines everything, which is why it’s so big.

@tmpsantos tmpsantos changed the title Add -visibility=hidden param to Android build Add -fvisibility=hidden param to Android build Jul 12, 2016
@tmpsantos

Copy link
Copy Markdown
Contributor

Some numbers for armv-7 (KB):

Build options libmapboxgl.so lib size delta Test app APK APK Size delta
-O3 (current) 5220 0 5937 0
-Os 5165 -55 5847 -90
-O3 -fvisibility=hidden 4226 -994 5802 -135
-Os -fvisibility=hidden 3918 -1302 5674 -263

@bleege

bleege commented Jul 12, 2016

Copy link
Copy Markdown
Contributor

Great find everyone! This is going to be great!

@tmpsantos

Copy link
Copy Markdown
Contributor
Build options BUILDTYPE=Release make apackage
O3 (current) 16542 KB
-Os -fvisibility=hidden 14917 KB

@tmpsantos
tmpsantos merged commit cc3a812 into master Jul 13, 2016
@tmpsantos
tmpsantos deleted the 5656-android_visibility branch July 13, 2016 11:13
ivovandongen added a commit that referenced this pull request Jul 25, 2016
kkaefer pushed a commit that referenced this pull request Jul 26, 2016
kkaefer pushed a commit that referenced this pull request Jul 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Android Mapbox Maps SDK for Android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants