[Mesa-dev] [PATCH mesa 02/16] anv: tie anv_assert() enablement to regular assert()

Emil Velikov emil.l.velikov at gmail.com
Mon Dec 4 14:04:40 UTC 2017


On 27 November 2017 at 18:40, Eric Engestrom <eric.engestrom at imgtec.com> wrote:
> On Sunday, 2017-11-26 10:12:46 +1100, Timothy Arceri wrote:
>> On 25/11/17 08:02, Timothy Arceri wrote:
>> > On 25/11/17 05:07, Eric Engestrom wrote:
>> > > Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
>> > > ---
>> > >   src/intel/vulkan/anv_private.h | 2 +-
>> > >   1 file changed, 1 insertion(+), 1 deletion(-)
>> > >
>> > > diff --git a/src/intel/vulkan/anv_private.h
>> > > b/src/intel/vulkan/anv_private.h
>> > > index 6d4e43f2e687cbf26ccd..6474abf0f3694c7fcd3a 100644
>> > > --- a/src/intel/vulkan/anv_private.h
>> > > +++ b/src/intel/vulkan/anv_private.h
>> > > @@ -382,7 +382,7 @@ void anv_debug_report(struct anv_instance *instance,
>> > >      } while (0)
>> > >   /* A non-fatal assert.  Useful for debugging. */
>> > > -#ifdef DEBUG
>> > > +#ifndef NDEBUG
>> >
>> > I'm confused by all these assert patches. Doesn't NDEBUG mean no debug
>> > or non-debug why are you switching things around? Won't this add all
>> > this code to release builds and remove it from debug builds?
>>
>> Oh you are using ifndef, I still don't get what you are trying to do with
>> these patches. Can you please explain?
>
> Like the title says, the point is to align the behaviour of our various
> custom asserts with the standard asserts.
> Having them behave differently (read: be enabled or disabled
> asynchronously) can only lead to confusion, and possibly breakages.
>
> (Try to compile a debug build with asserts off or a release build with
> asserts on without patch 12/16 "compiler: use NDEBUG to guard asserts",
> for instance. Although to be fair, that's the only actual breakage I've
> seen so far.)
>
> This confusion was caused by our autoconf script defining NDEBUG when
> DEBUG wasn't defined, which lead some people to believe these are
> interchangeable and/or always tied to each other, but this isn't true
> with other build systems, such as meson.
>
The whole thing predates autoconf by a number of years.

We have:
 - DEBUG - was aimed at extra processing/printfs
Stuff like MESA_DEBUG is guarded behind DEBUG - see mtypes.h,
draw_pipe.c or just grep -w DEBUG for more examples.
 - NDEBUG - asserts

With time we started using DEBUG more and more for asserts - something
that Eric is trying to address here.

-Emil


More information about the mesa-dev mailing list