-
Notifications
You must be signed in to change notification settings - Fork 375
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
[PROF-6288] Enable -Werror
to turn compiler warnings into errors in CI
#2358
Conversation
**What does this PR do?**: This PR enables the `-Werror` compiler flag, which turns any compiler warnings into errors, when compiling profiler C code in CI. I also refreshed the `extconf.rb` for the `ddtrace_profiling_loader` to match the compiler flags from `ddtrace_profiling_native_extension` as well. **Motivation**: Most compiler warnings are quite useful at point out potential bugs, and we want to make sure our code is warning-free on all Ruby versions we support. **Additional Notes**: We don't enable `-Werror` always because we can't control what compiler our customers use. E.g. they may use a new compiler which introduces a new warning which we haven't seen and it doesn't make sense to "break" profiling for them just because of that. **How to test the change?**: Check that CI is still green.
# Older gcc releases may not default to C99 and we need to ask for this. This is also used: | ||
# * by upstream Ruby -- search for gnu99 in the codebase | ||
# * by msgpack, another ddtrace dependency | ||
# (https://github.com/msgpack/msgpack-ruby/blob/18ce08f6d612fe973843c366ac9a0b74c4e50599/ext/msgpack/extconf.rb#L8) | ||
add_compiler_flag '-std=gnu99' | ||
|
||
# Gets really noisy when we include the MJIT header, let's omit it | ||
add_compiler_flag '-Wno-unused-function' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag, as well as others below were already in ext/ddtrace_profiling_native_extension/extconf.rb
but I had forgot to enable them for ext/ddtrace_profiling_loader/extconf.rb
so I took the opportunity to copy them over as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't enable -Werror always because we can't control what compiler our customers use.
That was my fear upon jumping on this PR, but you addressed it immediately.
LGTM!
**What does this PR do?**: In #2358 we changed how the profiling native extension is built in CI by adding the `-Werror` compiler option to turn warnings into errors. We did this automatically by checking if the `CI` environment variable was set to `true`. Unfortunately, this broke at least one user, see <DataDog/datadog-api-client-ruby#1137>. The warning that was triggered in that case was actually not relevant, see my investigation in <#2377>. The `CI=true` was never meant to trigger outside of our CI, but clearly it's too generic of a name for us to rely on that. To fix this, I've gone ahead and changed the configuration so that `-Werror` only gets added when `DD_PROFILING_CI=true`. I also changed our docker and CircleCI configurations to set this by default. **Motivation**: This issue affected one Datadog internal customer -- <DataDog/datadog-api-client-ruby#1137>. This should never happen -- we don't want any issues when compiling the profiling bits to affect ddtrace installation. **Additional Notes**: (Nothing) **How to test the change?**: Validate that `-Werror` only gets added when `DD_PROFILING_CI=true`. To trigger a warning for testing, try removing `DDTRACE_UNUSED` from function argument declarations, and you should see that the compiler starts failing due to that. --- Fixes #2377
What does this PR do?:
This PR enables the
-Werror
compiler flag, which turns any compiler warnings into errors, when compiling profiler C code in CI.I also refreshed the
extconf.rb
for theddtrace_profiling_loader
to match the compiler flags fromddtrace_profiling_native_extension
as well.Motivation:
Most compiler warnings are quite useful at point out potential bugs, and we want to make sure our code is warning-free on all Ruby versions we support.
Additional Notes:
We don't enable
-Werror
always because we can't control what compiler our customers use. E.g. they may use a new compiler which introduces a new warning which we haven't seen and it doesn't make sense to "break" profiling for them just because of that.This PR is on top of
ivoanjo/prof-5942-ractor-support
just out of convenience and does not really depend on anything on that PR.How to test the change?:
Check that CI is still green.