Skip to content

Commit 45b2a91

Browse files
committed
Merge bitcoin#29404: refactor: bitcoin-config.h includes cleanup
9d1dbbd scripted-diff: Fix bitcoin_config_h includes (TheCharlatan) Pull request description: As mentioned in bitcoin#26924 (comment) and bitcoin#29263 (comment), it is currently not safe to remove `bitcoin-config.h` includes from headers because some unrelated file might be depending on it. See also bitcoin#26972 for discussion. Solve this by including the file directly everywhere it's required, regardless of whether or not it's already included by another header. There should be no functional change here, but it will allow us to safely remove includes from headers in the future. ~I'm afraid it's a bit tedious to reproduce these commits, but it's reasonably straightforward:~ Edit: See note below ```bash # All commands executed from the src/ subdir. # Collect all tokens from bitcoin-config.h.in # Isolate the tokens and remove blank lines # Replace newlines with | and remove the last trailing one # Collect all files which use these tokens # Filter out subprojects (proper forwarding can be verified from Makefiles) # Filter out .rc files # Save to a text file git grep -E -l `grep undef config/bitcoin-config.h.in | cut -d" " -f2 | grep -v '^$' | tr '\n' '|' | sed 's/|$//'` | grep -v -e "^leveldb/" -e "^secp256k1/" -e "^crc32c/" -e "^minisketch/" -e "^Makefile" -e "\.rc$" > files-with-config-include.txt # Find all files from the above list which don't include bitcoin-config.h git grep -L -E "config/bitcoin-config.h" -- `cat files-with-config-include.txt` # Include them manually with the exception of some files in crypto: # crypto/sha256_arm_shani.cpp crypto/sha256_avx2.cpp crypto/sha256_sse41.cpp crypto/sha256_x86_shani.cpp # These are exceptions which don't use bitcoin-config.h, rather the Makefile.am adds these cppflags manually. # Commit changes. This should match the first commit of this PR. # Use the same search as above to find all files which DON'T use any config tokens git grep -E -L `grep undef config/bitcoin-config.h.in | cut -d" " -f2 | grep -v '^$' | tr '\n' '|' | sed 's/|$//'` | grep -v -e "^leveldb/" -e "^secp256k1/" -e "^crc32c/" -e "^minisketch/" -e "^Makefile" -e "\.rc$" > files-without-config-include.txt # Manually remove the includes and commit changes. This should match the second commit of this PR. ``` Edit: I'll keep this old description for posterity, but the manual approach has been replaced with a scripted diff from TheCharlatan ACKs for top commit: maflcko: ACK 9d1dbbd 🚪 TheCharlatan: ACK 9d1dbbd hebasto: ACK 9d1dbbd, I have reviewed the code and it looks OK. fanquake: ACK 9d1dbbd Tree-SHA512: f11ddc4ae6a887f96b954a6b77f310558ddb271088a3fda3edc833669c4251b7f392515224bbb8e5f67eb2c799b4ffed3b07d96454e82ec635c686d0df545872
2 parents d301c99 + 9d1dbbd commit 45b2a91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+148
-76
lines changed

src/addrdb.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <addrdb.h>
711

812
#include <addrman.h>

src/addrman.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <addrman.h>
711
#include <addrman_impl.h>
812

src/bench/verify_script.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <bench/bench.h>
610
#include <key.h>
711
#if defined(HAVE_CONSENSUS_LIB)

src/bench/wallet_create.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <bench/bench.h>
610
#include <node/context.h>
711
#include <random.h>

src/bench/wallet_loading.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <bench/bench.h>
610
#include <interfaces/chain.h>
711
#include <node/context.h>

src/clientversion.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <clientversion.h>
610
#include <util/translation.h>
711

src/common/system.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <common/system.h>
711

812
#include <logging.h>

src/compat/compat.h

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#ifndef BITCOIN_COMPAT_COMPAT_H
77
#define BITCOIN_COMPAT_COMPAT_H
88

9-
#if defined(HAVE_CONFIG_H)
10-
#include <config/bitcoin-config.h>
11-
#endif
12-
139
// Windows defines FD_SETSIZE to 64 (see _fd_types.h in mingw-w64),
1410
// which is too small for our usage, but allows us to redefine it safely.
1511
// We redefine it to be 1024, to match glibc, see typesizes.h.

src/crypto/chacha20poly1305.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <crypto/chacha20poly1305.h>
610

711
#include <crypto/common.h>

src/crypto/muhash.h

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifndef BITCOIN_CRYPTO_MUHASH_H
66
#define BITCOIN_CRYPTO_MUHASH_H
77

8-
#if defined(HAVE_CONFIG_H)
9-
#include <config/bitcoin-config.h>
10-
#endif
11-
128
#include <serialize.h>
139
#include <uint256.h>
1410

src/crypto/sha256.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <crypto/sha256.h>
610
#include <crypto/common.h>
711

src/netaddress.h

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifndef BITCOIN_NETADDRESS_H
66
#define BITCOIN_NETADDRESS_H
77

8-
#if defined(HAVE_CONFIG_H)
9-
#include <config/bitcoin-config.h>
10-
#endif
11-
128
#include <compat/compat.h>
139
#include <crypto/siphash.h>
1410
#include <prevector.h>

src/netbase.h

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifndef BITCOIN_NETBASE_H
66
#define BITCOIN_NETBASE_H
77

8-
#if defined(HAVE_CONFIG_H)
9-
#include <config/bitcoin-config.h>
10-
#endif
11-
128
#include <compat/compat.h>
139
#include <netaddress.h>
1410
#include <serialize.h>

src/qt/addressbookpage.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#if defined(HAVE_CONFIG_H)
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/addressbookpage.h>
106
#include <qt/forms/ui_addressbookpage.h>
117

src/qt/askpassphrasedialog.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#if defined(HAVE_CONFIG_H)
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/askpassphrasedialog.h>
106
#include <qt/forms/ui_askpassphrasedialog.h>
117

src/qt/bitcoingui.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/bitcoingui.h>
610

711
#include <qt/bitcoinunits.h>

src/qt/clientmodel.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/clientmodel.h>
610

711
#include <qt/bantablemodel.h>

src/qt/coincontroldialog.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#if defined(HAVE_CONFIG_H)
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/coincontroldialog.h>
106
#include <qt/forms/ui_coincontroldialog.h>
117

src/qt/guiutil.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/guiutil.h>
610

711
#include <qt/bitcoinaddressvalidator.h>

src/qt/modaloverlay.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/modaloverlay.h>
610
#include <qt/forms/ui_modaloverlay.h>
711

src/qt/notificator.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/notificator.h>
610

711
#include <QApplication>

src/qt/paymentserver.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#if defined(HAVE_CONFIG_H)
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/paymentserver.h>
106

117
#include <qt/bitcoinunits.h>

src/qt/paymentserver.h

-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
// sends them to the server.
3333
//
3434

35-
#if defined(HAVE_CONFIG_H)
36-
#include <config/bitcoin-config.h>
37-
#endif
38-
3935
#include <qt/sendcoinsrecipient.h>
4036

4137
#include <QObject>

src/qt/sendcoinsentry.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#if defined(HAVE_CONFIG_H)
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/sendcoinsentry.h>
106
#include <qt/forms/ui_sendcoinsentry.h>
117

src/qt/sendcoinsrecipient.h

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifndef BITCOIN_QT_SENDCOINSRECIPIENT_H
66
#define BITCOIN_QT_SENDCOINSRECIPIENT_H
77

8-
#if defined(HAVE_CONFIG_H)
9-
#include <config/bitcoin-config.h>
10-
#endif
11-
128
#include <consensus/amount.h>
139
#include <serialize.h>
1410

src/qt/test/apptests.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#include <test/util/setup_common.h>
1515
#include <validation.h>
1616

17-
#if defined(HAVE_CONFIG_H)
18-
#include <config/bitcoin-config.h>
19-
#endif
20-
2117
#include <QAction>
2218
#include <QLineEdit>
2319
#include <QRegularExpression>

src/qt/test/optiontests.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <common/args.h>
610
#include <init.h>
711
#include <qt/bitcoin.h>

src/qt/transactiondesc.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#ifdef HAVE_CONFIG_H
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/transactiondesc.h>
106

117
#include <qt/bitcoinunits.h>

src/qt/walletmodel.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#if defined(HAVE_CONFIG_H)
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/walletmodel.h>
106

117
#include <qt/addresstablemodel.h>

src/qt/walletmodel.h

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifndef BITCOIN_QT_WALLETMODEL_H
66
#define BITCOIN_QT_WALLETMODEL_H
77

8-
#if defined(HAVE_CONFIG_H)
9-
#include <config/bitcoin-config.h>
10-
#endif
11-
128
#include <key.h>
139

1410
#include <qt/walletmodeltransaction.h>

src/qt/walletmodeltransaction.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#ifdef HAVE_CONFIG_H
6-
#include <config/bitcoin-config.h>
7-
#endif
8-
95
#include <qt/walletmodeltransaction.h>
106

117
#include <policy/policy.h>

src/random.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <random.h>
711

812
#include <compat/compat.h>

src/rest.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <rest.h>
711

812
#include <blockfilter.h>

src/rpc/external_signer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <common/args.h>
610
#include <common/system.h>
711
#include <external_signer.h>

src/rpc/mining.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <chain.h>
711
#include <chainparams.h>
812
#include <common/system.h>

src/rpc/node.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6+
#if defined(HAVE_CONFIG_H)
7+
#include <config/bitcoin-config.h>
8+
#endif
9+
610
#include <chainparams.h>
711
#include <httpserver.h>
812
#include <index/blockfilterindex.h>

0 commit comments

Comments
 (0)