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

allow project to be built with NDEBUG #6355

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

garlick
Copy link
Member

@garlick garlick commented Oct 8, 2024

Problem: as noted in #6354, we get some compiler warnings (promoted to errors) when the project is built with -DNDEBUG.

@grondo pointed out that we missed adding CODE_COVERAGE_CPPFLAGS to our Makefiles, otherwise we would have been building with that flag in CI.

So this PR adds CODE_COVERAGE_CPPFLAGS to AM_CPPFLAGS in all our Makefiles, and then addresses the warnings that result in a way that seemed appropriate for the context, one of:

  • remove the assertion
  • convert assertion to warning
  • declare assertion-only vars with __attribute__((unused))

Problem: compiler warnings are issued on message code
when the project is built with NDEBUG defined.

Remove unhelpful assertions.
Problem: when the kvs is compiled with NDEBUG, warnings
are issued for unused variables.

Declare those variables with __attribute__((unused)) to
silence the warnings.
Problem: compiler warnings are issued on the broker code
when the project is built with NDEBUG defined.

Convert assertions to runtime errors.
Just remove some assertions that are not helpful.
Problem: compiler warnings are issued on the flux-proxy code
when the project is built with NDEBUG defined.

Convert warnings to runtime errors.
In one case, remove an unnecessary assertion.
Problem: AM_CPPFLAGS does not include CODE_COVERAGE_CPPFLAGS,
so NDEBUG is not defined when coverage is calculated.

Furthermore, this means the code is not compiled with NDEBUG in CI,
so we don't notice some unused variable warnings that may come up
for end users.

Add CODE_COVERAGE_CPPFLAGS to all the AM_CPPFLAGS definitions
in our Makefile.am files.

Fixes flux-framework#6354
Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

Wow, thank you! LGTM!

@garlick
Copy link
Member Author

garlick commented Oct 8, 2024

Thanks! Setting MWP.

@mergify mergify bot merged commit 4e17867 into flux-framework:master Oct 8, 2024
32 of 33 checks passed
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 60.97561% with 16 lines in your changes missing coverage. Please review.

Project coverage is 83.29%. Comparing base (13430c8) to head (5ee0cc4).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/broker/attr.c 45.45% 6 Missing ⚠️
src/broker/overlay.c 33.33% 2 Missing ⚠️
src/cmd/builtin/proxy.c 50.00% 2 Missing ⚠️
src/modules/kvs/kvstxn.c 33.33% 2 Missing ⚠️
src/broker/boot_config.c 50.00% 1 Missing ⚠️
src/broker/broker.c 50.00% 1 Missing ⚠️
src/common/libflux/message.c 80.00% 1 Missing ⚠️
src/modules/kvs/kvs.c 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6355      +/-   ##
==========================================
- Coverage   83.32%   83.29%   -0.04%     
==========================================
  Files         523      523              
  Lines       86209    86194      -15     
==========================================
- Hits        71836    71795      -41     
- Misses      14373    14399      +26     
Files with missing lines Coverage Δ
src/broker/boot_pmi.c 65.79% <ø> (ø)
src/broker/brokercfg.c 70.12% <ø> (ø)
src/broker/groups.c 84.73% <ø> (ø)
src/broker/modhash.c 79.94% <100.00%> (-0.11%) ⬇️
src/broker/module.c 78.06% <100.00%> (-0.06%) ⬇️
src/broker/runat.c 79.19% <ø> (ø)
src/modules/kvs/cache.c 90.35% <100.00%> (ø)
src/modules/kvs/lookup.c 78.88% <100.00%> (ø)
src/broker/boot_config.c 81.05% <50.00%> (-0.26%) ⬇️
src/broker/broker.c 76.93% <50.00%> (-0.21%) ⬇️
... and 6 more

... and 13 files with indirect coverage changes

@garlick garlick deleted the issue#6354 branch October 8, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants