AnyDSL / thorin

The Higher-Order Intermediate Representation
https://anydsl.github.io
GNU Lesser General Public License v3.0
150 stars 15 forks source link

Allow compiling with debug but no checks #123

Closed PearCoding closed 2 years ago

PearCoding commented 2 years ago

Just a quick bugfix. I detected that bug randomly. Maybe replace the NDEBUG check completely and only relay on THORIN_ENABLE_CHECKS. Without the fix thorin will not compile in build environments where neither NDEBUG nor THORIN_ENABLE_CHECKS is defined.

Remark: I have no idea why someone would do this configuration, but the current source is not handling this case.

michael-kenzel commented 2 years ago

I have literally just run into this bug right now while upgrading my AnyDSL setup to the latest version. I'm running this configuration because AnyDSL and LLVM have the unfortunate habit of placing vital diagnostics behind assertions rather than compiler errors. I have lost so many hours to debugging what ultimately turned out to be consequences of this that I will simply never use an AnyDSL build that doesn't have assertions turned on anymore. At the same time, there's no reason for me to pay for using a full debug build of the compilers since I'm generally not going to be debugging the compilers, just using them.

The fix I've implemented locally now just replaces the

#ifndef NDEBUG

with

#if THORIN_ENABLE_CHECKS

since I don't see any good reason why this should be tied to whether assertions are turned on or not. Whether state_.breakpoints exists or not also only depends on THORIN_ENABLE_CHECKS

PearCoding commented 2 years ago

If the existence of state_.breakpoints only relies on THORIN_ENABLE_CHECKS I agree. In the end I don't care how the bug is fixed. I also only use the Release mode (sometimes with asserts) and the Debug mode, if ever, always with asserts.

richardmembarth commented 2 years ago

fixed in #126