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 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.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Sep 10, 2018

Author Member

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

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

This comment has been minimized.

Copy link
@cbracken

cbracken Sep 10, 2018

Member

Interesting - @petrhosek might have more info.

This comment has been minimized.

Copy link
@petrhosek

petrhosek Sep 10, 2018

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.

This comment has been minimized.

Copy link
@goderbauer

goderbauer Sep 10, 2018

Author Member

Thanks for the explanation!

@goderbauer

This comment has been minimized.

Copy link
Member Author

goderbauer commented Sep 10, 2018

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

This comment has been minimized.

Copy link
Member

cbracken commented Sep 10, 2018

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

@cbracken

This comment has been minimized.

Copy link
Member

cbracken commented Sep 10, 2018

lgtm

@goderbauer

This comment has been minimized.

Copy link
Member Author

goderbauer commented Sep 10, 2018

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
2 checks passed
2 checks passed
WIP ready for review
Details
cla/google All necessary CLAs are signed
@goderbauer goderbauer deleted the goderbauer:lto-flags branch Sep 10, 2018
@goderbauer goderbauer added the size label Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.