-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
ENH: strip debug symbols from macOS wheels #51900
Comments
One other note for reviewers... I checked all wheels from all files in the the 2.0.0 release candidate (PyPI link) and found that in addition to the macOS wheels, the evidence of that (click me)mkdir /tmp/linux-wheels
cd /tmp/linux-wheels
curl -O \
https://files.pythonhosted.org/packages/3e/55/9212e3cca8c3c2ac8cf6ea85491080e011523bf5a0886782110ef69dfbe5/pandas-2.0.0rc0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
unzip pandas-2.0.0rc0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# list all symbols
docker run \
--rm \
-v $(pwd):/opt/check \
--workdir /opt/check \
python:3.11 \
nm --debug-syms pandas/_libs/algos.cpython-311-x86_64-linux-gnu.so
# show that strip reduces the size
docker run \
--rm \
-v $(pwd):/opt/check \
--workdir /opt/check \
python:3.11 \
du -h pandas/_libs/algos.cpython-311-x86_64-linux-gnu.so
# 2.2M
docker run \
--rm \
-v $(pwd):/opt/check \
--workdir /opt/check \
python:3.11 \
/bin/bash -c 'strip --strip-unneeded pandas/_libs/algos.cpython-311-x86_64-linux-gnu.so && du -h pandas/_libs/algos.cpython-311-x86_64-linux-gnu.so'
# 2.0M Is that expected? If not, would you like me to open a separate issue documenting it? |
Hi @jameslamb, The macOS issue is expected since we can't pass flags for stripping to the linker. I'll try to look into the manylinux issue more. We migrated to a new build system with cibuildwheel, and currently strip the wheels with When I added this, I kind of eyeballed the wheel sizes, but I'll try |
Thanks for looking into it! I'm not that familiar with You could also investigate whether |
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
I found tonight that
.so
files inpandas
macOS wheels contain debug symbols.By my estimate, these add around 1MB compressed and around 4 MB uncompressed to the
cp311-cp311-macosx_10_9_universal2
wheel.how I estimated that (click me)
On my macbook tonight (macOS 12.2, Intel CPU), I downloaded the latest CPython 3.11, macOS universal wheel and checked its size with
du
.Next, I unzipped it and used
dsymutil
to check for debug symbols.That showed some (and interesting that they seem to include filepaths from a CI system's runner image 👀 )
Next, I tried stripping all of the
.so
files using OSXstrip
(docs link).Packed the wheel back up
Then installed it (making sure the environment didn't have
pandas
installed before), and ran the tests.Installation worked, and the tests all ran to completion, with the following results:
I checked all of the wheels (for all platforms) from the 1.5.3 release (PyPI link) and only found debug symbols in the macOS ones.
I did not repeat the analysis above to estimate the size impact of those symbols for any wheels other than the
cp311-cp311-macosx_10_9_universal2
one.Feature Description
If the inclusion of these symbols is not intentional and if I'm right that they're not necessary, please consider removing them.
This might be accomplished by avoiding them in the first place, e.g.:
-g
or similar from being used at build time-DCMAKE_BUILD_TYPE=Release
ifCMake
is being used)*-Wl,strip-all
forgcc
as suggested in Shared libraries are not stripped in the manylinux1 wheels #19531 (comment)Or by stripping those built objects after the fact.
strip -S _file.so
on MacOSI'm not familiar enough with
pandas
build system and preferred toolchain to offer more specific recommendations, sorry.Alternative Solutions
Instead of a
pandas
-specific fix, it might be worth adding support todelocate
similar to howauditwheel
supports stripping after the fact withauditwheel repair --strip
for Linux.I'm not aware of another such tool that works with macOS wheels containing mach-o format objects.
Additional Context
Relevant Discussions
I can see there was some discussion about stripping this project's wheels back in 2018, although that looks to be mostly about Linux wheels:
tests/
directory #19681 (comment)This conversation from 2020 contains some details about building
pandas
on macOS with `clang:Other misc. discussions from similar projects about stripping debug symbols while building Python wheels.
Notes for Reviewers
Thanks very much for your time and consideration!
The text was updated successfully, but these errors were encountered: