Skip to content

Don't fiddle with NDEBUG in C code #16511

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

Merged
merged 2 commits into from
Oct 27, 2024
Merged

Don't fiddle with NDEBUG in C code #16511

merged 2 commits into from
Oct 27, 2024

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 19, 2024

It is way to late to do this in php.h, since assert.h has already been included. Even pushing that down to zend_portability.h may not have the desired effect. Instead we define or undefine NDEBUG as CFLAG, so that it works in all circumstances.

As a last resort we fail at build time, if NDEBUG is defined when ZEND_DEBUG is enabled.

We also remove the useless workaround in zend_test to include assert.h again, since that usually won't have any effect anyway.


This is an alternative to #16366, which had been suggested by @arnaud-lb. I'm not quite sure whether this works well for phpize builds.

Also note that Windows (un)defines the NDebug macro; I have no idea what that is about.

It is way to late to do this in php.h, since assert.h has already been
included.  Even pushing that down to zend_portability.h may not have
the desired effect.  Instead we define or undefine NDEBUG as CFLAG, so
that it works in all circumstances.

As a last resort we fail at build time, if `NDEBUG` is defined when
`ZEND_DEBUG` is enabled.

We also remove the useless workaround in zend_test to include assert.h
again, since that usually won't have any effect anyway.
@cmb69
Copy link
Member Author

cmb69 commented Oct 19, 2024

Need to investigate the build failure for LINUX_X64_DEBUG_ZTS_ASAN.

Co-authored-by: Arnaud Le Blanc <[email protected]>
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

LGTM!

@cmb69 cmb69 marked this pull request as ready for review October 21, 2024 14:11
@cmb69 cmb69 requested a review from bukka as a code owner October 21, 2024 14:11
@cmb69 cmb69 merged commit 836a162 into php:master Oct 27, 2024
10 checks passed
@cmb69 cmb69 deleted the cmb/ndebug2 branch October 27, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants