Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Link Time Optimization (LTO) compiler flag #98

Merged
merged 1 commit into from
Feb 11, 2019

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Feb 8, 2019

Enables Link Time Optimization (LTO) for all targets, resulting in marginally smaller binary sizes and (theoretical) performance improvements.

  • LTO increases the amount of time during the build process spent linking, but for a project this size it’s negligible — on my computer, it increased from 1.1 seconds to 1.9 seconds.
  • ThinLTO did not show a measurable decrease in binary size, unfortunately, but “monolithic” did (and is what this PR enables).
  • This change should provide improvements for consumer projects/libraries that build this Xcode project directly or consume it as a binary.
  • There will be no change in the iOS Maps SDK — [build] Enable link-time optimization for iOS release builds mapbox-gl-native#12502 already did this (and, due how to this events library is consumed there, it is also LTO'd).

Binary size changes

The differences in the stripped binaries for the dynamic framework are not huge, but they’re something.

Before, LTO disabled

3.2M	MapboxMobileEvents
496K	MapboxMobileEvents-stripped
272K	MapboxMobileEvents-stripped-arm64
240K	MapboxMobileEvents-stripped-armv7

Monolithic LTO enabled

2.8M	MapboxMobileEvents
480K	MapboxMobileEvents-stripped
272K	MapboxMobileEvents-stripped-arm64
224K	MapboxMobileEvents-stripped-armv7

ThinLTO enabled

3.2M	MapboxMobileEvents
496K	MapboxMobileEvents-stripped
272K	MapboxMobileEvents-stripped-arm64
240K	MapboxMobileEvents-stripped-armv7

/cc @rclee @andrlee

@friedbunny friedbunny self-assigned this Feb 8, 2019
@friedbunny friedbunny requested a review from rclee February 8, 2019 22:12
@friedbunny
Copy link
Contributor Author

friedbunny commented Feb 8, 2019

Looks like this change decreases the static library’s raw binary size from 8.54 MB to 7.06 MB.

Copy link
Contributor

@rclee rclee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks Jason!
cc: @alfwatt @andrlee

@friedbunny friedbunny merged commit 43283b0 into master Feb 11, 2019
@friedbunny friedbunny deleted the friedbunny-enables-lto branch February 11, 2019 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants