-
Notifications
You must be signed in to change notification settings - Fork 5
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: Add compiler diagnostic flags #84
Conversation
131db28
to
d9d0ce7
Compare
ff2f574
to
dacc6f7
Compare
d9d0ce7
to
9d64cb6
Compare
Rebased. |
9d64cb6
to
92291c0
Compare
src/qt/CMakeLists.txt
Outdated
@@ -85,6 +85,9 @@ target_include_directories(bitcoinqt | |||
PUBLIC | |||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> | |||
) | |||
set_property(SOURCE macnotificationhandler.mm | |||
APPEND PROPERTY COMPILE_OPTIONS -Wno-error=deprecated-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.
This isn't in the master branch? Also not sure why it's -Wno-error? We aren't moving to a state where we are using, or trying to enable -Werror
by default?
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 isn't in the master branch?
bitcoin#29362 has been submitted to the master branch.
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.
Ok, dropped.
cmake/secp256k1.cmake
Outdated
@@ -57,4 +57,6 @@ if(MSVC) | |||
) | |||
endif() | |||
|
|||
target_link_libraries(secp256k1 PRIVATE core_interface) | |||
# Using core_base_interface instead of core_interface | |||
# to avoid C++-specific flags from warn_interface. |
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 comment can be improved. We are avoiding passing warning flags to libsecp256k1 because it's a subtree, and warnings produced aren't fixable in our tree, making them pointless, not because it's C code.
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.
Thanks! Reworked.
) | ||
try_append_cxx_flags("-Wself-assign" TARGET warn_interface | ||
IF_CHECK_PASSED "-Wno-self-assign" | ||
) |
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.
Missing -Wno-deprecated-copy
?
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. It is not required anymore as CMake includes imported packages headers as system ones, which effectively suppresses external warnings.
17f4870
to
6367599
Compare
92291c0
to
be01037
Compare
3ef5cc5
to
7878e2b
Compare
33dee19 fixup! cmake: Build `leveldb` static library (Hennadii Stepanov) Pull request description: This PR split from #84 It introduces a new `warn_leveldb_interface`, which overrides `-Wconditional-uninitialized` and `-Wsuggest-override` if any. For MSVC builds, dropped warning suppressions that are provided at the global level. For example, on the staging branch: ``` $ env CC=clang CXX=clang++ CXXFLAGS="-Wconditional-uninitialized -Wsuggest-override" cmake -B build $ cmake --build build --target leveldb > /dev/null /home/hebasto/git/bitcoin/src/leveldb/db/c.cc:474:17: warning: 'Name' overrides a member function but is not marked 'override' [-Wsuggest-override] const char* Name() const { return rep_->Name(); } ^ /home/hebasto/git/bitcoin/src/leveldb/db/c.cc:110:15: note: overridden virtual function is here const char* Name() const override { return (*name_)(state_); } ^ /home/hebasto/git/bitcoin/src/leveldb/db/c.cc:475:10: warning: 'CreateFilter' overrides a member function but is not marked 'override' [-Wsuggest-override] void CreateFilter(const Slice* keys, int n, std::string* dst) const { ^ /home/hebasto/git/bitcoin/src/leveldb/db/c.cc:112:8: note: overridden virtual function is here void CreateFilter(const Slice* keys, int n, std::string* dst) const override { ^ /home/hebasto/git/bitcoin/src/leveldb/db/c.cc:478:10: warning: 'KeyMayMatch' overrides a member function but is not marked 'override' [-Wsuggest-override] bool KeyMayMatch(const Slice& key, const Slice& filter) const { ^ /home/hebasto/git/bitcoin/src/leveldb/db/c.cc:125:8: note: overridden virtual function is here bool KeyMayMatch(const Slice& key, const Slice& filter) const override { ^ 3 warnings generated. /home/hebasto/git/bitcoin/src/leveldb/db/version_set.cc:1016:55: warning: variable 'manifest_size' may be uninitialized when used here [-Wconditional-uninitialized] descriptor_log_ = new log::Writer(descriptor_file_, manifest_size); ^~~~~~~~~~~~~ /home/hebasto/git/bitcoin/src/leveldb/db/version_set.cc:997:25: note: initialize the variable 'manifest_size' to silence this warning uint64_t manifest_size; ^ = 0 1 warning generated. ``` ACKs for top commit: vasild: ACK 33dee19 theuni: ACK 33dee19 Tree-SHA512: ffe9efc438bc808a42abaa42a45f7073c1e3cdd6404e9b8b811e94b304c2464f3df26c276d363c97a3941d50f0e6bcb3788f1d870dd23df86b0d9a33363b7e77
cbd43cc fixup! cmake: Build `bitcoind` executable (Hennadii Stepanov) 6be6d78 fixup! cmake: Build `bitcoin_util` static library (Hennadii Stepanov) Pull request description: The `HAVE_THREAD_LOCAL` is not visible in `src/test/util_threadnames_tests.cpp`. It is easy to verify with the diff as follows: ```diff --- a/src/test/util_threadnames_tests.cpp +++ b/src/test/util_threadnames_tests.cpp @@ -55,6 +55,7 @@ std::set<std::string> RenameEnMasse(int num_threads) BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded) { #if !defined(HAVE_THREAD_LOCAL) +#error // This test doesn't apply to platforms where we don't have thread_local. return; #endif ``` This PR fixes this issue by moving the macro definition to the `core_interface` library. Split from #84. ACKs for top commit: vasild: ACK cbd43cc Tree-SHA512: bd558ae35251d0e9bbdf494690a06ed57f6a36bdbf94840f1b134779bef5aa1de94ee53c962948a5a4b9cc11927777b5a919a7506779149e5fe0c6355c416419
7878e2b
to
ab1a745
Compare
Rebased and undrafted. |
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.
ACK ab1a745
# For -Wno-error=unreachable-code, please refer to https://github.com/bitcoin/bitcoin/issues/29334 | ||
configure_env: 'env CXXFLAGS="-Wno-error=unreachable-code"' |
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.
Adding this to silence a particular issue, obviously has the problem that if new issues like that are created, then they will be silenced as well (on this platform). 👎 I understand that this is the best thing to do if there is resistance to change the source code.
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 source code was changed to solve other issues, and so far no-one has shown why this version of the compiler isn't broken and/or emitting false positives (why is only the older version emitting these warnings?). Generally we don't refactor source code to work around warnings from compilers, let alone older compilers. Especially not when it's just in pursuit of using -Werror.
string(STRIP "${CMAKE_CXX_FLAGS}" cxx_flags) | ||
string(STRIP "${CMAKE_CXX_FLAGS_INIT}" cxx_flags_init) | ||
if(cxx_flags STREQUAL cxx_flags_init) |
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.
Non-blocker IMO, just mentioning: with this change it is no longer possible to set your own flags on the command line like cmake -DCMAKE_CXX_FLAGS=-myflag
and have stuff from try_append_cxx_flags()
from inside CMakeLists.txt
appended to them.
To achieve this either one of the following worked for me:
export CXXFLAGS="-myflag"
(and then run cmake
)
or
-DCMAKE_CXX_COMPILER="c++;-myflag"
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.
-DCMAKE_CXX_COMPILER="c++;-myflag"
This is definitely not someting that we would want (or encourage others) to do.
ab1a745
to
ba8a3c3
Compare
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.
ACK ba8a3c3
The sneaked fixups look ok too.
ba8a3c3
to
3abba8b
Compare
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.
ACK 3abba8b
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.
tACK e4ef404
Before (or when with this PR user overrides CMAKE_CXX_FLAGS
):
Common compile options ................ -fno-extended-identifiers -fstack-reuse=none -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
After (when CMAKE_CXX_FLAGS
matches CMAKE_CXX_FLAGS_INIT
-> meant to be set by a toolchain file):
Common compile options ................ -fno-extended-identifiers -fstack-reuse=none -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wno-unused-parameter
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.
ACK e4ef404
Rebased on top of the bitcoin#29577 after the latest syncing. It made |
The core_base_interface does not have C++-specific compiler options.
Add more `-DWERROR=ON`.
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.
ACK 695a5ca
Sorry for not presenting the third commit as fixup ones ready to be auto-squashed.