[Buildroot] [PATCHv4 02/16] core: enable 'NDEBUG' unless BR2_ENABLE_RUNTIME_DEBUG is set

Yann E. MORIN yann.morin.1998 at free.fr
Sun Jul 4 11:32:08 UTC 2021


Peter, Thomas², All,

On 2021-07-04 13:01 +0200, Peter Korsgaard spake thusly:
> >>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni at bootlin.com> writes:
>  > Hello,
>  > On Tue,  1 Jun 2021 16:34:07 +0200
>  > Thomas De Schampheleire <patrickdepinguin at gmail.com> wrote:
>  >> From: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
>  >> 
>  >> The 'assert' statement in glibc honors the 'NDEBUG' preprocessor macro: if
>  >> it is set, then the assert statement is compiled away.
>  >> 
>  >> Define this 'NDEBUG' macro when BR2_ENABLE_RUNTIME_DEBUG is disabled (the
>  >> default case).
>  >> 
>  >> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
>  > So, I would like to challenge whether this change is really a good
>  > idea. Since this has been merged, we had to add a significant number of
>  > patches to undefine NDEBUG.
> Indeed.

Compiling without assert() should never have had an impact on the
behaviour of the program. Semantically, assert() should only be used to
test pre- and post-conditions (e.g. a value we were passed is in an
acceptable range), i.e. to ensure the contract of the API.

The problem is that developpers have started using assert() as a mean to
test expected error conditions (e.g. the socket was closed by the remote
end), instead of handling them gracefully.

As such, the semantic of assert() has shifted enough that the original
intent is mush less prominent than what it is currently used for.

So yes, this does more harm than it brings benefits.

>  > I believe this change is too dangerous, has caused a number of build
>  > breakage + can cause run-time breakage that is difficult to predict.
>  > What do you think ?
> I agree, I don't think it ends up being a net positive regarding
> cost/benefit. I would prefer to revert it.

In the end, for packages that do use assert() can add NDEBUG to their
CFLAGS if so they wish.

I will revert all those changes, since I was the one who applied the
original changes.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'



More information about the buildroot mailing list