Skip to content
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

BLD: Try g0 on macos? #51971

Merged
merged 5 commits into from
Mar 15, 2023
Merged

BLD: Try g0 on macos? #51971

merged 5 commits into from
Mar 15, 2023

Conversation

lithomas1
Copy link
Member

@lithomas1 lithomas1 commented Mar 14, 2023

@lithomas1 lithomas1 added the Build Library building on various platforms label Mar 14, 2023
@WillAyd
Copy link
Member

WillAyd commented Mar 14, 2023

Is the issue still seeing debug symbols on macOS? I think there is a Darwin option for gused that is the default which may be generating that:

https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html

@lithomas1
Copy link
Member Author

Is the issue still seeing debug symbols on macOS? I think there is a Darwin option for gused that is the default which may be generating that:

https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html

Doesn't Apple use clang nowadays?

In the logs, I'm seeing a -g option being passed to clang, so I'm trying to cancel it out with the -g0 option (I read somewhere on Stack Overflow that that works, will need to see results, though).

@lithomas1
Copy link
Member Author

I'm not sure who's passing it though.

@WillAyd
Copy link
Member

WillAyd commented Mar 14, 2023

Yea gcc is an alias for clang on macOS by default. I think if you are using conda-compilers though it may actually install gcc.

AFAIK the APIs between the two are supposed to be similar, but I didn't see any documentation for what clang has on gused

https://clang.llvm.org/docs/ClangCommandLineReference.html

@WillAyd
Copy link
Member

WillAyd commented Mar 14, 2023

In the logs, I'm seeing a -g option being passed to clang, so I'm trying to cancel it out with the -g0 option (I read somewhere on Stack Overflow that that works, will need to see results, though).

Yea I think that is true. The GCC documentation for options is really good and thorough. This also confirms that -g0 should negate -g. Let's see

https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options

@WillAyd
Copy link
Member

WillAyd commented Mar 15, 2023

Where in the logs do you see -g showing up? I must be looking in the wrong places.

If I had to guess it's something conda might be adding for us. I think Ralf pointed that out on the meson PR, which was pretty enlightening.

@lithomas1
Copy link
Member Author

lithomas1 commented Mar 15, 2023

Where in the logs do you see -g showing up? I must be looking in the wrong places.

If I had to guess it's something conda might be adding for us. I think Ralf pointed that out on the meson PR, which was pretty enlightening.

Wheels are built with cibuildwheel(uses the GHA python's and sometimes Docker on Linux), so there's absolutely no conda involved right now.

Right now what's really infuriating me is that, even though I'm passing -g0 via CFLAGS, it is somehow showing up as -g, and I'm not sure what I'm doing wrong.

gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -g -arch x86_64 -DNPY_NO_DEPRECATED_API=0 -I/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-build-env-e0sc4bd0/overlay/lib/python3.8/site-packages/numpy/core/include -I/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/cibw-run-am2shr8g/cp38-macosx_x86_64/build/venv/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c pandas/_libs/groupby.c -o build/temp.macosx-10.9-x86_64-cpython-38/pandas/_libs/groupby.o -Wno-error=deprecated-declarations -Wno-error=unreachable-code

Here is an example command. The second -g(before -arch) is mine, but the first one is from something(sysconfig? default flags).

You can find this by ctrl+f for gcc in the logs.

@lithomas1
Copy link
Member Author

Where in the logs do you see -g showing up? I must be looking in the wrong places.
If I had to guess it's something conda might be adding for us. I think Ralf pointed that out on the meson PR, which was pretty enlightening.

Wheels are built with cibuildwheel(uses the GHA python's and sometimes Docker on Linux), so there's absolutely no conda involved right now.

Right now what's really infuriating me is that, even though I'm passing -g0 via CFLAGS, it is somehow showing up as -g, and I'm not sure what I'm doing wrong.

gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -g -arch x86_64 -DNPY_NO_DEPRECATED_API=0 -I/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-build-env-e0sc4bd0/overlay/lib/python3.8/site-packages/numpy/core/include -I/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/cibw-run-am2shr8g/cp38-macosx_x86_64/build/venv/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c pandas/_libs/groupby.c -o build/temp.macosx-10.9-x86_64-cpython-38/pandas/_libs/groupby.o -Wno-error=deprecated-declarations -Wno-error=unreachable-code

Here is an example command. The second -g(before -arch) is mine, but the first one is from something(sysconfig? default flags).

You can find this by ctrl+f for gcc in the logs.

Well, I'm just being stupid. It turns out I was overriding the cibuildwheel environment vars for macos 🤦.

@@ -166,7 +166,7 @@ test-command = ""
# macOS doesn't support stripping wheels with linker
# https://github.com/MacPython/numpy-wheels/pull/87#issuecomment-624878264
select = "*-macosx*"
environment = ""
environment = {CFLAGS="-g0"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice find. a bit orthogonal but wonder if we should strip all symbols here too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess it would help if I read the comment two lines up

@lithomas1
Copy link
Member Author

@jameslamb

I think I got the macOS symbols as well now. Savings are on par with what you mentioned

Savings are currently 0.4 MB compressed for the x86_64 wheel, and 0.2 MB for the arm64 wheel.
(Since universal2 has both x86_64 and arm64, that's why the savings here are like half your savings. We also don't make those wheels anymore as of 2.0rc0, since numpy dropped them as well).

If you'd like to check one of the wheels yourself, here is a link to one of the wheels
https://github.com/pandas-dev/pandas/suites/11567086673/artifacts/599127251
(contains both x86_64 and arm64 in that zip file)

@lithomas1 lithomas1 marked this pull request as ready for review March 15, 2023 11:29
@lithomas1 lithomas1 added this to the 2.0 milestone Mar 15, 2023
@mroeschke mroeschke merged commit f08871d into pandas-dev:main Mar 15, 2023
@mroeschke
Copy link
Member

Thanks @lithomas1

@jameslamb
Copy link
Contributor

@jameslamb

I think I got the macOS symbols as well now. Savings are on par with what you mentioned...

Thanks so much again for the quick resolution on this! I just pulled those wheels from the link you provided... don't see debug symbols in either of them 🎉

If it interests you... I originally found these debug symbols (#51900) using a side-project I've been working on since last year's SciPy conference: https://github.com/jameslamb/pydistcheck. It's intended to be a CLI you run against wheels and sdists in CI, to catch issues like this (click here for a full list of what it checks) and ensure that changes to your build process don't introduce regressions like letting the debug symbols back in.

Anyway, cheers and enjoy the rest of your week 👋🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: strip debug symbols from macOS wheels
4 participants