Pass debugging flags as headers via CMake.
srijan-paul opened this issue · 0 comments
It's possible to pass macro definitions at compile time.
In CMake, this is done via add_definitions.
For this Issue, the solution should be as simple as passing a flag to the compiler at build time.
Currently, there is a macro definition called VYSE_DEBUG
in lang/include/vyse/common.hpp
that defines a macro:
#define VYSE_DEBUG
#define VYSE_DEBUG_RUNTIME 1
#define VYSE_DEBUG_DISASSEMBLY 1
When these macros are defined, the runtime is slower, but does some crash analytics and logs the state of the VM ever so often.
Problem: These flags should not be defined when the codebase is being compiled in release mode. Currently the only way to do this is to manually comment out the macros before compiling a release build. We would want to automate this process.
To solve this, we should check CMAKE_BUILD_TYPE
, if debug, then we pass these macro definitions as compiler flags (instead of hard coding them in a common header file).
We should refrain from defining them in release builds.