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 LTO for Android #165

Merged
merged 1 commit into from
Sep 10, 2018
Merged

Enable LTO for Android #165

merged 1 commit into from
Sep 10, 2018

Conversation

goderbauer
Copy link
Member

@goderbauer goderbauer commented Sep 10, 2018

Size reductions of libflutter.so:

  • uncompressed: -412KB (from 6MB to 5.6MB)
  • compressed: -243KB (from 3.3MB to 3MB)

Fixes flutter/flutter#16538.

if (is_win) {
# Favor size over speed, /O1 must be before the common flags. The GYP
# build also specifies /Os and /GF but these are implied by /O1.
cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
} else if (is_android || is_ios) {
} else if (is_ios) {
cflags = [ "-Os" ] + common_optimize_on_cflags # Favor size over speed.
Copy link
Member Author

Choose a reason for hiding this comment

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

Using -Oz on iOS builds actually increases size, even though clang doc says:

-Oz   Like -Os (and thus -O2), but reduces code size further.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting - @petrhosek might have more info.

Choose a reason for hiding this comment

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

This is not entirely surprising. LTO usually leads to size increase due to inlining and it currently doesn't currently take -Oz into account. We had some discussions about this in the past, but the conclusion is that it's not quite clear what LTO with -Oz should do since those are to some extent conflicting options.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the explanation!

@goderbauer
Copy link
Member Author

@goderbauer goderbauer changed the title enable LTO for Android Enable LTO for Android Sep 10, 2018
@cbracken
Copy link
Member

Please keep an eye on the benchmarks after this rolls into the framework.

@cbracken
Copy link
Member

lgtm

@goderbauer
Copy link
Member Author

Please keep an eye on the benchmarks after this rolls into the framework.

Will do!

@goderbauer goderbauer merged commit eba79bb into flutter:master Sep 10, 2018
@goderbauer goderbauer deleted the lto-flags branch September 10, 2018 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants