Merge bitcoin/bitcoin#31161: cmake: Set top-level target output locations

568fcdddae scripted-diff: Adjust documentation per top-level target output location (Hennadii Stepanov)
026bb226e9 cmake: Set top-level target output locations (Hennadii Stepanov)

Pull request description:

  This PR sets the target output locations to the `bin` and `lib` subdirectories within the build tree, creating a directory structure that mirrors that of the installed targets.

  This approach is widely adopted by the large projects, such as [LLVM](https://github.com/llvm/llvm-project/blob/e146c1867e8decfd423034f63a3a863733e03f04/lldb/cmake/modules/LLDBStandalone.cmake#L128-L130):
  ```cmake
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
  ```

  The `libsecp256k1` project has also recently [adopted](https://github.com/bitcoin-core/secp256k1/pull/1553) this approach.

  With this PR, all binaries are conveniently located. For example, run:
  ```
  $ ./build/bin/fuzz
  ```
  instead of:
  ```
  $ ./build/src/test/fuzz/fuzz
  ```

  On Windows, all required DLLs are now located in the same directory as the executables, allowing to run `bitcoin-chainstate.exe` (which loads `bitcoinkernel.dll`) without the need to copy DLLs or modify the `PATH` variable.

  The idea was briefly discussed among the build team during the recent CoreDev meeting.

  ---

  **Warning**: This PR changes build locations of newly built executables like `bitcoind` and `test_bitcoin` from `src/` to `bin/` without deleting previously built executables. A clean build is recommended to avoid accidentally running old binaries.

ACKs for top commit:
  theStack:
    Light re-ACK 568fcdddae
  ryanofsky:
    Code review ACK 568fcdddae. Only change since last review was rebasing. I'm ok with this PR in its current form if other developers are happy with it. I just personally think it is inappropriate to \*silently\* break an everyday developer workflow like `git pull; make bitcoind`. I wouldn't have a problem with this PR if it triggered an explicit error, or if the problem was limited to less common workflows like changing cmake options in an existing build.
  TheCharlatan:
    Re-ACK 568fcdddae
  theuni:
    ACK 568fcdddae

Tree-SHA512: 1aa5ecd3cd49bd82f1dcc96c8e171d2d19c58aec8dade4bc329df89311f9e50cbf6cf021d004c58a0e1016c375b0fa348ccd52761bcdd179c2d1e61c105e3b9f
This commit is contained in:
merge-script committed 2025-03-12 11:19:00 +08:00
commit 502d47203e
27 files changed
+164 -145

No files matched your search

+1 -1
View File
@@ -188,7 +188,7 @@ In a different terminal, starting Bitcoin Core in SigNet mode and with
re-indexing enabled.
```
$ ./build/src/bitcoind -signet -reindex
$ ./build/bin/bitcoind -signet -reindex
```
This produces the following output.
+3 -3
View File
@@ -16,7 +16,7 @@
This script requires a 'bitcoind' binary compiled with eBPF support and the
'validation:block_connected' USDT. By default, it's assumed that 'bitcoind' is
located in './build/src/bitcoind'. This can be modified in the script below.
located in './build/bin/bitcoind'. This can be modified in the script below.
EXAMPLES:
@@ -67,7 +67,7 @@ BEGIN
connected block is between the start and end height (or the end height is
unset).
*/
usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
usdt:./build/bin/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
{
$height = arg1;
$transactions = arg2;
@@ -102,7 +102,7 @@ usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2
blocks where the time it took to connect the block is above the
<logging threshold in ms>.
*/
usdt:./build/src/bitcoind:validation:block_connected / (uint64) arg5 / 1e6 > $3 /
usdt:./build/bin/bitcoind:validation:block_connected / (uint64) arg5 / 1e6 > $3 /
{
$hash = arg0;
$height = (int32) arg1;
+5 -5
View File
@@ -5,7 +5,7 @@ BEGIN
printf("Logging opened, closed, misbehaving, and evicted P2P connections\n")
}
usdt:./build/src/bitcoind:net:inbound_connection
usdt:./build/bin/bitcoind:net:inbound_connection
{
$id = (int64) arg0;
$addr = str(arg1);
@@ -15,7 +15,7 @@ usdt:./build/src/bitcoind:net:inbound_connection
printf("INBOUND conn from %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing);
}
usdt:./build/src/bitcoind:net:outbound_connection
usdt:./build/bin/bitcoind:net:outbound_connection
{
$id = (int64) arg0;
$addr = str(arg1);
@@ -25,7 +25,7 @@ usdt:./build/src/bitcoind:net:outbound_connection
printf("OUTBOUND conn to %s: id=%ld, type=%s, network=%d, total=%d\n", $addr, $id, $conn_type, $network, $existing);
}
usdt:./build/src/bitcoind:net:closed_connection
usdt:./build/bin/bitcoind:net:closed_connection
{
$id = (int64) arg0;
$addr = str(arg1);
@@ -34,7 +34,7 @@ usdt:./build/src/bitcoind:net:closed_connection
printf("CLOSED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4);
}
usdt:./build/src/bitcoind:net:evicted_inbound_connection
usdt:./build/bin/bitcoind:net:evicted_inbound_connection
{
$id = (int64) arg0;
$addr = str(arg1);
@@ -43,7 +43,7 @@ usdt:./build/src/bitcoind:net:evicted_inbound_connection
printf("EVICTED conn to %s: id=%ld, type=%s, network=%d, established=%ld\n", $addr, $id, $conn_type, $network, arg4);
}
usdt:./build/src/bitcoind:net:misbehaving_connection
usdt:./build/bin/bitcoind:net:misbehaving_connection
{
$id = (int64) arg0;
$message = str(arg1);
+2 -2
View File
@@ -5,7 +5,7 @@ BEGIN
printf("Logging P2P traffic\n")
}
usdt:./build/src/bitcoind:net:inbound_message
usdt:./build/bin/bitcoind:net:inbound_message
{
$peer_id = (int64) arg0;
$peer_addr = str(arg1);
@@ -15,7 +15,7 @@ usdt:./build/src/bitcoind:net:inbound_message
printf("inbound '%s' msg from peer %d (%s, %s) with %d bytes\n", $msg_type, $peer_id, $peer_type, $peer_addr, $msg_len);
}
usdt:./build/src/bitcoind:net:outbound_message
usdt:./build/bin/bitcoind:net:outbound_message
{
$peer_id = (int64) arg0;
$peer_addr = str(arg1);
+4 -4
View File
@@ -8,7 +8,7 @@
This script requires a 'bitcoind' binary compiled with eBPF support and the
'utxocache' tracepoints. By default, it's assumed that 'bitcoind' is
located in './build/src/bitcoind'. This can be modified in the script below.
located in './build/bin/bitcoind'. This can be modified in the script below.
NOTE: requires bpftrace v0.12.0 or above.
*/
@@ -22,7 +22,7 @@ BEGIN
/*
Attaches to the 'utxocache:add' tracepoint and prints additions to the UTXO set cache.
*/
usdt:./build/src/bitcoind:utxocache:add
usdt:./build/bin/bitcoind:utxocache:add
{
$txid = arg0;
$index = (uint32)arg1;
@@ -44,7 +44,7 @@ usdt:./build/src/bitcoind:utxocache:add
/*
Attaches to the 'utxocache:spent' tracepoint and prints spents from the UTXO set cache.
*/
usdt:./build/src/bitcoind:utxocache:spent
usdt:./build/bin/bitcoind:utxocache:spent
{
$txid = arg0;
$index = (uint32)arg1;
@@ -66,7 +66,7 @@ usdt:./build/src/bitcoind:utxocache:spent
/*
Attaches to the 'utxocache:uncache' tracepoint and uncache UTXOs from the UTXO set cache.
*/
usdt:./build/src/bitcoind:utxocache:uncache
usdt:./build/bin/bitcoind:utxocache:uncache
{
$txid = arg0;
$index = (uint32)arg1;