Skip to content

RFC: tree-wide: rename DEBUG to EXPENSIVE_CHECKS to stop the confusion with NDEBUG

Eric Engestrom requested to merge eric/mesa:rename-debug into main

There have been countless discussions, confusion & bugs around what DEBUG means/is used for and how it's different from NDEBUG. The latest one that I saw (and which prompted me to finally do something about it) was #4965 (closed) but I expect most of you will recall the various times this came up.

It also causes issue with projects like LLVM and Bellagio which make use of such a common name in their headers, leading to workarounds like including a header, undef'ing DEBUG, and re-including the header, or having to undef DEBUG right before including a specific header. These are fragile (new version of these headers might move the code around) and there's a good chance we might forget to add the workaround in new code including these headers, leading to inconsistent behaviour across build types.

Let's finally pick a better name, which I arbitrarily called EXPENSIVE_CHECKS. It should be quite easy to rename it to something else, should someone suggest a better name.


This MR focuses on the rename, let's make sure I didn't sed too much or incorrectly. Fixing code that shouldn't have been using this define is left as an exercise for the reader for follow up MRs, with a couple of exceptions: src/gallium/auxiliary/gallivm/ & src/gallium/frontends/omx/bellagio/ had special code to handle DEBUG being used in other project headers, which is no longer relevant so it has been dropped.

Merge request reports