MarshallOfSound

#52290: build: only ship grit resources the binary actually references (macOS)

Merged
Created: Jul 8, 2026, 1:36:50 PM
Merged: Jul 8, 2026, 11:12:05 PM
1 comments
Target: main

Follow-up to #51804, enabling grit resource allowlisting on macOS.

  • the allowlist is extracted the same way as on Linux — a --collect-inputs-only pseudo-link whose inputs are scanned for the ui::AllowlistedResource<id> markers — except that on macOS all of Electron's native code links into the Electron Framework, so the pseudo-link mirrors the framework's link inputs rather than the app shim's
  • the Apple solink tool runs through linker_driver.py instead of gcc_solink_wrapper.py, so the existing Chromium patch grows an equivalent --collect-inputs-only mode there: skip the real link, write the input list to the output, and stub the other declared outputs (TOC, dSYM bundle, unstripped copy) so the mode also works in release builds where dSYMs/stripping are enabled
  • ar.py's thin-archive expansion silently dropped regular archives (and raised on Mach-O universal archives like libclang_rt.osx.a). Fine on Linux where the build uses thin archives everywhere, but on macOS static libraries are regular archives — ~1,700 of the framework's link inputs — so their objects were never scanned. Regular archives embed their members' contents, so they're now kept in the list and raw-scanned directly
  • electron_resource_allowlist_check runs against the mac pak paths (gen/electron_repack, with en-US shipping as en.pak) and gates electron_dist_zip exactly as on Linux; no new suppressions or pak additions were needed — the paks added in #51804 already cover macOS
macOS arm64 before after
locales (220 paks) 47.1 MB 8.6 MB

(resources.pak / chrome_*.pak are unchanged by this PR — the additions from #51804 already ship on macOS.)

Verified against the built app: localized strings resolve from the slimmed paks (en/de/ja form-validation messages), DevTools, printToPDF, the PDF viewer, and chrome://histograms all load. Also verified the check fails correctly when a shipped pak is removed from its input list. Windows (PDB-based extraction) remains a follow-up; there this change is still inert.

Notes: Reduced the macOS distribution size by shipping only the locale strings 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