wheel: strip non-extern symbols on macOS and Linux#6057
Closed
Grantim wants to merge 3 commits into
Closed
Conversation
macOS Mach-O binaries shipped in the meshlib wheel retain all local symbols by default (`__LINKEDIT` is ~67% of `mrmeshpy.so`). Run `strip -x` after `delocate-path` and before `delocate-wheel` so the final wheel ships with externs only — saves roughly 30 MB compressed per macOS wheel without losing any dyld-visible entrypoint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fedr
approved these changes
May 6, 2026
delocate copies brew dylibs preserving their 0444 mode, so `strip -x` fails with EACCES. Bump user-write before each strip call. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pass `--strip` to `auditwheel repair` so the bundled deps in `meshlib.libs/` lose their .symtab/.strtab/.debug_* sections. ~15 MB uncompressed savings across the dep chain (libopenvdb, libxerces, OCCT TK*, libMR*); compresses to ~3-5 MB on the .whl. Companion to the macOS strip step. Windows has no analog — PE files don't carry the equivalent symbol payload (PDBs are external and not bundled). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fedr
approved these changes
May 6, 2026
Contributor
Author
|
Abandoning this approach — the wheel-only strip placement was ineffective (modified the staging dir after |
10 tasks
Grantim
added a commit
that referenced
this pull request
May 7, 2026
Companion to PR #6058. PR-A stripped our own libs at link; this strips the third-party deps that we bundle into wheels/.pkg/NuGet/etc. - Linux: VCPKG_LINKER_FLAGS_RELEASE -Wl,-s in x64+arm64 triplets so vcpkg ports drop .symtab/.strtab/.debug_* during their own release link (~15 MB across the bundled chain). Strip-at-link sidesteps the patchelf alignment bug that broke #6057's auditwheel --strip attempt. - macOS: chmod +w + strip -x every brew dylib in install_brew_requirements.sh so delocate-wheel/install_name_tool/.pkg copy already-trimmed binaries. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
Grantim
added a commit
that referenced
this pull request
May 7, 2026
Companion to PR #6058. PR-A stripped our own libs at link; this strips the third-party deps that we bundle into wheels/.pkg/NuGet/etc. - Linux: VCPKG_LINKER_FLAGS_RELEASE -Wl,-s in x64+arm64 triplets so vcpkg ports drop .symtab/.strtab/.debug_* during their own release link (~15 MB across the bundled chain). Strip-at-link sidesteps the patchelf alignment bug that broke #6057's auditwheel --strip attempt. - macOS: chmod +w + strip -x every brew dylib in install_brew_requirements.sh so delocate-wheel/install_name_tool/.pkg copy already-trimmed binaries. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Grantim
added a commit
that referenced
this pull request
May 7, 2026
…6063) * deps: strip third-party libs at install time (vcpkg + brew) Companion to PR #6058. PR-A stripped our own libs at link; this strips the third-party deps that we bundle into wheels/.pkg/NuGet/etc. - Linux: VCPKG_LINKER_FLAGS_RELEASE -Wl,-s in x64+arm64 triplets so vcpkg ports drop .symtab/.strtab/.debug_* during their own release link (~15 MB across the bundled chain). Strip-at-link sidesteps the patchelf alignment bug that broke #6057's auditwheel --strip attempt. - macOS: chmod +w + strip -x every brew dylib in install_brew_requirements.sh so delocate-wheel/install_name_tool/.pkg copy already-trimmed binaries. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(brew strip): walk Cellar/ instead of lib/ \$BREW_PREFIX/lib contains only symlinks into Cellar/, so the previous find -type f matched nothing. Walking Cellar reaches the real .dylib files. Verified separately: linux vcpkg side stripped libopenvdb.so .strtab from 2.07 MB to 0; mac libopenvdb.dylib __LINKEDIT was unchanged because of this bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: retrigger CI (prepare-image was cancelled mid-flight) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(brew strip): re-sign dylibs with ad-hoc signature after strip strip invalidates the existing ad-hoc signature, and dyld then SIGKILLs any process trying to load the dylib (Apple Silicon enforces this hard). Symptom on the previous run: python3.10 -m ensurepip got Killed: 9. Fix: codesign --force --sign - immediately after strip in the same find chain. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * deps: drop macOS brew strip, scope PR to Linux only The macOS brew strip ran in CI but produced byte-identical libopenvdb.dylib in the wheel — strip+codesign on brew bottles appears to be a silent no-op, likely due to hardened-runtime signature handling. Linux savings (~3 MB compressed via vcpkg triplet -Wl,-s) are real and worth shipping; macOS investigation moves to a separate branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The macOS pip wheel ships every Mach-O binary with its
__LINKEDITsegment intact. Onmrmeshpy.so(124.6 MB)__LINKEDITis 82.8 MB — 67% of the file;libopenvdb.dylibshows the same: 49 MB of 68.8 MB. The macOS build has nostripstep; the Linux build hasauditwheel repairbut doesn't pass--strip, so the 99 bundled libs inmeshlib.libs/retain ~15 MB of.symtab/.strtab/.debug_*they don't need at runtime.This PR adds the missing strip step on both platforms:
strip -xbetweendelocate-pathanddelocate-wheelinscripts/wheel/build_wheel.py.-xremoves only local symbols; externs that dyld binds (PyInit_*, library entrypoints) stay intact, so dynamic loading is unaffected.chmod +wfirst because delocate copies brew dylibs preserving their0444mode.delocate-wheelruns after the strip and re-validates / re-signs.--stripflag onauditwheel repair. auditwheel runsstripon each bundled library during the repair step.delvewheel.Expected savings from analysis of v3.1.2.192 wheels:
.whl(compressed): roughly −30 MB per wheel × 2 architecturesmrmeshpy.so124.6 → ~50 MB uncompressedlibopenvdb.dylib68.8 → ~25 MB uncompressed.whl(compressed): roughly −3-5 MB per wheel × 2 architectures.sofiles (mostly.strtabwhich compresses well, hence the modest net savings)Test plan
CI under the
test-pip-buildlabel produces all 4 wheel artifacts; size delta is visible in the workflow summary.pip installthe macOS arm64 wheel in a fresh venv, runimport meshlib.mrmeshpy; meshlib.mrmeshpy.makeCube()— should succeed (catches any extern accidentally trimmed)lief.parse(...).segmentson a stripped Mach-O:__LINKEDITshould drop from ~80 MB to ~20-30 MB onmrmeshpy.solief.parse(...).sectionson a stripped Linux bundled lib (e.g.libopenvdb.so):.symtab/.strtabshould be near zero🤖 Generated with Claude Code