elements/src/util
merge-script ede388d03d
Merge bitcoin/bitcoin#30911: build: simplify by flattening the dependency graph
12fa9511b5 build: simplify dependency graph (Cory Fields)
c4e498300c build: avoid unnecessary dependencies on generated headers (Cory Fields)

Pull request description:

  These changes speed up my build (default config/options/targets) by roughly 10%. I suspect the difference may be more significant in other build configs.

  Before:
  > $ time cmake --build build -j24
  > real3m26.932s

  After:
  > $ time cmake --build build -j24
  > real3m7.556s

  Generally they allow for jobservers (either `make -jX` or `ninja`) to be better utilized. This can be verified using `top` while building and looking at the number of compiles running at any given time before/after these changes. Before, it's easy to observe periods of stalling when only one or two compiles are happening. After these changes, the compiler process count should mostly match the number of jobs given (`-jX`) until it falls off at the end.

  ---

  The first commit sets [DEPENDS_EXPLICIT_ONLY](https://cmake.org/cmake/help/latest/command/add_custom_command.html#command:add_custom_command) for commands which generate our test header files. Without this option, `test_bitcoin`'s generated headers won't be built until all of its other dependencies have been built. This introduces a significant stall in the build, though currently only Ninja benefits from this being set, and only CMake >= 3.27 understands it.

  Example from a generated `build.ninja`:

  Before:

  > \# Custom command for src/test/data/base58_encode_decode.json.h
  >
  > build src/test/data/base58_encode_decode.json.h | ${cmake_ninja_workdir}src/test/data/base58_encode_decode.json.h: CUSTOM_COMMAND /home/cory/dev/bitcoin/src/test/data/base58_encode_decode.json /home/cory/dev/bitcoin/cmake/script/GenerateHeaderFromJson.cmake || libcrc32c.a libcrc32c_sse42.a libleveldb.a libminisketch.a minisketch_clmul src/bitcoin_clientversion src/crypto/libbitcoin_crypto.a src/crypto/libbitcoin_crypto_avx2.a src/crypto/libbitcoin_crypto_sse41.a src/crypto/libbitcoin_crypto_x86_shani.a src/generate_build_info src/libbitcoin_cli.a src/libbitcoin_common.a src/libbitcoin_consensus.a src/libbitcoin_node.a src/secp256k1/src/libsecp256k1.a src/secp256k1/src/secp256k1_precomputed src/test/util/libtest_util.a src/univalue/libunivalue.a src/util/libbitcoin_util.a src/wallet/libbitcoin_wallet.a src/zmq/libbitcoin_zmq.a

  After:

  > \# Custom command for src/test/data/base58_encode_decode.json.h
  >
  > build src/test/data/base58_encode_decode.json.h | ${cmake_ninja_workdir}src/test/data/base58_encode_decode.json.h: CUSTOM_COMMAND /home/cory/dev/bitcoin/src/test/data/base58_encode_decode.json /home/cory/dev/bitcoin/cmake/script/GenerateHeaderFromJson.cmake

  ---

  The second commit is more significant. It sets [CMAKE_OPTIMIZE_DEPENDENCIES](https://cmake.org/cmake/help/latest/prop_tgt/OPTIMIZE_DEPENDENCIES.html) globally, which allows the objects of static libs to be built in parallel when one lib depends on the other. This can be set as a per-lib property, ~but I don't see any need for that as we don't currently have any edge-cases where this wouldn't be ok. If those should arise, we could always disable on a per-lib basis~.

  Edit: turns out this triggers an [upstream bug](https://gitlab.kitware.com/cmake/cmake/-/issues/24058), which I guess can be considered an edge-case until fixed in CMake. I've added 2 per-lib opt-outs as a result.

  Example:

  Before:

  > \# Link the static library src/libbitcoin_cli.a
  >
  > build src/libbitcoin_cli.a: CXX_STATIC_LIBRARY_LINKER__bitcoin_cli_RelWithDebInfo src/CMakeFiles/bitcoin_cli.dir/compat/stdin.cpp.o src/CMakeFiles/bitcoin_cli.dir/rpc/client.cpp.o || src/univalue/libunivalue.a

  After:

  > \# Link the static library src/libbitcoin_cli.a
  >
  > build src/libbitcoin_cli.a: CXX_STATIC_LIBRARY_LINKER__bitcoin_cli_RelWithDebInfo src/CMakeFiles/bitcoin_cli.dir/compat/stdin.cpp.o src/CMakeFiles/bitcoin_cli.dir/rpc/client.cpp.o
  >

ACKs for top commit:
  l0rinc:
    utACK 12fa9511b5
  hebasto:
    ACK 12fa9511b5.

Tree-SHA512: f85f507e70cdc06acd07542161d9f9b8edf9ba866f08c8ef17aaaed770fa11530a27521c4413456d863463a6e77d4d6983fa623a64e17bbd602c2bc70aacc112
2025-02-12 16:02:57 +01:00
..
any.h refactor: Split util::AnyPtr into its own file 2023-05-20 12:03:33 +02:00
asmap.cpp streams: cache file position within AutoFile 2024-09-13 07:35:41 -04:00
asmap.h
batchpriority.cpp refactor: Move ScheduleBatchPriority to its own file 2023-05-20 12:03:30 +02:00
batchpriority.h refactor: Move ScheduleBatchPriority to its own file 2023-05-20 12:03:30 +02:00
bip32.cpp Merge bitcoin/bitcoin#26076: Switch hardened derivation marker to h 2023-05-08 13:31:28 -04:00
bip32.h
bitdeque.h refactor: Fix "error C2248: cannot access private member" on MSVC 2024-04-28 07:11:24 +01:00
bitset.h util: use explicit cast in MultiIntBitSet::Fill() 2024-12-05 16:55:36 +01:00
byte_units.h util: fix compiler warning about deprecated space before _MiB 2025-01-20 14:32:20 +01:00
bytevectorhash.cpp random: get rid of GetRand by inlining 2024-07-01 12:39:53 -04:00
bytevectorhash.h
chaintype.cpp testnet: Introduce Testnet4 2024-08-06 01:38:10 +02:00
chaintype.h testnet: Introduce Testnet4 2024-08-06 01:38:10 +02:00
check.cpp Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to execute a fuzz target 2024-10-31 13:51:37 +01:00
check.h Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to execute a fuzz target 2024-10-31 13:51:37 +01:00
CMakeLists.txt build: simplify dependency graph 2025-01-31 15:07:44 +00:00
epochguard.h
exception.cpp
exception.h
fastrange.h
feefrac.cpp Avoid explicitly computing diagram; compare based on chunks 2024-04-22 09:36:36 -04:00
feefrac.h clusterlin: add DepGraph::RemoveTransactions and support for holes in DepGraph 2024-10-07 13:49:35 -04:00
fs.cpp Add tests for C++20 std::u8string 2023-12-11 17:42:05 +01:00
fs.h refactor: Rename fs::path::u8string() to fs::path::utf8string() 2023-12-14 16:22:40 +01:00
fs_helpers.cpp build: Replace MAC_OSX macro with existing __APPLE__ 2024-10-24 12:29:26 +02:00
fs_helpers.h util: add perm string helper functions 2024-06-27 14:55:10 +01:00
golombrice.h
hash_type.h
hasher.cpp random: get rid of GetRand by inlining 2024-07-01 12:39:53 -04:00
hasher.h refactor: Replace fwd-decl with proper include 2024-12-19 13:46:43 +01:00
insert.h refactor: Split util::insert into its own file 2023-05-20 12:03:31 +02:00
macros.h
moneystr.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
moneystr.h
overflow.h util: Add integer left shift helpers 2025-01-15 15:43:05 +01:00
overloaded.h doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
rbf.cpp
rbf.h
readwritefile.cpp
readwritefile.h
result.h refactor: Avoid copying util::Result values 2024-04-25 16:08:24 -04:00
serfloat.cpp
serfloat.h
signalinterrupt.cpp util: Get rid of uncaught exceptions thrown by SignalInterrupt class 2023-12-04 15:39:15 -04:00
signalinterrupt.h util: Get rid of uncaught exceptions thrown by SignalInterrupt class 2023-12-04 15:39:15 -04:00
sock.cpp sock: change Sock::SendComplete() to take Span 2023-10-31 18:19:22 +01:00
sock.h sock: change Sock::SendComplete() to take Span 2023-10-31 18:19:22 +01:00
strencodings.cpp util: remove unused IsHexNumber 2024-08-23 13:53:40 +01:00
strencodings.h move-only: Detail_CheckNumFormatSpecifiers and G_TRANSLATION_FUN 2024-11-15 17:16:27 +01:00
string.cpp util: Move util/string.h functions to util namespace 2024-05-16 10:16:08 -05:00
string.h move-only: Detail_CheckNumFormatSpecifiers and G_TRANSLATION_FUN 2024-11-15 17:16:27 +01:00
subprocess.h tidy: modernize-use-equals-default 2024-07-08 11:12:01 +02:00
syserror.cpp scripted-diff: drop config/ subdir for bitcoin-config.h, rename to bitcoin-build-config.h 2024-10-10 12:22:12 +02:00
syserror.h Show descriptive error messages when FileCommit fails 2023-06-30 09:48:21 -04:00
task_runner.h tidy: modernize-use-equals-default 2024-07-08 11:12:01 +02:00
thread.cpp
thread.h
threadinterrupt.cpp
threadinterrupt.h util: Add SignalInterrupt class and use in shutdown.cpp 2023-06-28 09:49:28 +02:00
threadnames.cpp build: Replace MAC_OSX macro with existing __APPLE__ 2024-10-24 12:29:26 +02:00
threadnames.h util: avoid using thread_local variable that has a destructor 2024-05-16 18:16:46 +02:00
time.cpp util: Add mockable steady_clock 2025-01-13 21:53:56 +01:00
time.h util: Add mockable steady_clock 2025-01-13 21:53:56 +01:00
tokenpipe.cpp scripted-diff: drop config/ subdir for bitcoin-config.h, rename to bitcoin-build-config.h 2024-10-10 12:22:12 +02:00
tokenpipe.h
trace.h tracing: only prepare tracepoint args if attached 2024-10-28 14:27:47 +01:00
transaction_identifier.h refactor: remove TxidFromString 2024-07-31 16:47:39 +01:00
translation.h refactor: Introduce struct to hold a runtime format string 2025-01-15 12:16:08 +01:00
types.h doc: Clarify C++20 comments 2024-01-05 11:22:31 +01:00
ui_change_type.h
vecdeque.h utils: add missing include 2024-06-11 16:28:11 +00:00
vector.h chainparams: add blockhash to AssumeutxoData 2023-09-30 06:38:47 -04:00