[Mesa-dev] Let's talk about -DDEBUG

Eric Engestrom eric.engestrom at intel.com
Thu Dec 13 11:06:49 UTC 2018


On Wednesday, 2018-12-12 15:24:25 -0800, Dylan Baker wrote:
> In the autotools discussion I've come to realize that we also need to talk about
> the -DDEBUG guard. It seems that there are two different uses, and thus two
> different asks about it:
> 
> - Nine (and RadeonSI?) use -DDEBUG to hide generic debugging
> - NIR and Intel (at least) use -DDEBUG to hide really expensive checks that are
>   useful, but necessarily tank performance.
> 
> The first group would like -DDEBUG in debugoptimized builds, the second
> obviously doesn't.
> 
> Is the right solution to move the first group being !NDEBUG, or would it be
> better to split DEBUG into two different defines such as DEBUG_MESSAGES and
> EXPENSIVE_VALIDATION (paint the bikeshed whatever color you like), with the
> first for both debug and debugoptimized and the second only in debug builds?

Replacing DEBUG with !NDEBUG is obviously trivially simpler, but I think
the right thing would be to split it into !NDEBUG and EXPENSIVE_VALIDATION
(the color suits me just fine :P), as both solutions satisfy the first
group but only the latter solution satisfies the 2nd group.

I think a first pass might be to simply s/DEBUG/EXPENSIVE_VALIDATION/ so
that it expresses the intent more clearly, with a prior patch to convert
Nine and other obvious !NDEBUG candidates, then, later on, some of the
EXPENSIVE_VALIDATION can be promoted to !NDEBUG on a case-by-case basis.


More information about the mesa-dev mailing list