MarshallOfSound

#51809: build: enable ThinLTO link-time optimization for the main binary

Merged
Created: May 30, 2026, 5:57:33 PM
Merged: Jun 1, 2026, 9:23:07 AM
3 comments
Target: main

Description of Change

Chromium's build system applies the thinlto_optimize_default config 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 in thinlto_optimize_max, which Chrome does for its three main binaries (chrome_initial, chrome_dll on Windows, and chrome_framework on 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) and electron_framework (macOS framework), exactly mirroring what chrome/BUILD.gn does 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:

Build Score
Electron release build today (--lto-O0) 22.08 ± 0.19
Electron with this change (--lto-O2) 24.99 ± 0.79

+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

  • The final ThinLTO link of the main binary becomes more expensive: observed ~8 min → ~15 min on a 64-core machine, peak link RAM ~38 GB.
  • .text grows ~8.4% from more aggressive cross-module inlining — the same trade-off Chrome makes for its binaries.
  • Component/testing builds (which don't use ThinLTO) are unaffected.

Related

  • #51669 — complementary: without this change, macOS would still link at --lto-O0 once ThinLTO is re-enabled there; with it, that PR delivers full link-time optimization on macOS too.

Checklist

Release Notes

Notes: Improved performance of Linux and Windows release builds by enabling ThinLTO link-time optimization for the main Electron binary.

Backports

42-x-y
Merged
PR Number
#51821
Merged At
Jun 1, 2026, 11:30:42 AM
Released In
v42.3.1
Release Date
Jun 1, 2026, 11:25:56 PM
43-x-y
Merged
PR Number
#51820
Merged At
Jun 1, 2026, 11:31:24 AM
Released In
v43.0.0-beta.1
Release Date
Jun 4, 2026, 3:31:55 PM

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron