BUILD.gn: Support LTO build on Linux#176191
Merged
auto-submit[bot] merged 1 commit intoflutter:masterfrom Sep 29, 2025
Merged
Conversation
Add support for LTO builds on Linux.
Contributor
There was a problem hiding this comment.
Code Review
This pull request enables Link-Time Optimization (LTO) for Linux builds by adding is_linux to the conditional check in engine/src/build/config/compiler/BUILD.gn. My review focuses on code style and correctness. I've suggested a formatting change to improve readability and adhere to the GN style guide.
|
|
||
| lto_flags = [] | ||
| if (enable_lto && (is_ios || is_mac || is_android || is_fuchsia || is_wasm)) { | ||
| if (enable_lto && (is_linux || is_ios || is_mac || is_android || is_fuchsia || is_wasm)) { |
Contributor
Contributor
|
This makes sense and we thought this was already how it worked. LGTM. |
chinmaygarde
approved these changes
Sep 29, 2025
jason-simmons
approved these changes
Sep 29, 2025
markyang92
added a commit
to markyang92/meta-flutter
that referenced
this pull request
Sep 30, 2025
Enable LTO for the is_linux case in BUILD.gn as well. This patch has been upstream merged into Flutter. flutter/flutter#176191
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Sep 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Sep 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Sep 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Sep 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Sep 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Sep 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Oct 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Oct 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Oct 1, 2025
auto-submit bot
pushed a commit
to flutter/packages
that referenced
this pull request
Oct 1, 2025
Manual roll requested by [email protected] flutter/flutter@96fe3b3...c9608e2 2025-09-30 [email protected] Implement framework interface for the dialog window archetype (flutter/flutter#176202) 2025-09-30 [email protected] Update flutter test to use SemanticsFlags (flutter/flutter#175987) 2025-09-30 [email protected] Set minimum supported java version to 17 (flutter/flutter#176226) 2025-09-30 [email protected] Reduce timeout for Linux web_tool_tests back to 60 (flutter/flutter#176286) 2025-09-30 [email protected] Roll Packages from 34eec78 to 287739d (9 revisions) (flutter/flutter#176284) 2025-09-30 [email protected] [web] Bump Firefox to 143.0 (flutter/flutter#176110) 2025-09-30 [email protected] Migrate to `WidgetStateBorderSide` (flutter/flutter#176164) 2025-09-30 [email protected] Enhance input decorator padding logic for character counter in text f… (flutter/flutter#175706) 2025-09-30 [email protected] Update the test package for the web engine unit test bits. (flutter/flutter#176241) 2025-09-30 [email protected] Warn if embedder API calls don't return success (flutter/flutter#176184) 2025-09-30 [email protected] Roll Fuchsia Test Scripts from APSBP-sS-3FX69Ihf... to JUeFbA8y0E-_pj-bg... (flutter/flutter#176243) 2025-09-30 [email protected] Roll GN to 81b24e01 (flutter/flutter#176119) 2025-09-29 [email protected] Rename DisplayMonitor to DisplayManager on Win32 (flutter/flutter#175619) 2025-09-29 [email protected] [Android] Use headingLevel for heading accessibility property (flutter/flutter#175416) 2025-09-29 [email protected] BUILD.gn: Support LTO build on Linux (flutter/flutter#176191) 2025-09-29 [email protected] fix `assertEquals` arguments are in wrong order in `FlutterJNITest.java` (flutter/flutter#175728) 2025-09-29 [email protected] Add tests for `Project` getters (flutter/flutter#175994) 2025-09-29 [email protected] Roll Fuchsia Linux SDK from 8zjcJic_DtvB2Bo2x... to rcOl0yxJb4znJ903Y... (flutter/flutter#176215) 2025-09-29 [email protected] Clean up typos in `PlatformViewsControllerTest.java` (flutter/flutter#175725) 2025-09-29 [email protected] Migrate java 11 usage to java 17 usage for templates (flutter/flutter#176203) 2025-09-29 [email protected] User Invoke-Expression instead of call operator for nested Powershell scripts invocations (on Windows) (flutter/flutter#175941) 2025-09-29 [email protected] Update changelog as on 3.35 branch (flutter/flutter#176216) 2025-09-29 [email protected] fix typo in `Crashes.md` (flutter/flutter#175959) 2025-09-29 [email protected] Add scene plugin lifecycle events (flutter/flutter#175866) 2025-09-29 [email protected] Migrate tests and documentation to set java version to 17 (flutter/flutter#176204) 2025-09-29 [email protected] Update Engine CI to use NDK r28c (flutter/flutter#175870) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
okorohelijah
pushed a commit
to okorohelijah/flutter
that referenced
this pull request
Oct 7, 2025
Add support for LTO builds on Linux. <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [v] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [v] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [v] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [v] I signed the [CLA]. - [v] I listed at least one issue that this PR fixes in the description above. - [v] I updated/added relevant documentation (doc comments with `///`). - [v] I added new tests to check the change I am making, or this PR is [test-exempt]. - [v] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [v] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- - Enable LTO on Linux. - Build test - I validated the build in the Yocto build system using meta-flutter # Build before modification. ```bash # clone poky $ source oe-init-build-env $ echo "MACHINE = \"genericarm64\"" >> build/conf/local.conf # clone meta-flutter. $ git clone https://github.com/meta-flutter/meta-flutter.git # Added meta-oe and meta-flutter to BBLAYERS in build/conf/bblayers.conf $ bitbake flutter-engine # Check whether LTO has been applied in compile_commands.json $ cat build/tmp/work/armv8a-poky-linux/flutter-engine/3.32.8/sources/gn/engine/src/out/linux_debug_arm64/compile_commands.json | grep "\-flto" ..nothing ``` # Build after modification. ``` # checkout modified meta-flutter meta-flutter/meta-flutter@a901568 $ cd meta-flutter $ git remote add markyang92 https://github.com/markyang92/meta-flutter.git $ git fetch markyang92 a901568da38de2ad3c8a176311b86d8e0f2bb1c1 $ git cherry-pick FETCH_HEAD $ cd .. $ bitbake flutter-engine # Check whether LTO has been applied in compile_commands.json $ cat build/tmp/work/armv8a-poky-linux/flutter-engine/3.32.8/sources/gn/engine/src/out/linux_debug_arm64/compile_commands.json | grep "\-flto" "command": ".....clang++ ... Omitted .. \ -flto ..... \ -g0 -Wunreachable-code -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -c ../../flutter/fml/string_conversion.cc -o clang_x64/obj/flutter/fml/string_conversion.string_conversion.o" ```
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Nov 12, 2025
reidbaker
pushed a commit
to AbdeMohlbi/flutter
that referenced
this pull request
Dec 10, 2025
Add support for LTO builds on Linux. <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [v] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [v] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [v] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [v] I signed the [CLA]. - [v] I listed at least one issue that this PR fixes in the description above. - [v] I updated/added relevant documentation (doc comments with `///`). - [v] I added new tests to check the change I am making, or this PR is [test-exempt]. - [v] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [v] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- - Enable LTO on Linux. - Build test - I validated the build in the Yocto build system using meta-flutter # Build before modification. ```bash # clone poky $ source oe-init-build-env $ echo "MACHINE = \"genericarm64\"" >> build/conf/local.conf # clone meta-flutter. $ git clone https://github.com/meta-flutter/meta-flutter.git # Added meta-oe and meta-flutter to BBLAYERS in build/conf/bblayers.conf $ bitbake flutter-engine # Check whether LTO has been applied in compile_commands.json $ cat build/tmp/work/armv8a-poky-linux/flutter-engine/3.32.8/sources/gn/engine/src/out/linux_debug_arm64/compile_commands.json | grep "\-flto" ..nothing ``` # Build after modification. ``` # checkout modified meta-flutter meta-flutter/meta-flutter@a901568 $ cd meta-flutter $ git remote add markyang92 https://github.com/markyang92/meta-flutter.git $ git fetch markyang92 a901568da38de2ad3c8a176311b86d8e0f2bb1c1 $ git cherry-pick FETCH_HEAD $ cd .. $ bitbake flutter-engine # Check whether LTO has been applied in compile_commands.json $ cat build/tmp/work/armv8a-poky-linux/flutter-engine/3.32.8/sources/gn/engine/src/out/linux_debug_arm64/compile_commands.json | grep "\-flto" "command": ".....clang++ ... Omitted .. \ -flto ..... \ -g0 -Wunreachable-code -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -c ../../flutter/fml/string_conversion.cc -o clang_x64/obj/flutter/fml/string_conversion.string_conversion.o" ```
JSUYA
added a commit
to flutter-tizen/flutter
that referenced
this pull request
Dec 12, 2025
- flutter#172588 has been included in 3.38. So it excludes that was applied in 3.35.3. - Added the `--no-lto` gn option. - `flto` for linux was added but it have been disabled in Flutter CI due to build performance issues. - flutter#176191 - flutter#177660 - flutter#177694 - If we want to apply the flto option, we need a container with an updated toolchain. tool: flutter-tizen/flutter-tizen#714 embedder: flutter-tizen/embedder#134 flutter-tizen/flutter-tizen#687
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for LTO builds on Linux.
Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Build before modification.
Build after modification.