Skip to content

ci, iwyu: Fix warnings in src/util and treat them as errors#34448

Draft
hebasto wants to merge 3 commits intobitcoin:masterfrom
hebasto:260129-iwyu-util
Draft

ci, iwyu: Fix warnings in src/util and treat them as errors#34448
hebasto wants to merge 3 commits intobitcoin:masterfrom
hebasto:260129-iwyu-util

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Jan 29, 2026

This PR continues the ongoing effort to enforce IWYU warnings.

See Developer Notes.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 29, 2026

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

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:

  • #34641 (node: scale default -dbcache with system RAM by l0rinc)
  • #34639 (iwyu: Document or remove some pragma: export and other improvements by hebasto)
  • #34598 (bench: use deterministic HexStr payload by l0rinc)
  • #34435 (refactor: use _MiB/_GiB consistently for byte conversions by l0rinc)
  • #32554 (bench: replace embedded raw block with configurable block generator by l0rinc)

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.

@hebasto hebasto marked this pull request as draft January 29, 2026 15:41
@fanquake
Copy link
Member

In file included from /home/admin/actions-runner/_work/_temp/src/hash.h:16:
/home/admin/actions-runner/_work/_temp/src/uint256.h:150:17: error: no member named 'HexDigit' in the global namespace
  150 |         *p1 = ::HexDigit(str[--digits]);
      |                 ^~~~~~~~
/home/admin/actions-runner/_work/_temp/src/uint256.h:152:38: error: no member named 'HexDigit' in the global namespace
  152 |             *p1 |= ((unsigned char)::HexDigit(str[--digits]) << 4);
      |                                      ^~~~~~~~
2 errors generated.

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Task Valgrind, fuzz: https://github.com/bitcoin/bitcoin/actions/runs/21484505843/job/61889746047
LLM reason (✨ experimental): Compilation failed due to missing #include causing std::vector to be undefined in string.h and related code.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@fanquake
Copy link
Member

Seems pretty odd that IWYU can be "passing" here, but nothing actually compiles.

achow101 added a commit that referenced this pull request Jan 30, 2026
…ETE_FLAG`

516be10 wallet: Rename `RecordType::DELETE` to `RecordType::DELETE_FLAG` (Hennadii Stepanov)

Pull request description:

  On Windows, the `winnt.h` header defines `DELETE` as a macro for a "Standard Access Right" bitmask (0x00010000L).

  This introduces a fragile dependency on header inclusion order: if Windows headers happen to be included before the `RecordType` enum definition, the preprocessor expands `DELETE` into a numeric literal, causing syntax errors.

  Rename the enumerator to `DELETE_FLAG` to remove this fragility and avoid the collision entirely.

  Split from #34448.

ACKs for top commit:
  maflcko:
    re-lgtm ACK 516be10
  achow101:
    ACK 516be10

Tree-SHA512: eba054b395e18c07efb2901b28f542b042b62d85e1a798eeff35f8431530cb667fa791c47c4125cecdb689213b458ba396715495415e9b83bb322509a9376222
@hebasto
Copy link
Member Author

hebasto commented Jan 30, 2026

Rebased on top of merged #34454.

@hebasto
Copy link
Member Author

hebasto commented Jan 31, 2026

Rebased on top of merged #34460.

@hebasto
Copy link
Member Author

hebasto commented Feb 10, 2026

Rebased.

@hebasto
Copy link
Member Author

hebasto commented Feb 10, 2026

unrelated, but the clang-format in the ci container seems broken? It removes the newlines. E.g. https://github.com/bitcoin/bitcoin/actions/runs/21830259022/job/62995439943#step:11:1639

Looks like fix_includes.py strips empty lines and clang-format-diff.py fails to restore them.

@hebasto
Copy link
Member Author

hebasto commented Feb 10, 2026

unrelated, but the clang-format in the ci container seems broken? It removes the newlines. E.g. https://github.com/bitcoin/bitcoin/actions/runs/21830259022/job/62995439943#step:11:1639

Looks like fix_includes.py strips empty lines and clang-format-diff.py fails to restore them.

Fixed in #34551.

@hebasto
Copy link
Member Author

hebasto commented Feb 10, 2026

The only conflicting PR has been merged, so now seems like a good time to get this reviewed.

Friendly ping @sedited @maflcko @willcl-ark :)

sedited added a commit that referenced this pull request Feb 11, 2026
f8d2f30 ci: Extend diff context for clang-format (Hennadii Stepanov)

Pull request description:

  This PR ensures `clang-format` can properly restore empty lines between header groups that were previously stripped by `fix_includes.py`.

  Addresses [this](#34448 (comment)) comment.

ACKs for top commit:
  maflcko:
    lgtm ACK f8d2f30
  l0rinc:
    untested code review ACK f8d2f30
  sedited:
    ACK f8d2f30

Tree-SHA512: 97e5450fc15e415134aa1e74ee415f947173978d999afbc0f204e1cdb2f68309b763c8a2ad819c4597147fc15540600aa8c99477db64e961ad428d8f45f3d384
@hebasto
Copy link
Member Author

hebasto commented Feb 13, 2026

Rebased.

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Task Windows-cross to x86_64, ucrt: https://github.com/bitcoin/bitcoin/actions/runs/21989888993/job/63533810608
LLM reason (✨ experimental): Test failure: std::future::wait_for is called with a plain long int instead of a std::chrono::duration, causing a type-mismatch in threadpool_tests.cpp.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

On Windows, the `winerror.h` header defines `WAIT_TIMEOUT` as a macro.

This introduces a fragile dependency on header inclusion order: if
Windows headers happen to be included before using `WAIT_TIMEOUT`, the
preprocessor expands it into a numeric literal, causing syntax errors.

Rename the variable to `TEST_WAIT_TIMEOUT` to remove this fragility and
avoid the collision entirely.
@@ -8,6 +8,7 @@

#include <crypto/siphash.h>
#include <logging/categories.h> // IWYU pragma: export
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR is going to fix util, then I think pretty much any (existing) pramga use, outside of the config header, should be getting comments (especially given the prior added one was another IWYU bug). Pragmas should be used sparingly, and explained when so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that all pragmas should eventually be documented. However, addressing the existing ones here would significantly expand the scope of this PR and likely introduce more merge conflicts.

Since these older pragmas might need to be removed entirely rather than just documented, it would be best to loop in the original authors or reviewers to make that call. I think it makes the most sense to tackle this cleanup in follow-up PRs.

Copy link
Member

@fanquake fanquake Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, addressing the existing ones here would significantly expand the scope of this PR

Looking at the current state of this PR, there are 4 instances of // IWYU pragma: export in src/util/. Documenting or removing them, seems in scope for a PR that is fixing all issues in src/util/. If not done now, we'll just have to come back again later and fix them anyways (and still have merge conflicts anyways, if there are any).

Since these older pragmas might need to be removed entirely rather than just documented,
it would be best to loop in the original authors or reviewers to make that call.

Isn't the best case if you can just delete the pragma, and fix the includes? Otherwise I'm not sure what call they would need to make. Either the pragma is removed, and includes fixed, there is a IWYU bug (which can be documented), or a rationale is written for keeping the pragma (even if it isn't needed)?

@hebasto
Copy link
Member Author

hebasto commented Feb 20, 2026

Drafted. Please review #34639 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants