[Bug 292636] Mk/Uses/meson.mk: Disable asserts on release builds
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 14 Mar 2026 17:23:36 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292636
John Hein <jcfyecrayz@liamekaens.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jcfyecrayz@liamekaens.com
--- Comment #7 from John Hein <jcfyecrayz@liamekaens.com> ---
(In reply to Gleb Popov from comment #5)
According to the docs at least (https://mesonbuild.com/Builtin-options.html),
b_ndebug defaults to false.
"Details for buildtype" in that documentation says "debug" should be false for
"release" builds. But that (debug=false) doesn't explicitly mean that b_ndebug
gets set to true (at least not anywhere that I could see in the doc).
In fact, there is the following statement in that doc:
"Note that -Ddebug=false does not cause the compiler preprocessor macro NDEBUG
to be defined. The macro can be defined using the base option b_ndebug,
described below."
Later in that doc in "Base options", the default for b_ndebug is false. And
the possible settings are false, true and if-release.
Though this is not a direct question to meson upstream, I think this answers
Gleb's question in a RTFM context.
So assuming that documentation (untested by me for correctness), Daniel's patch
seems mostly right.
Or we could explicitly always set b_ndebug=if-release outside the .if .. .elif
.. .else (rather only explicitly setting b_ndebug in the .else part as in
Daniel's patch to meson.mk). Then, b_ndebug will be set according to the
intent of the if-release setting - true if a release buildtype or false if it
is one of the WITH_DEBUG* cases (where buildtype is set to debug or
debugoptimized).
I think if someone is building WITH_DEBUG or WITH_DEBUGINFO, it is appropriate
and expected (POLA-wise) for assertions to be enabled (i.e., b_ndebug=false).
I think using if-release does that for the user automatically.
In other words:
========
--- a/Mk/Uses/meson.mk
+++ b/Mk/Uses/meson.mk
@@ -78,6 +78,7 @@ CONFIGURE_ARGS+= --buildtype release \
--optimization plain \
--strip
. endif
+MESON_ARGS+= -Db_ndebug=if-release
. for _bool in true false enabled disabled
. if defined(MESON_${_bool:tu})
========
Daniel, do you have a fairly easy (even if contrived) reproduction case for a
particular port that exhibits the problem (not getting built with disabled
asserts)?
--
You are receiving this mail because:
You are the assignee for the bug.