Skip to content

Conversation

@marcelm
Copy link
Collaborator

@marcelm marcelm commented Nov 27, 2025

(I made this a while ago and waited until #521 was merged.)

Assertions (through assert()) are enabled by default and need to be disabled by defining the NDEBUG ("no debug") macro with the compiler option -DNDEBUG. CMake adds that option for all build types (-DCMAKE_BUILD_TYPE=...) except Debug, but for Debug, optimizations are entirely disabled, which makes strobealign unusable.

This commit

  • enables optimizations for the Debug build type
  • enables -O3 instead of -O2 for the RelWithDebInfo build type
  • outputs a warning when assertions are enabled (they slow things down and are not meant to be enabled for a release)

So after this commit:

  • Use -DCMAKE_BUILD_TYPE=Release when building a release
  • Use -DCMAKE_BUILD_TYPE=Debug for development
  • Use -DCMAKE_BUILD_TYPE=RelWithDebInfo for profiling

@ksahlin
Copy link
Owner

ksahlin commented Nov 27, 2025

approved

Assertions (through `assert()`) are enabled by default and need to be
disabled by defining the `NDEBUG` ("no debug") macro with the compiler option
`-DNDEBUG`. CMake adds that option for all build types
(`-DCMAKE_BUILD_TYPE=...`) except `Debug`, but for `Debug`,
optimizations are entirely disabled, which makes strobealign unusable.

This commit
- enables optimizations for the `Debug` build type
- enables `-O3` instead of `-O2` for the `RelWithDebInfo` build type
- outputs a warning when assertions are enabled (they slow things down and
  are not meant to be enabled for a release)

So after this commit:

- Use `-DCMAKE_BUILD_TYPE=Release` when building a release
- Use `-DCMAKE_BUILD_TYPE=Debug` for development
- Use `-DCMAKE_BUILD_TYPE=RelWithDebInfo` for profiling
@marcelm marcelm merged commit 3740183 into main Dec 8, 2025
11 checks passed
@marcelm marcelm deleted the easier-assert branch December 8, 2025 21: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.

3 participants