-
Notifications
You must be signed in to change notification settings - Fork 37.7k
lint: Check for missing bitcoin-config.h includes #29408
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
The idea to |
8c2a68d
to
f4db354
Compare
Concept ACK. The linter output matches my list, with the additions of:
The crypto defines actually come from our Makefile. Those have always been wonky, maybe now is a good time to do something about those.
|
Yeah, not sure how to solve this. Maybe rewrite everything as a clang-tidy plugin? |
Concept ACK f4db354. |
51ad354
to
ae00c91
Compare
What's the status on this? Just waiting on a change for the crypto defines? It'd be nice to get it in with/soonafter #29404. |
f45f2bf
to
4856291
Compare
Ok, this (The signed, previous to last commit, fa9c71a) is ready for review. I'll drop the last commit (unsigned merge commit) once and if it is merged. |
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.
Tested 4856291 on Ubuntu 23.10.
Missing #include <config/bitcoin-config.h>
are reported correctly.
What are we supposed to do to automatically avoid redundant / unneeded includes?
Iwyu is a tool to detect redundant and unneeded includes, so it can be used. However, there may be false warnings in regard to this specific header. Thus, an iwyu pragma can be used to avoid incorrect removal of needed includes. Should I push a commit here? |
I assume that both macros I'm pretty sure that the same happens to the I suggest to add |
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.
https://api.cirrus-ci.com/v1/task/5330278671974400/logs/ci.log:
crypto/sha256.cpp should remove these lines:
- #include <config/bitcoin-config.h> // lines 6-6
More // IWYU pragma: keep
?
It's not clear to me what the benefit of using IWYU is here. The missing defines will (by definition) vary per-platform, so I'm not sure what we're chasing here exactly. Or is it more-so just to keep IWYU usable without warnings for our c-i configs specifically? |
Yeah, good point. So I guess the only way to remove unused includes would be to write another check in the linter. I'll drop the last commit and leave everything else for a follow-up. |
9eca5ed
to
fa9c71a
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
Yes. At some point in the future we might want to treat IWYU warnings as errors. |
fa55397
to
fa97cf6
Compare
This is needed for a future change.
This will print a backtrace when an internal code error happened.
Added the check to error on redundant (harmless) includes as well, since it was trivial. Should be trivial to re-ACK. |
fa97cf6
to
fa31908
Compare
Rebased, for silent merge conflict in |
…_ismine.cpp It was included indirectly via src/wallet/test/util.h, however it is better to include what you use.
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.
Weak ACK fa58ae7.
My python-fu is weak, but I think this is a necessary check and it seems to work as advertised.
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 fa58ae7
Added milestone, since this test can catch bugs, and it was reviewed. |
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 fa58ae7, tested on Ubuntu 23.10 -- it catches bugs properly. I didn't review rust code changes.
…tcoin-config.h includes fa09451 Add lint check for bitcoin-config.h include IWYU pragma (MarcoFalke) dddd40b scripted-diff: Add IWYU pragma keep to bitcoin-config.h includes (MarcoFalke) Pull request description: The `bitcoin-config.h` includes have issues: * The header is incompatible with iwyu, because symbols may be defined or not defined. So the `IWYU pragma: keep` is needed to keep the include when a symbol is not defined on a platform. Compare the previous discussion in #29408 (comment) * Guarding the includes by `HAVE_CONFIG_H` is verbose and brittle. Now that all build config dependencies have been removed from low level headers, the benefits are questionable, and the guard can be removed. The linter could also be tricked by guarding the include by `#if defined(HAVE_C0NFIG_H)` (`O` replaced by `0`). Compare the previous discussion in #29404 (comment) . ACKs for top commit: achow101: ACK fa09451 TheCharlatan: ACK fa09451 hebasto: re-ACK fa09451, only rebased since my recent [review](#29494 (review)) (`timedata.cpp` removed in #29623). Tree-SHA512: 47cb973f7f24bc625acc4e78683371863675d186780236d55d886cf4130e05a78bb04f1d731aae7088313b8e963a9677cc77cf518187dbd99d776f6421ca9b52
Missing
bitcoin-config.h
includes are problematic, because the build could silently pass, but produce an unintended result. For example, a slower fallback algorithm could be picked, even thoughbitcoin-config.h
indicates that a faster feature is available and should be used.As the build succeeds silently, this problem is not possible to detect with iwyu.
Thus, fix this by using a linter based on grepping the source code.