build: enable ThinLTO link-time optimization for the main binary#51809
Merged
Conversation
Chromium applies the thinlto_optimize_default config to all targets by default, which passes --lto-O0 (Windows: /opt:lldlto=0) to the linker -- i.e. no optimization is performed during the ThinLTO link step. Chrome opts its main binaries (chrome executable, chrome.dll, Chrome Framework) into the thinlto_optimize_max config to get full link-time optimization, but Electron never did, so release builds of Electron were linked with --lto-O0 and lost most of the benefit of ThinLTO and PGO. Swap in thinlto_optimize_max for electron_app (Linux/Windows) and electron_framework (macOS), exactly like chrome/BUILD.gn does for its equivalent targets.
5 tasks
jkleinsc
approved these changes
Jun 1, 2026
|
Release Notes Persisted
|
This was referenced Jun 1, 2026
Contributor
|
I have automatically backported this PR to "43-x-y", please check out #51820 |
Contributor
|
I have automatically backported this PR to "42-x-y", please check out #51821 |
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.
Description of Change
Chromium's build system applies the
thinlto_optimize_defaultconfig to every target by default. That config passes--lto-O0(Windows:/opt:lldlto=0) to the linker, meaning no optimization is performed during the ThinLTO link step — it exists to keep developer links fast. Targets that want real link-time optimization must explicitly swap inthinlto_optimize_max, which Chrome does for its three main binaries (chrome_initial,chrome_dllon Windows, andchrome_frameworkon macOS).Electron has never done this swap, so every release build of Electron that uses ThinLTO (Linux and Windows today; macOS once #51669 lands) links the main binary with
--lto-O0, giving up cross-module inlining and most of the link-time benefit of PGO.This change applies the same config swap to
electron_app(Linux/Windows executable) andelectron_framework(macOS framework), exactly mirroring whatchrome/BUILD.gndoes for its equivalent targets.Performance impact (measured)
Speedometer 3.1, Linux x64 release build from
main, interleaved benchmark rounds of 10 iterations each on the same machine:--lto-O0)--lto-O2)+13.2% improvement. For reference, Chrome for Testing at the same Chromium version (150.0.7863.0) scores ~28.4 in the same environment, so this change closes roughly half of the gap between Electron release builds and Chrome.
Build cost
.textgrows ~8.4% from more aggressive cross-module inlining — the same trade-off Chrome makes for its binaries.Related
--lto-O0once ThinLTO is re-enabled there; with it, that PR delivers full link-time optimization on macOS too.Checklist
npm testpassesRelease Notes
Notes: Improved performance of Linux and Windows release builds by enabling ThinLTO link-time optimization for the main Electron binary.