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

Jason Ekstrand jason at jlekstrand.net
Thu Dec 13 17:41:52 UTC 2018


On Thu, Dec 13, 2018 at 11:34 AM Dylan Baker <dylan at pnwbakers.com> wrote:

> Quoting Rob Clark (2018-12-12 16:35:24)
> > On Wed, Dec 12, 2018 at 7:14 PM Dylan Baker <dylan at pnwbakers.com> wrote:
> > >
> > > Quoting Rob Clark (2018-12-12 15:52:47)
> > > > On Wed, Dec 12, 2018 at 6:25 PM Dylan Baker <dylan at pnwbakers.com>
> 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?
> > > >
> > > > I guess my use cases for !=release builds are:
> > > >
> > > > + I want all the expensive checking because I'm not in it to win the
> > > >   deqp/piglit fps race
> > > > + I want debug syms for profiling and/or valgrind, but otherwise
> > > >   want something close to a release build but with debug syms
> > > >
> > > >
> > > > That said, I can get behind replacing DEBUG with !NDEBUG or
> > > > EXPENSIVE_DEBUG or whatever permutation of that color folks prefer
> > > >
> > > >
> > > > BR,
> > > > -R
> > >
> > > I guess I should have covered that:
> > >
> > > autotools had effectively two build types "debug" and "not debug",
> "debug" set
> > > "-DDEBUG -g -O2", "not debug" set -DNDEBUG
> > >
> > > Meson has 4 build types, and a separate toggle for NDEBUG:
> > > debug: -O0 -DDEBUG (we add -DDEBUG)
> > > debugoptimzed: -O2 -g
> > > release: -O2
> > > plain: (nothing)
> >
> > I generally view meson as an upgrade in this respect, I guess mostly
> > because I have no use for '-DDEBUG -g -O2' (ie. the -O0 equiv is fine
> > by me).. maybe making meson debug config use -O2 would bridge the gap?
> >  If so I have no problem with dropping -O0 and making debug config
> > also use -O2
> >
> > BR.
> > -R
>
> Unfortunately buildtypes are part of meson itself, you can't override
> them. It
> does this to ensure that each buildtype is equivalent when changing
> compiler,
> ie, MSVC doesn't have -O0 and -O2, but it does have equivalent commands
> options.
>
> Basically our choices (as I see them are):
>
> 1. Status Quo
> 2. Split DEBUG into two flags, one that is only in debug builds, one that
> is in
>    both debug and debugoptimized builds
>

Whatever we do, let's please not split DEBUG and NDEBUG.  We've had no end
of trouble with sorting out the fallout of them being different.


> 3. Stop defining DEBUG by default in any build type and tell people to add
>    -Dc_args=-DDEBUG -Dcpp_args=-DDEBUG if they want DEBUG.
>

Can we not please?  Yes, I have a script that wraps things but
-Dbuild-type=debug should do something reasonable and reasonable includes
-DDEBUG.

--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181213/0cadb1e7/attachment-0001.html>


More information about the mesa-dev mailing list