WIP: cmake: Remove optional definitions from bitcoin-build-config.h

bitcoin/bitcoin: PR #35072

1 major finding · 2 minor findings · 2 suggestions

Findings

Link

[major] · bitcoinqt compiles out external-signer configuration

With BUILD_GUI=ON and wallet and signer support enabled, the GUI disables signer-path configuration even though external signing still works when configured outside the GUI.

Location: src/CMakeLists.txt:149 (head).

Details and suggested fix

ENABLE_EXTERNAL_SIGNER now comes only from bitcoin_common. Its PRIVATE static-library link through bitcoin_wallet forwards link dependencies, not compile definitions, and bitcoin_cli provides no alternate path into bitcoinqt. The generated header previously supplied the macro. Consequently, OptionsDialog disables externalSignerPath and displays the false “Compiled without external signing support” tooltip. CreateWalletDialog also selects its unsupported constructor branch and omits the encryption-handler checkbox update. Backend enumeration remains enabled: supplying -signer in bitcoin.conf or on the command line still lets setSigners() enable wallet creation when a signer is found. Link bitcoin_common directly and PRIVATE to bitcoinqt so these sources receive the definition without restoring it to the shared header.


Link

[minor] · run_command coverage disappears in signer-enabled unit tests

With BUILD_TESTS=ON and ENABLE_EXTERNAL_SIGNER=ON, test_bitcoin silently omits system_tests/run_command, and test_util omits enumeratesigners registration.

Location: src/test/system_tests.cpp:6 (base).

Details and suggested fix

bitcoin_node and bitcoin_wallet consume bitcoin_common privately, so linking them does not give test_bitcoin its new signer definition; test_util also lacks a definition path. Removing the configuration-header includes therefore preprocesses out the subprocess test, including its exit-code, stderr, JSON and stdin assertions. CTest discovers system_tests from source and treats “no test cases matching filter” as a skip. The same missing macro removes signer registration from the static-inline RegisterAllCoreRPCCommands() call in TestingSetup, unlike production initialization in bitcoin_node. No current unit test calls enumeratesigners, so that second effect is fixture drift rather than an observed test failure. Link bitcoin_common directly to both targets, then verify that system_tests/run_command remains registered.


Link

[minor] · Moved feature macros lose the missing-definition safeguard

The move removes the five feature macros from lint_includes_build_config, leaving missing target definitions indistinguishable from intentionally disabled features.

Location: cmake/bitcoin-build-config.h.in:33 (base).

Details and suggested fix

lint_includes_build_config derives its symbol list from bitcoin-build-config.h.in, so it no longer checks uses of these five macros after their removal. Their #ifdef guards accept an accidentally missing usage requirement, as the signer consumers here demonstrate. Give consumer targets explicit 0/1 values and convert the associated guards to value-based #if checks, including negated checks. This lets the existing -Wundef flag catch missing definitions on supporting non-MSVC compilers, with CI treating the warning as an error, while preserving disabled-feature behavior and target-scoped rebuilds. This diagnostic does not cover MSVC.


Optional improvements

Link

[suggestion] · Receive-request GUI test misses compiled-out QR support

The receive-request GUI test would still pass if the new USE_QRCODE target definition disappeared, although head currently supplies it correctly.

Location: src/qt/receiverequestdialog.cpp:17 (base).

Details and suggested fix

The wallet test opens ReceiveRequestDialog with a receiving address, label, amount and message, but checks only text and request persistence. Without USE_QRCODE, setInfo() hides qr_code and btnSaveAs while populating the same asserted text. In that block, check for a non-null QR pixmap and a visible save button when QR support is expected. Supply that expectation independently on test_bitcoin-qt from WITH_QRENCODE, rather than guarding the assertion with the production macro, so the check cannot disappear with the feature. The existing fixture needs no additional wallet or chain setup.


Link

[suggestion] · Walletless GUI builds still require unused QRencode by default

The pre-existing default QRencode discovery still requires an unused dependency for walletless GUI builds, despite this PR making its linkage wallet-only.

Location: src/qt/CMakeLists.txt:228 (head).

Details and suggested fix

WITH_QRENCODE depends only on BUILD_GUI, so BUILD_GUI=ON with ENABLE_WALLET=OFF still leaves it on by default and executes required QRencode discovery. Yet both consuming sources and the new link and definition are inside if(ENABLE_WALLET). Add ENABLE_WALLET to the dependent option's condition, such as "BUILD_GUI;ENABLE_WALLET", so walletless GUI builds do not need the QRencode development files. Wallet-enabled builds retain QR support by default and the explicit opt-out.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

A separate historical motivation for GUI/non-GUI builds was fully static non-GUI binaries. Wladimir van der Laan explained that the GUI needed access to the dynamic linker and that different compiler/linker flags could therefore require separate builds. Fanquake's subsequent outline also anticipated rebuilding depends after changing environments and adapting binary-security and symbol checks.

The affected build behavior sits between two different workflows: toggling GUI support without changing the common compilation environment, and deliberately building GUI and non-GUI artifacts with different environments or flags. Historical support for separation does not imply that shared objects can always be reused across the latter workflow.

Source 1 · Source 2