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

Eero Tamminen eero.t.tamminen at intel.com
Thu Dec 13 16:09:50 UTC 2018


Hi,

On 13.12.2018 12.19, Eric Engestrom wrote:
> On Wednesday, 2018-12-12 19:45:06 -0500, Marek Olšák wrote:
>> On Wed, Dec 12, 2018 at 7:35 PM Rob Clark <robdclark at gmail.com> wrote:
>>> 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)
...
>>>> 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

Target without optimizations is good to track down issues triggered by
compiler optimizations, and to have faster builds.


>> Sounds good.
>>
>> Also I think we should make -Db_ndebug=true the default for release builds.
>> !NDEBUG enables a lot more debugging code than just assertions.
> 
> That's already the case :)
> 
> The default value (line 29 of the root meson.build) is:
> 
>    b_ndebug=if-release
> 
> which means it will default to `true` if `buildtype=release`, and `false`
> otherwise, while still being overridden if you manually set `b_ndebug`.

There needs to be something that's release with debug symbols, but
without _any_ other differences.  If build type assert handling differs
from release, debug symbols are less of a use for debugging issues
with release build.


Build type names could also be more descriptive, although something
like this seems overkill:
- release
- release_with_symbols
- release_with_symbols_and_asserts
- full_debug

Meson can help by outputting exact description of each build types,
e.g. when one doesn't specify one, or unrecognized one is provided.


	- Eero


More information about the mesa-dev mailing list