cmake: Add compiler diagnostic flags#84
Conversation
131db28 to
d9d0ce7
Compare
ff2f574 to
dacc6f7
Compare
d9d0ce7 to
9d64cb6
Compare
|
Rebased. |
9d64cb6 to
92291c0
Compare
| $<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.
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.
This isn't in the master branch?
bitcoin#29362 has been submitted to the master branch.
|
|
||
| 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.
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.
| ) | ||
| try_append_cxx_flags("-Wself-assign" TARGET warn_interface | ||
| IF_CHECK_PASSED "-Wno-self-assign" | ||
| ) |
There was a problem hiding this comment.
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. |
| # 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.
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.
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.
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.
-DCMAKE_CXX_COMPILER="c++;-myflag"
This is definitely not someting that we would want (or encourage others) to do.
ab1a745 to
ba8a3c3
Compare
ba8a3c3 to
3abba8b
Compare
pablomartin4btc
left a comment
There was a problem hiding this comment.
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
|
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`.
c40dbbb test: Move `script_assets_tests` into its own suite (Hennadii Stepanov) Pull request description: This PR ensures that the `script_assets_tests` test case is explicitly reported as "Skipped" when it is not run, making it clearer when running the test suite with `ctest`: - on the master branch @ 9355578: ``` $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_" Internal ctest changing into directory: /home/hebasto/git/bitcoin/build Test project /home/hebasto/git/bitcoin/build Start 87: script_tests Start 83: script_p2sh_tests Start 85: script_segwit_tests Start 86: script_standard_tests Start 84: script_parse_tests 1/5 Test #84: script_parse_tests ............... Passed 0.11 sec 2/5 Test #86: script_standard_tests ............ Passed 0.11 sec 3/5 Test #85: script_segwit_tests .............. Passed 0.12 sec 4/5 Test #83: script_p2sh_tests ................ Passed 0.12 sec 5/5 Test #87: script_tests ..................... Passed 0.36 sec 100% tests passed, 0 tests failed out of 5 Total Test time (real) = 0.37 sec ``` - with this PR: ``` $ env -u DIR_UNIT_TEST_DATA ctest --test-dir build -j 16 -R "^script_" Internal ctest changing into directory: /home/hebasto/git/bitcoin/build Test project /home/hebasto/git/bitcoin/build Start 83: script_assets_tests Start 88: script_tests Start 84: script_p2sh_tests Start 86: script_segwit_tests Start 87: script_standard_tests Start 85: script_parse_tests 1/6 Test #85: script_parse_tests ............... Passed 0.11 sec 2/6 Test #83: script_assets_tests ..............***Skipped 0.12 sec 3/6 Test #86: script_segwit_tests .............. Passed 0.11 sec 4/6 Test #87: script_standard_tests ............ Passed 0.11 sec 5/6 Test #84: script_p2sh_tests ................ Passed 0.12 sec 6/6 Test #88: script_tests ..................... Passed 0.36 sec 100% tests passed, 0 tests failed out of 6 Total Test time (real) = 0.37 sec The following tests did not run: 83 - script_assets_tests (Skipped) $ env DIR_UNIT_TEST_DATA=/home/hebasto/git/bitcoin/qa-assets/unit_test_data ctest --test-dir build -j 16 -R "^script_" Internal ctest changing into directory: /home/hebasto/git/bitcoin/build Test project /home/hebasto/git/bitcoin/build Start 83: script_assets_tests Start 88: script_tests Start 84: script_p2sh_tests Start 86: script_segwit_tests Start 87: script_standard_tests Start 85: script_parse_tests 1/6 Test #85: script_parse_tests ............... Passed 0.11 sec 2/6 Test #87: script_standard_tests ............ Passed 0.11 sec 3/6 Test #86: script_segwit_tests .............. Passed 0.11 sec 4/6 Test #84: script_p2sh_tests ................ Passed 0.12 sec 5/6 Test #88: script_tests ..................... Passed 0.35 sec 6/6 Test #83: script_assets_tests .............. Passed 1.58 sec 100% tests passed, 0 tests failed out of 6 Total Test time (real) = 1.58 sec ``` ACKs for top commit: maflcko: re-ACK c40dbbb 👈 ajtowns: ACK c40dbbb achow101: ACK c40dbbb Tree-SHA512: 25713e1c3b507b6f2a5fecc7b1ea285a6642b906c248769238a58fc0df48489ac5f7606778f9e3653b407b7f1d06563e1554d04321303b350c80eb888500cc5d
Sorry for not presenting the third commit as fixup ones ready to be auto-squashed.