MarshallOfSound

#51804: build: only ship grit resources the binary actually references (Linux)

Merged
Created: May 29, 2026, 9:45:07 PM
Merged: Jun 1, 2026, 11:33:46 AM
1 comments
Target: main

Repacks the locale .pak files against a resource allowlist derived from the binary itself, and adds a build-time check that every resource the binary can request is actually shipped.

  • enable grit resource allowlisting in release builds; the allowlist is extracted from the electron executable's exact link inputs via a --collect-inputs-only pseudo-link, regenerated every build, no hand-maintained list
  • repack locales/*.pak with that allowlist (only strings reachable from native code are kept)
  • add electron_resource_allowlist_check, which fails the build if a referenced resource is missing from the shipped paks — and pack everything it found missing today (components_branded_strings error-page / Web Bluetooth strings, content-layer chrome:// internals pages, extension renderer bindings, theme/autofill/lottie resources referenced via grit resource maps)
  • one-line Chromium patch to allow allowlist generation for desktop Linux/macOS
Linux x64 before after
locales (55 paks) 46.8 MB 7.6 MB
resources.pak 7.0 MB 7.5 MB
chrome_100/200_percent.pak 0.3 MB 1.8 MB
net dist size ~297 MB ~260 MB (−37 MB)

Enabled for both testing and release builds, so the allowlist check acts as a PR CI gate: a change that references an unshipped resource fails its own CI instead of the next release build. The first CI runs after this lands will be slower while compile caches repopulate (the grit-generated headers all change).

Verified against a full-pak build: localized strings (en/de/ja/hi), DevTools, PDF viewer, printToPDF, chrome://histograms. Windows (PDB extraction) and macOS (Mach-O support in the upstream script) are follow-ups; on those platforms this change only adds inert marker symbols.

Notes: Reduced the Linux distribution size by ~37 MB by only shipping locale strings and resources that Electron can actually use.

Backports

No Backports Requested

This pull request doesn't have any backports requested or created for older release branches.

What are backports?

Backports are copies of changes made to the main branch that are applied to older release branches. They ensure that bug fixes and important changes are available in maintained older versions of Electron.

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