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

Explicitly setting a debug build also requires explicitly setting b_ndebug=false #441

Closed
ngoldbaum opened this issue Jul 12, 2023 · 6 comments
Labels
invalid This doesn't seem right

Comments

@ngoldbaum
Copy link

ngoldbaum commented Jul 12, 2023

For whatever reason I need to have setup = ["-Dbuildtype=debug", "-Db_ndebug=false"] in my pyproject.toml, not just setup = ["-Dbuildtype=debug"].

I think what's happening is the default meson settings meson-python sets all need to be explicitly overriden. If I just pass -Dbuildtype=debug, the meson setup command meson-python creates is:

+ meson setup --reconfigure /home/nathan/Documents/numpy-user-dtypes/stringdtype /home/nathan/Documents/numpy-user-dtypes/stringdtype/build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dbuildtype=debug --native-file=/home/nathan/Documents/numpy-user-dtypes/stringdtype/build/meson-python-native-file.ini

So I guess meson-python's settings take precedence because they are explicitly set, but then my custom settings for the build type override that, but since I don't have a custom ndebug, the previously set if-release choice doesn't get reset.

Maybe meson-python could check if there is a user-provided buildtype and not set ndebug or buildtype if so?

@dnicolodi
Copy link
Member

When reporting an issue it is desirable to explicitly state what you are trying to achieve, the solution you tried, how it did not work, preferably corroborated by some evidence. The description of this issue allows us only to guess what you are trying to do and why you thin it does not work as expected.

I guess you are trying to obtain a build with debug symbols and with assertions enabled. To achieve that you added

[tool.meson-python.args]
setup = ["-Dbuildtype=debug"]

However, in your opinion that is not sufficient in enabling assertions (ie compile without the -DNDEBUG compilation flag). Why do you think this is the case? The combination of -Dn_debug=if-release -Dbuildtype=debug should not result in the -DNDEBUG compilation flag being set.

@ngoldbaum
Copy link
Author

Sorry if the initial description wasn’t clear. You’re right that I’d expect the combination of -Dn_debug=if-release and -Dbuildtype=debug to not set -DNDEBUG. However, I’m finding that not to be the case, I need to explicitly set -Dn_debug=false.

@dnicolodi
Copy link
Member

How did you verify that? I just tested it and it works as expected, see #442

@ngoldbaum
Copy link
Author

Hmm, I can't seem to reproduce what I was seeing yesterday in my project. Sorry for the noise! I'll try to write a failing test next time I report a bug.

@dnicolodi
Copy link
Member

A complete test is not necessary, however providing a way to reproduce the issue would be nice.

@rgommers
Copy link
Contributor

Glad this is working as expected after all 😅. Choosing defaults has turned out to be tricky enough already.

@rgommers rgommers added the invalid This doesn't seem right label Jul 13, 2023
rgommers added a commit to rgommers/meson-python that referenced this issue Sep 1, 2023
Closes mesonbuildgh-461
Closes mesonbuildgh-207
Also xref mesonbuildgh-459 and mesonbuildgh-441 which are already closed but contain
discussion relevant to debug builds.
rgommers added a commit to rgommers/meson-python that referenced this issue Sep 2, 2023
Closes mesonbuildgh-461
Closes mesonbuildgh-207
Also xref mesonbuildgh-459 and mesonbuildgh-441 which are already closed but contain
discussion relevant to debug builds.
dnicolodi pushed a commit that referenced this issue Sep 2, 2023
Closes gh-461
Closes gh-207
Also xref gh-459 and gh-441 which are already closed but contain
discussion relevant to debug builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants