1 suggestion
Optional improvements
[suggestion] · Header-wide IWYU retention lacks its configuration rationale
The build-config header's blanket IWYU exception is now unexplained, although the separate lint still checks missing and redundant includes.
Location: cmake/bitcoin-build-config.h.in:5 (head).
Details and suggested fix
This PR removes the lint message explaining that IWYU can incorrectly suggest removing these includes, but leaves only a bare always_keep pragma in the template. Configuration symbols can be absent depending on the platform and build options, so IWYU's view of one configuration cannot reliably establish that an include is unnecessary. Add a nearby comment explaining this and pointing to lint_includes_build_config as the check for missing and redundant includes, consistent with the preference in doc/developer-notes.md:559. This documents the tooling exception without restoring per-include annotations or changing the current include set.
Avoid lowercase define, including in defined or undefined, in that comment: the lint greps the template for that substring and treats each matching line's second whitespace token as a symbol name.
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
Explicit configuration-header includes protect against silent changes in compiled behavior, not merely compilation failures.
The original lint proposal explains that missing configuration macros can select a slower fallback while the build still succeeds. Both pinned versions retain the corresponding warning and require direct includes in files using configuration symbols. The unchanged HAVE_POSIX_FALLOCATE branch and fallback in src/util/fs_helpers.cpp illustrate why successful compilation alone cannot establish that the intended feature was selected.
Configuration-header retention was introduced because IWYU's view of one platform cannot reliably represent dependencies on macros that are undefined there.
The #29494 proposal explicitly says that configuration symbols may be defined or undefined depending on the platform, making retention annotations necessary. Earlier discussion likewise questioned using IWYU for definitions that vary across platforms. This explains the per-include keep annotations at the pinned base: an apparently unused header can still be a source-level dependency needed under another configuration.
Source 1 · Source 2 · Source 3
Protecting configuration includes from IWYU was deliberately paired with a separate source-based check for genuinely redundant includes.
Historical participants raised the concern that keep annotations prevent IWYU from reporting an include that becomes unnecessary. The author identified the dedicated build-config lint as responsible for that check; #29408 also explicitly added rejection of redundant, described as harmless, includes. Both pinned versions preserve this two-sided lint: require the header where configuration symbols appear and flag it where they do not. Header retention therefore does not express a policy of including the header everywhere.
Source 1 · Source 2 · Source 3 · Source 4
Centralizing the retention instruction in the configuration header has an explicit historical precedent: avoid repeating a keep annotation at every include site.
The earlier #34127 proposal states precisely this motivation for always_keep. The pinned head places that instruction in cmake/bitcoin-build-config.h.in, removes the repeated include-site comments, and updates the lint's required include spelling. The historical rationale concerns where the tooling exception is expressed, rather than changing which configured features consumers use.
Ralph's inferences
The relevant defensive assumption is fallible maintenance and configuration-specific tooling visibility, rather than a new peer-adversary or consensus threat model.
The inspected sources discuss silently selected fallbacks, platform-dependent definitions, and incorrect automated include removal. Together with the pinned lint and annotation changes, this indicates a build-maintenance safeguard: preserve explicit configuration dependencies despite what a particular analysis environment observes. These sources do not establish a separate protocol or economic rationale for the annotation policy.