mapbox / mapbox-gl-native-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and OpenGL
https://www.mapbox.com/mobile/
Other
210 stars 122 forks source link

Update build configurations and reduce binary size #134

Open julianrex opened 4 years ago

julianrex commented 4 years ago

mapbox-gl-native is simplifying the build configurations, to just Debug and Release (see https://github.com/mapbox/mapbox-gl-native/pull/16083).

We need to do the same.

We can handle a "stripped" build (i.e. what is currently Release) as a packaging step, i.e. by default the new Release configuration will contain debug symbols.

At the same time we should consider #22

julianrex commented 4 years ago

Following on from https://github.com/mapbox/mapbox-gl-native-ios/issues/63:

Currently the release frameworks are NOT building with -flto or -Os, which has resulted in an increase in binary size. Here are some stats when building with various optimizations.

Build settings framework size 1 dSYM size 2 arm64 slice size 3 arm64 no bitcode 4 arm64 stripped 5 __TEXT 6 __DATA __OBJC others
5.8.0 148065160 639619389 62868360 10439560 5162968 4800512 245760 0 116696
-Os -flto 85817300 344712182 38254548 4241364 4241364 3883008 245760 0 112596
-Oz -flto 72817804 325747720 31759500 3579020 3579020 3211264 245760 0 121996

Looking at compiling with -Os -flto, the framework size is brought back to original levels - though when compiling with -Oz the result is even more dramatic (~30% size reduction).

I would suggest that we update with -Os, then compare performance when compiling with -Oz ("outlining").

Symbols should be included the dSYM; though the size is much smaller compared with 5.8.0 so I suspect I made an error with the symbol handling. Need to check debugging, and call stacks on crashes.

These stats were built from the jrex/build-tests branch building with make iframework BUILDTYPE=Release BUILD_DOCS=false


Notes:

  1. Size of the Mapbox binary in the framework directory
  2. Size of the binary in the Mapbo.framework.dSYM/Contents/Resources/DWARF/ directory
  3. Size of the arm64 slice, extracted by: lipo Mapbox.framework/Mapbox -thin arm64 -output Mapbox-arm64
  4. Size of binary generated by 3, with bitcode removed: xcrun bitcode_strip Mapbox-arm64 -r -o Mapbox-arm64-no-bitcode
  5. Size of binary generated by 4, with symbols stripped: strip -Sx Mapbox-arm64-no-bitcode -o Mapbox-arm64-no-bitcode-stripped
  6. Remaining columns are from running size on the above binary.
julianrex commented 4 years ago

Noting that we should consider a separate Github release artifact for the dSYM and bcsymbolmap files (see also https://github.com/mapbox/mapbox-gl-native-android/pull/134).

1ec5 commented 4 years ago

Noting that we should consider a separate Github release artifact for the dSYM and bcsymbolmap files (see also https://github.com/mapbox/mapbox-gl-native-android/pull/134).

Note that Carthage (#143) expects the .dSYM to appear in the same .framework.zip archive as the executable.

julianrex commented 4 years ago

Note that Carthage (#143) expects the .dSYM to appear in the same .framework.zip archive as the executable.

Ok, so multiple packages 😭

julianrex commented 4 years ago

Have split out the update of Release and RelWithDebInfo configuration into a separate PR: https://github.com/mapbox/mapbox-gl-native/pull/16460, so that existing build scripts/packaging is not changed.

I think it's still valid to consolidate configurations to just Release & Debug, so this ticket can be kept open for the time-being.