Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce custom preprocessor flag for debugging #20

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

psalz
Copy link
Member

@psalz psalz commented Oct 27, 2020

This introduces the CELERITY_DETAIL_ENABLE_DEBUG flag, which is set for debug builds of the Celerity runtime, regardless of a user target's build type. This is more reliable than using NDEBUG, as headers and implementation files are always guaranteed to receive the flag, both during library compilation and when linking to it. Also it means having less of those confusing double-negative !defined(NDEBUG) checks.

Unfortunately the implementation turned out to be quite annoying (of course...), as CMake doesn't really expose a mechanism for querying the build configuration of a library target that is being linked (which could then be used e.g. in generator expressions). The workaround for now is to inspect the IMPORTED_CONFIGURATIONS of the Celerity::celerity_runtime library, and use that to conditionally set the flag. For this to work however we require that only a single build configuration is imported in the first place, as otherwise it becomes more difficult to tell which configuration ends up being linked (albeit not impossible).

While thus far we effectively already only really supported one installed build configuration (as we'd otherwise have to set the CMAKE_<CONFIG>_POSTFIX variables), instead of adding support for multiple configurations, I've decided to enforce single config installs with an error for now. While I do see merit in having that feature, I can also see it causing a lot of unnecessary headaches during development, when rebuilding one configuration of the runtime, while some executable still links to the other one... So maybe we could look into e.g. only enabling this for versioned releases.

This should fix #19.

Copy link
Contributor

@fknorr fknorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

This introduces the CELERITY_DETAIL_ENABLE_DEBUG flag, which is set for
debug builds of the Celerity runtime, regardless of a user target's
build type. This is more reliable than using NDEBUG, as headers and
implementation files are always guaranteed to receive the flag, both
during library compilation and when linking to it.

Additionally:
   - Fix a bug within buffer_manager which caused it to have a different
     size for debug and non-debug builds (prompting this change).
   - Restrict Celerity installations to a single build configuration.
     This was effectively already the case (as we currently don't set
     CMAKE_<CONFIG>_POSTFIX), but now an error is generated whenever two
     or more build configurations are detected.
@psalz psalz merged commit 2c12944 into master Dec 14, 2020
@psalz psalz deleted the custom-debug-pp-flag branch December 14, 2020 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

buffer_manager causes a segment fault
2 participants