Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Enable LTO for Android#165

Merged
goderbauer merged 1 commit into
flutter-team-archive:masterfrom
goderbauer:lto-flags
Sep 10, 2018
Merged

Enable LTO for Android#165
goderbauer merged 1 commit into
flutter-team-archive:masterfrom
goderbauer:lto-flags

Conversation

@goderbauer

@goderbauer goderbauer commented Sep 10, 2018

Copy link
Copy Markdown
Contributor

Size reductions of libflutter.so:

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

Fixes flutter/flutter#16538.

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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.

Copy link
Copy Markdown

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

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

@cbracken

Copy link
Copy Markdown
Contributor

lgtm

@goderbauer

Copy link
Copy Markdown
Contributor Author

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

Will do!

@goderbauer goderbauer merged commit eba79bb into flutter-team-archive:master Sep 10, 2018
@goderbauer goderbauer deleted the lto-flags branch September 10, 2018 21:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants