-
Notifications
You must be signed in to change notification settings - Fork 239
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
Strip debug symbols of wheels #331
Comments
See also numpy/numpy#16110 |
xref MacPython/numpy-wheels#82. FWIW, multibuild uses |
It's not something I'd like cibuildwheel to do by default - for small C extensions, including debug symbols is very nice so that users can supply crash reports. But it might be nice to document it somewhere, for example in the Tips and Tricks section of the docs "Why are my wheels so big?" |
That could also work, ofc. If we then document that adding On the other hand, wouldn't stripping them be a sensible default? By default Python won't print any C stack trace, and it would be reasonably hard for a typical Python users to get these (going through The problem not stripping by default is that (almost) no one reads the docs unless there's a problem (like missing debug symbols). |
That's true, but I'm not sure it's that big of a problem. We don't minify our Python code, even though it could save loads of space/bandwidth. I guess it's a philosophy thing for me - software should be open and hackable by default, especially in open source. But definitely document, as it could be really handy for some projects :) |
This comment suggests using |
For what it's worth, I've tried to compile with multiple settings, and run
and if you zip them, as they will be in a wheel (ratios seems to stay approximately the same):
These are CMake build types, so:
I don't know how representative my project is (there's an enormous code base I'm wrapping that isn't mine but that's +- normal C/C++, but there's also lots of template instantiations coming from pybind11 that will result in long names, I suppose), but stripping symbols results in approximately a third of the size for builds with |
While what you say makes sense, I slightly disagree in this particular context. I agree with the part that software should be open and hackable by default, but built binaries - well, need not be. Considering the fact that most people would use cibuildwheels as the final step for releasing software, I would say stripping out the debug symbols by default would be a wiser choice (at least in my opinion). Or alternatively, there should be an easy option to configure it. |
I guess... I agree that there's some debate to be had here. cibuildwheel doesn't have a position on this though - Python (via
Module authors have full control over how their extensions compile through setup.py. If you want to strip these symbols, I believe you can do: setup(
ext_modules=[
Extension('_foo', ['foo.c'], extra_compile_args=['-g0'])
],
) Refs: https://docs.python.org/3/distutils/setupscript.html#other-options https://clang.llvm.org/docs/UsersManual.html#cmdoption-g0 If somebody can confirm the above syntax that'd be great! Or if there's a better way, let me know. Then we can add some documentation showing how best to do this. |
I just tried out adding the |
It doesn't make any sense if extension is linked against the release edition of Python's run-time library, does it? |
Since python 3.8 there is the same ABI for debug and normal build: |
@cher-nov You still get full names of the functions and methods of the extension module in the strack traces, though. So often, to locate a bug, that's more than enough, and you don't need a debug build of Python itself. |
If we had a "tutorial" page, this might somehow make it in, otherwise, it should just be an entry in FAQ? Pybind11's setup helpers add this by default. https://github.com/pybind/pybind11/blob/721834b422482a522abd4e83f11d545ef876f997/pybind11/setup_helpers.py#L146 |
Yes, an entry in the FAQ would be good, @henryiii. I guess it would be |
Hello, FYI I'm working on this issue in Psycopg 3: psycopg/psycopg#142 I think cython libraries are big offenders, because the names generated are massive. Some stats our side: Worst offender in psycopg 3.0.2 is the x86-64 Python 3.8 wheel package. Stripping our .so files the download size shrunk 33%:
Unpacked footprint of all the libs installed shrunk 60%:
Footprint of the psycopg binaries alone shrunk 88%:
Running |
I was just made aware by @mattip that some Python distributions have
-g
insysconfig.get_config_vars('CFLAGS')
, and thus include debug symbols (including the versions in themanylinux
images, it seems). The reason for this apparently is that these are then stripped before packed in the Debian/Fedora/... package managers (and often the symbols themselves are added as separate package for debugging).The thing about building wheels is that these
sysconfig
are used when building wheels. So should we somehow strip symbols as well, or add-Wl,-strip-all
to the build flags, or ... ?The text was updated successfully, but these errors were encountered: