ci, iwyu: Treat warnings as errors for specific targets #31308

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:241117-force-iwyu changing 20 files +51 −25
  1. hebasto commented at 9:00 pm on November 17, 2024: member

    This PR is the first step towards treating IWYU warnings as errors. It utilises CMake’s native support via the CMAKE_CXX_INCLUDE_WHAT_YOU_USE) variable. While this approach introduces some duplication at present, it will ultimately enable us to consolidate how the IWYU tool is executed, allowing for a choice between using the iwyu_tool.py script or CMake’s built-in functionality.

    At this stage, only the headers for the bitcoin_crypto target have been updated, and the CI will now treat any future IWYU warnings as errors:

     0...
     1Warning: include-what-you-use reported diagnostics:
     2
     3(/ci_container_base/src/crypto/chacha20.h has correct #includes/fwd-decls)
     4
     5/ci_container_base/src/crypto/chacha20.cpp should add these lines:
     6#include <assert.h>           // for assert
     7
     8/ci_container_base/src/crypto/chacha20.cpp should remove these lines:
     9- #include <string.h>  // lines 15-15
    10
    11The full include-list for /ci_container_base/src/crypto/chacha20.cpp:
    12#include <crypto/chacha20.h>
    13#include <assert.h>           // for assert
    14#include <crypto/common.h>    // for WriteLE32, ReadLE32
    15#include <span.h>             // for Span, UCharCast
    16#include <support/cleanse.h>  // for memory_cleanse
    17#include <algorithm>          // for copy, min
    18#include <bit>                // for rotl
    19---
    20
    21gmake[3]: *** [src/crypto/CMakeFiles/bitcoin_crypto.dir/build.make:90: src/crypto/CMakeFiles/bitcoin_crypto.dir/chacha20.cpp.o] Error 1
    22gmake[3]: *** Waiting for unfinished jobs....
    23gmake[2]: *** [CMakeFiles/Makefile2:1097: src/crypto/CMakeFiles/bitcoin_crypto.dir/all] Error 2
    24gmake[1]: *** [CMakeFiles/Makefile2:1104: src/crypto/CMakeFiles/bitcoin_crypto.dir/rule] Error 2
    25gmake: *** [Makefile:452: bitcoin_crypto] Error 2
    
  2. hebasto added the label Refactoring on Nov 17, 2024
  3. hebasto added the label Tests on Nov 17, 2024
  4. DrahtBot commented at 9:00 pm on November 17, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31308.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #21590 (Safegcd-based modular inverses in MuHash3072 by sipa)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. hebasto force-pushed on Nov 18, 2024
  6. DrahtBot added the label CI failed on Nov 18, 2024
  7. hebasto force-pushed on Nov 25, 2024
  8. hebasto force-pushed on Nov 25, 2024
  9. DrahtBot added the label Needs rebase on Dec 5, 2024
  10. hebasto force-pushed on Dec 5, 2024
  11. hebasto force-pushed on Dec 5, 2024
  12. DrahtBot removed the label Needs rebase on Dec 5, 2024
  13. hebasto marked this as ready for review on Dec 5, 2024
  14. DrahtBot removed the label CI failed on Dec 5, 2024
  15. DrahtBot added the label Needs rebase on Dec 8, 2024
  16. refactor: Fix includes for `libbitcoin_crypto` 6df1a0ce23
  17. ci, iwyu: Treat warnings as errors for specific targets
    Currently, this applies only to the `bitcoin_clientversion` and
    `bitcoin_crypto` targets.
    d838f1bac6
  18. hebasto force-pushed on Dec 12, 2024
  19. hebasto commented at 10:45 am on December 12, 2024: member
    Rebased.
  20. DrahtBot removed the label Needs rebase on Dec 12, 2024
  21. in ci/test/03_test_script.sh:189 in d838f1bac6
    180@@ -180,6 +181,13 @@ if [ "${RUN_TIDY}" = "true" ]; then
    181            -- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
    182            -Xiwyu --max_line_length=160 \
    183            2>&1 | tee /tmp/iwyu_ci.out
    184+
    185+  # TODO: Expand the following list to all targets.
    186+  TARGETS_WITH_FORCED_IWYU="bitcoin_clientversion bitcoin_crypto"
    187+  cd "${BASE_BUILD_DIR}"
    188+  bash -c "cmake -S ${BASE_ROOT_DIR} -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=\"include-what-you-use;-Xiwyu;--cxx17ns;-Xiwyu;--mapping_file=${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp;-Xiwyu;--error\""
    189+  bash -c "cmake --build . ${MAKEJOBS} --clean-first --target ${TARGETS_WITH_FORCED_IWYU}"
    


    maflcko commented at 10:10 pm on December 19, 2024:
    Could make sense to run this before the tee /tmp/iwyu_ci.out command, given that it errors? Or would it be missing (part of) the output? It would be good to see an example CI run. Maybe a -- --keep-going could be used for a slightly better output, if stuff is possibly missing?

    hebasto commented at 10:28 am on January 20, 2025:

    Could make sense to run this before the tee /tmp/iwyu_ci.out command, given that it errors?

    This approach allows a developer to check other includes, not only the first one that fails.

    Maybe a -- --keep-going could be used for a slightly better output, if stuff is possibly missing?

    I’m not sure what criteria you are using to define “better” in this case. The current branch adds one more config/build round details to the CI log and the following:

    1. A message like the one posted in the PR description, if there is a warning.
    2. Nothing, if there are no warnings.

    maflcko commented at 11:00 am on January 20, 2025:

    I think the message you posted in the PR description only shows a single error in a single dependency. I am wondering what happens if there is more than one error in different targets, possibly ones where cmake will never get to print the second error.

    I am asking, because after the cmake migration the behavior of make -k changed. Previously, everything would be attempted to be built. Now, cmake will skip and exit early in some cases.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-01-21 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me