-
Notifications
You must be signed in to change notification settings - Fork 34
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
cmake: enable more strict compiler warnings #508
Conversation
ec2f408
to
e57f3d1
Compare
Add |
lib/fizzy/execute.cpp
Outdated
@@ -1963,7 +1963,7 @@ ExecutionResult execute( | |||
} | |||
case Instr::f64_promote_f32: | |||
{ | |||
stack.top() = double{stack.top().f32}; | |||
stack.top() = static_cast<double>(stack.top().f32); |
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.
@chfast do you want this to go into master?
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.
No.
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.
Do we have consensus here?
788f2eb
to
bece2a1
Compare
Codecov Report
@@ Coverage Diff @@
## master #508 +/- ##
=======================================
Coverage 98.73% 98.73%
=======================================
Files 56 56
Lines 8704 8704
=======================================
Hits 8594 8594
Misses 110 110 |
cmake/CableCompilerSettings.cmake
Outdated
@@ -87,6 +87,12 @@ macro(cable_configure_compiler) | |||
# Enable basing warnings set and treat them as errors. | |||
add_compile_options(-Werror -Wall -Wextra -Wshadow) | |||
|
|||
add_compile_options(-Wdouble-promotion -Wcast-qual -Wcast-align -Wdangling-else -Wlogical-not-parentheses -Wmissing-declarations) |
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.
I think this must be checked against documentation.
E.g. -Wlogical-not-parentheses
- is enabled in Clang by default: https://clang.llvm.org/docs/DiagnosticsReference.html#wlogical-not-parentheses
- is enabled in GCC with
-Wall
: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall
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.
I added these based on documentation: first added a lot of the things I liked, then removed those which are included in -Wall
(and other settings we have). Seems like this one slipped through the cracks.
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.
I picked this one randomly.
The -Wdouble-promotion
should be remove as I don't want the change #508 (comment).
I will check the rest.
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.
- It seems
-Wcast-qual
and-Wcast-align
is only for C-style casts of pointers. Unlikely we will see such thing in our code, but the warning option can stay. - The
-Wdangling-else
is enabled by default/-Wall
. - The
-Wmissing-declarations
is nice.
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.
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.
The -Wdouble-promotion should be remove as I don't want the change #508 (comment).
Do you have a reasoning? I'd be also interested to hear @gumb0's view.
The double{x}
is superior to static_cast<double>(x)
and the -Wdouble-promotion
forbids using the first syntax. It is rather a compiler bug due to fact that -Wdouble-promotion
predates the double{x}
syntax.
There is even Clang bug for this: https://bugs.llvm.org/show_bug.cgi?id=34062.
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.
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.
-Wlogical-not-parentheses
looks to be included in -Wall
?
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.
Move the changes to the main CMakeLists.txt, do not modify the Cable file.
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 is cleaned up now.
0fdc110
to
9b65842
Compare
445273e
to
1d5168c
Compare
cddddec
to
5228ae2
Compare
fb2f85b
to
5a5689e
Compare
5a5689e
to
94b61f4
Compare
|
||
option(WEVERYTHING "Enable almost all compiler warnings" OFF) | ||
if(WEVERYTHING) | ||
add_compile_options(-Weverything) |
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.
Why do I not see these on CI?
Build Tidy (Debug)
step outputs
----
Generator: Ninja
Compiler: Clang
Build Type: Debug
LTO: OFF
Flags: -Dd_m3HasTracer -Wall -Wextra -Wparentheses -Wundef -Wpointer-arith -Wstrict-aliasing=2 -Werror=implicit-function-declaration -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -Werror=shadow
Debug flags: -g -DDEBUG=1 -ggdb -O0
Release flags: -O3 -Wfatal-errors -fomit-frame-pointer -fno-stack-check -fno-stack-protector
----
are these not all of the flags?
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.
These are wasm3 flags. We don't add ours to theirs.
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.
I don't see any warning emitted in Build Tidy
, do we not generate any currently? If we did, would CI fail?
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.
All warnings are fixed.
But here is older build with the warning for #508 (comment): https://app.circleci.com/pipelines/github/wasmx/fizzy/4478/workflows/b12515da-c249-4903-aa9f-8d3d1d5e7cbb/jobs/31809
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.
I mean, if it fails CI, what's the point of making them optional?
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.
People can still build it locally without a struggle.
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.
Do you mean they can build it locally without -Weverything for compilers that we don't test?
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.
Yes. Clang discourages usage of -Weverything
regularly for projects so I want to follow this rule for now. While Fizzy is actively maintained it is probably not big deal, but future versions of Clang may enable something we don't want.
@@ -0,0 +1,15 @@ | |||
// Fizzy: A fast WebAssembly interpreter |
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.
Maybe this file should be experimental.hpp
, because two of its three functions are defined in experimental.cpp
?
Also not sure if the third one - leb128u_decode_u64_noinline
- needs to be in its own cpp.
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.
I would go with something less specific than parser_benchmarks.cpp
: experimental.cpp
is fine.
This is not explicitly needed now as I discovered [[noinline]]
attribute...
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 is resolved now to use experimental.hpp
for alternative LEB128 implementation. The other functions were moved to parser_benchmarks.cpp
with [[gnu::noinline]]
attribute.
@@ -137,8 +137,8 @@ class TestValues | |||
std::array<T, ps.size() * 2 + 1> a; | |||
|
|||
auto it = std::begin(a); | |||
it = std::transform(std::reverse_iterator{std::end(ps)}, | |||
std::reverse_iterator{std::begin(ps)}, it, std::negate<T>{}); | |||
it = std::transform(std::make_reverse_iterator(std::end(ps)), |
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.
Does this resolve some warning?
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.
There is warning that reverse_iterator
is may not to designed for CTAD (as it does not have any explicit CTAD hints). I think it is ok to change it here as this is the only case for this warning. And I'm also considering rewriting these test arrays to constexpr version where STL algorithms are going to be less useful.
a72268a
to
66c480f
Compare
Co-authored-by: Paweł Bylica <chfast@gmail.com>
Co-authored-by: Paweł Bylica <chfast@gmail.com>
No description provided.