Skip to content

Fix[build]: Don't build libbmq with SAFE asserts in RelWithDebInfo builds - #1243

Closed
pniedzielski wants to merge 2 commits into
bloomberg:mainfrom
pniedzielski:fix/bsls_assert_level_assert_safe
Closed

Fix[build]: Don't build libbmq with SAFE asserts in RelWithDebInfo builds#1243
pniedzielski wants to merge 2 commits into
bloomberg:mainfrom
pniedzielski:fix/bsls_assert_level_assert_safe

Conversation

@pniedzielski

Copy link
Copy Markdown
Collaborator

Please see commit messages for details.

In `bmq_add_application_test`, there were originally two separate
if-blocks checking `${lib_target}_TEST_TARGETS`.  The first imported
test dependencies, and the second handled `.td` test driver manifest
generation before also importing test dependencies.  When the `.td`
target logic was removed in commit 595bdd8, the second block was
reduced to just the `bbs_import_target_dependencies` call, making it
an exact duplicate of the first.  This patch removes the redundant
second block.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
The build previously used a global `add_definitions()` to enable
`BSLS_ASSERT_LEVEL_ASSERT_SAFE` on all targets in non-Release builds.
This includes libbmq, which users may link against in production
`RelWithDebInfo` builds.  Enabling SAFE asserts in libbmq can be a
breaking change for those users by introducing assertion failures that
do not occur in Release builds.

This patch removes the global definition and instead enables safe
asserts selectively, for mqb, applications, and test targets.  libbmq
itself no longer gets the definition, but all of its unit tests still
do.

In the future, we should consider building libbmq with
`BSLS_ASSERT_LEVEL_ASSERT_SAFE` in CI using CMakePresets, or perhaps
controlling this entirely from CMakePresets.  For the moment, this
patch is a simple fix that prevents us from breaking users while we
figure out the best way to handle this.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
@pniedzielski
pniedzielski requested a review from hallfox April 1, 2026 20:28
@pniedzielski
pniedzielski requested a review from a team as a code owner April 1, 2026 20:28
@hallfox

hallfox commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

I'm a little skeptical of getting this fine-grained with where SAFE asserts are enabled. I think it may be fine to keep the current global option of always use safe unless otherwise specified in a configure variable that we just make up, e.g. -DBLAZINGMQ_ASSERT_LEVEL=OPT/-DBLAZINGMQ_ASSERT_LEVEL=ASSERT/-DBLAZINGMQ_ASSERT_LEVEL=SAFE. Then the bmq release unit can be specified to use the correct level where it makes sense to.

@pniedzielski

Copy link
Copy Markdown
Collaborator Author

Let me give that a shot.

@pniedzielski
pniedzielski deleted the fix/bsls_assert_level_assert_safe branch April 15, 2026 17:01
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.

2 participants