-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
ENH:Distutils Remove debugging symbols by default #16110
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
Conversation
b25224d to
4373d2a
Compare
runtests.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what the point of using -ggdb over -g?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably gdb format was more useful than OS native format in the past. However it's 2020 now, and assuming everyone uses GCC seems a little outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense thanks!, I kept it untouched, I will try to release a cleanup patch to beautify build logs and remove such cases like this one.
|
Sounds like a good idea to me in principle. Note that our wheels do get stripped (MacPython/numpy-wheels#19), however there's many ways to build NumPy and debug info is only needed rarely so non-debug as default makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @seiko2plus! I like the goal of this, not quite sure about the way of filtering. Also, Fortran compilers should probably be treated the same way as C/C++ compilers.
numpy/distutils/ccompiler.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me like trying to strip out flags that are set already may be confusing. This would also filter out flags explicitly set in for example CFLAGS right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my bad, I fixed it by execluding debug flags only if they weren't part of env vars.
Debug info flags are always set by the default which increases the binary size to over 600%, in case of the debug info is required for backtraces, the user has to rebuild NumPy with build option --debug.
4373d2a to
a20bb72
Compare
But I wonder why the wheel package that I fetched through PIP still has debug info?
It also makes |
I update it doc string, to add more clarification, I'm not sure yet about Fortran I will check it. |
Which wheel package are you using? |
|
@mattip, numpy-1.18.3-cp37-cp37m-manylinux1_x86_64.whl du site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so
20968 site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.sobloaty site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so
FILE SIZE VM SIZE
-------------- --------------
51.6% 10.6Mi 0.0% 0 .debug_loc
18.0% 3.69Mi 0.0% 0 .debug_info
14.3% 2.93Mi 74.9% 2.93Mi .text
5.9% 1.21Mi 0.0% 0 .debug_ranges
3.2% 673Ki 0.0% 0 .debug_line
1.3% 281Ki 7.0% 281Ki .eh_frame
1.1% 228Ki 5.7% 228Ki .rodata
0.8% 178Ki 0.0% 0 .symtab
0.8% 163Ki 0.0% 0 .debug_str
0.7% 154Ki 0.0% 0 .strtab
0.0% 0 3.3% 131Ki .bss
0.5% 110Ki 2.8% 110Ki .data
0.5% 101Ki 2.5% 101Ki .rela.dyn
0.4% 87.0Ki 0.0% 0 .debug_abbrev
0.2% 49.1Ki 1.2% 49.0Ki .eh_frame_hdr
0.2% 35.4Ki 0.7% 27.4Ki [22 Others]
0.1% 22.5Ki 0.6% 22.5Ki .dynsym
0.1% 15.0Ki 0.4% 15.0Ki [LOAD #0 [RX]]
0.1% 14.9Ki 0.4% 14.8Ki .rela.plt
0.1% 11.2Ki 0.3% 11.1Ki .dynstr
0.1% 11.1Ki 0.3% 11.1Ki [LOAD #6 [RW]]
100.0% 20.5Mi 100.0% 3.91Mi TOTAL |
|
I think the CFLAGS that are meant to strip the binaries are being reset by the |
|
As far as I can tell, these flags are coming from the host python: I don't think this is a numpy-specific problem, it is due to the way Ubuntu/Debian build python. We should fix our wheel building, but I am not sure we need to interfere with the flags here. |
|
@mattip, yes flags come from sysconfig var |
|
Do we want to make stripping a default or leave that choice to downstream projects? |
|
@charris, we should leave them the choice to enable debugging symbols via CFLAGS or through |
|
If we are changing the behavior then we need a release note telling folks that debug versions need to be specified and how to do it. Maybe in the "Changes" section. |
|
I am -0.5 on accepting this. It seems to be a local fix for a python-wide problem. I think a better place to change flags would be upstream: perhaps in distutils (or setuptools) or Note the problem of wheel size was fixed in MacPython/numpy-wheels#87. |
|
That sounds good @seiko2plus, thanks! |
|
IIRC we decided to not put this in, since the wheels are where the size really matters and those are being stripped now. Thanks @seiko2plus. (please reopen if I misremembered.) |
|
@seberg, no problem, fully respect it. thanks. |
Debug info flags are always set by the default which increases
the binary size to over 600%, in case of the debug info
is required for backtraces, the user has to rebuild NumPy
with build option --debug.
Shared object sizes with debug flags
Shared object sizes "without" debug flags
Umath extension binary info via Bloaty with debug flags
bloaty core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so FILE SIZE VM SIZE -------------- -------------- 45.0% 9.39Mi 0.0% 0 .debug_loc 22.0% 4.58Mi 0.0% 0 .debug_info 11.4% 2.38Mi 71.8% 2.38Mi .text 9.7% 2.03Mi 0.0% 0 .debug_line 5.3% 1.10Mi 0.0% 0 .debug_ranges 1.2% 263Ki 7.8% 263Ki .eh_frame 1.1% 233Ki 6.9% 233Ki .rodata 0.9% 182Ki 0.0% 0 .symtab 0.8% 174Ki 0.0% 0 .debug_str 0.0% 0 3.9% 130Ki .bss 0.6% 117Ki 0.0% 0 .strtab 0.5% 110Ki 3.3% 110Ki .data 0.5% 107Ki 0.0% 0 .debug_abbrev 0.5% 100Ki 3.0% 100Ki .rela.dyn 0.2% 50.0Ki 1.5% 49.9Ki .eh_frame_hdr 0.1% 22.1Ki 0.6% 22.0Ki .dynsym 0.1% 22.0Ki 0.4% 12.5Ki [21 Others] 0.1% 10.9Ki 0.3% 10.9Ki .dynstr 0.0% 9.46Ki 0.3% 9.40Ki .rela.plt 0.0% 6.34Ki 0.2% 6.28Ki .plt 0.0% 5.94Ki 0.2% 5.88Ki .gnu.hash 100.0% 20.9Mi 100.0% 3.31Mi TOTALUmath extension binary info via Bloaty "without" debug flags
bloaty core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so FILE SIZE VM SIZE -------------- -------------- 68.3% 2.38Mi 71.8% 2.38Mi .text 7.4% 263Ki 7.8% 263Ki .eh_frame 6.6% 233Ki 6.9% 233Ki .rodata 5.1% 182Ki 0.0% 0 .symtab 0.0% 0 3.9% 130Ki .bss 3.3% 117Ki 0.0% 0 .strtab 3.1% 110Ki 3.3% 110Ki .data 2.8% 100Ki 3.0% 100Ki .rela.dyn 1.4% 50.0Ki 1.5% 49.9Ki .eh_frame_hdr 0.6% 22.1Ki 0.6% 22.0Ki .dynsym 0.3% 10.9Ki 0.3% 10.9Ki .dynstr 0.3% 9.46Ki 0.3% 9.40Ki .rela.plt 0.2% 6.34Ki 0.2% 6.28Ki .plt 0.2% 5.94Ki 0.2% 5.88Ki .gnu.hash 0.2% 5.40Ki 0.2% 5.15Ki .data.rel.ro 0.1% 4.56Ki 0.0% 0 [Unmapped] 0.1% 3.22Ki 0.1% 3.16Ki .got.plt 0.1% 2.03Ki 0.0% 1.12Ki [14 Others] 0.1% 1.90Ki 0.1% 1.83Ki .gnu.version 0.0% 712 0.0% 648 .got 0.0% 632 0.0% 632 [LOAD #0 [R]] 100.0% 3.48Mi 100.0% 3.31Mi TOTAL