Strip local symbols from macOS and Linux release bundles (#63429)
Not sure if this PR is 100% good, since it removes symbols from local traces, leaving addresses only — but this what Windows seem to do already, and we have those symbols on Sentry to restore from, which were needed to normally read Linux perf traces already (see `perf.zip` in https://github.com/zed-industries/zed/issues/59689#issuecomment-5452720248) On the upside, uncompressed binaries' are now ~100MB less, which is a lot — hence decided to open the PR for the review ------------------- Strips debug info and local symbols from shipped macOS and Linux binaries, matching what Windows already does with PDBs: `bundle-mac` now always runs `dsymutil` before a new `strip -x` step, and `bundle-linux` adds `--discard-all` plus `zed.dbg`/`remote_server.dbg` extraction via `--only-keep-debug`. Sentry uploads are unchanged and precede stripping. The macOS binary UUID and the GNU build id survive stripping, so user-provided traces stay recoverable without rebuilding at the reporter's commit: `sample` output resolves via `atos` against the archived `zed.dwarf`, and `perf.data` via `perf buildid-cache` against the Sentry-archived binary. zed binary: macOS (2026-08-29 nightly): 420478976 -> 316503984 bytes (-24.7%, -104.0MB) Linux (v1.17.2 aarch64): 439417448 -> 336967256 bytes (-23.3%, -102.5MB) Downloads shrink far less, symbols compress ~7:1: the macOS DMG loses only ~15MB. Release Notes: - Improved installed size on macOS and Linux by stripping debug symbols from release binaries (roughly -25%)
This commit is contained in:
1 parent
8b32975a05
commit
9be65a8dfe
4 files changed
+80
-20
No files matched your search
+29
-13
@@ -292,24 +292,30 @@ function sign_binary() {
|
||||
fi
|
||||
}
|
||||
|
||||
debug_symbols_extracted=false
|
||||
function extract_debug_symbols() {
|
||||
if [ "$debug_symbols_extracted" = true ]; then
|
||||
return
|
||||
fi
|
||||
debug_symbols_extracted=true
|
||||
if ! dsymutil --flat "target/${target_triple}/${target_dir}/zed" 2> target/dsymutil.log; then
|
||||
echo "dsymutil failed"
|
||||
cat target/dsymutil.log
|
||||
exit 1
|
||||
fi
|
||||
if ! dsymutil --flat "target/${target_triple}/${target_dir}/remote_server" 2> target/dsymutil.log; then
|
||||
echo "dsymutil failed"
|
||||
cat target/dsymutil.log
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function upload_debug_symbols() {
|
||||
if [ "$local_install" = true ]; then
|
||||
echo "local install; skipping sentry upload."
|
||||
elif [[ -n "${SENTRY_AUTH_TOKEN:-}" ]]; then
|
||||
echo "Uploading zed debug symbols to sentry..."
|
||||
exe_path="target/${target_triple}/release/Zed"
|
||||
if ! dsymutil --flat "target/${target_triple}/${target_dir}/zed" 2> target/dsymutil.log; then
|
||||
echo "dsymutil failed"
|
||||
cat target/dsymutil.log
|
||||
exit 1
|
||||
fi
|
||||
if ! dsymutil --flat "target/${target_triple}/${target_dir}/remote_server" 2> target/dsymutil.log; then
|
||||
echo "dsymutil failed"
|
||||
cat target/dsymutil.log
|
||||
exit 1
|
||||
fi
|
||||
# note: this uploads the unstripped binary which is needed because it contains
|
||||
# .eh_frame data for stack unwinding. see https://github.com/getsentry/symbolic/issues/783
|
||||
extract_debug_symbols
|
||||
# Try uploading up to 3 times
|
||||
for attempt in 1 2 3; do
|
||||
echo "Sentry upload attempt $attempt..."
|
||||
@@ -332,6 +338,16 @@ function upload_debug_symbols() {
|
||||
|
||||
upload_debug_symbols
|
||||
|
||||
# Sentry receives the extracted zed.dwarf, not the binary, so debug symbols
|
||||
# must be extracted before the binaries are stripped below. The .dwarf files
|
||||
# also keep symbols recoverable when the sentry upload is skipped.
|
||||
if [[ "$target_dir" == "release" && "$local_install" != true ]]; then
|
||||
extract_debug_symbols
|
||||
strip -x "target/${target_triple}/${target_dir}/zed"
|
||||
strip -x "target/${target_triple}/${target_dir}/cli"
|
||||
strip -x "target/${target_triple}/${target_dir}/remote_server"
|
||||
fi
|
||||
|
||||
cp target/${target_triple}/${target_dir}/zed "${app_path}/Contents/MacOS/zed"
|
||||
cp target/${target_triple}/${target_dir}/cli "${app_path}/Contents/MacOS/cli"
|
||||
sign_app_binaries
|
||||
|
||||
Reference in new issue
Block a user