Skip to content

build: refactor Linux binary stripping to align with upstream #47932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dsanders11
Copy link
Member

@dsanders11 dsanders11 commented Aug 1, 2025

Description of Change

We occasionally see a transient issue in our published Linux releases where the electron binary gets relinked after we've stripped it when we run e build --target electron:electron_dist_zip due to inconsistent timestamps on an input file. The binary stripping being out-of-band with the rest of these steps means we're always going to be at risk of that target causing a relink of the binary.

Upstream Chromium has their own GN actions for doing stripping for their Linux releases. They do all of the same steps we currently do in CI (copy debug symbols, strip binary, add debug link), with the one exception that we pass --compress-debug-sections to objcopy when copying the debug symbols. To retain that step that required me copy-paste-modifying build/linux/strip_binary.{gni,py} from upstream Chromium. I can try to upstream the extra option since it's a minimal change, and if they accept it then we can drop these files and directly use upstream's.

Chromium's strip_binary action outputs the stripped binaries to separate files (defaults to <name>.stripped, which I've used in this PR), so this required some changes to the build/zip.py script to take the stripped version of the file when it is present. Using upstream's strip_binary also required setting the GN arg enable_linux_installer = false so that upstream's strip actions aren't pulled into the GN build, otherwise we get a GN error about target collision having the same output file (since we're stripping the same files as upstream, but we want our own target for them because we need to output the debug symbols to the debug/ directory, in addition to setting the compress option to true).

One benefit of aligning with upstream here is that we'll be using llvm-strip and llvm-objcopy from the Chromium toolchain, so we'll achieve greater consistency there, and currently we skip copying debug symbols on Linux ARM/ARM64 with a note about objcopy not being available - that should work now, I bellieve.

Things still to test:

  • Has been verified locally, but not in a full CI run
  • We'll want to verify the mksnapshot stuff works on Linux ARM

Checklist

  • PR description included and stakeholders cc'd
  • relevant API documentation, tutorials, and examples are updated and follow the documentation style guide

Release Notes

Notes: none

@dsanders11 dsanders11 marked this pull request as ready for review August 1, 2025 01:58
@dsanders11 dsanders11 requested a review from a team as a code owner August 1, 2025 01:58
Comment on lines +1472 to +1475
":strip_libEGL_shlib",
":strip_libGLESv2_shlib",
":strip_libffmpeg_shlib",
":strip_libvk_swiftshader_shlib",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we shipping these libraries as part of mksnapshot package ? This is not new in this PR, seems like we have been doing this for a while. These are chromium specific and mksnapshot should not be aware of them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepak1556, it looks like these are getting pulled in because the contents of the zip gets pulled from the GN runtime deps for the target. These come in via the dep chain:

//electron:electron_mksnapshot_zip -->
//tools/v8_context_snapshot:v8_context_snapshot_generator -->
//third_party/blink/public:blink

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I thought we were using the target from v8 to build mksnapshot, didn't realize there was another one from tools. However I am pretty sure mksnapshot shouldn't need those libraries to run, the generated ELF didn't show any dependency on them in the dynamic section. Can we double check and remove those, it would save package size.

@codebytere codebytere added target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. labels Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants