Skip to content

Commit f3874c0

Browse files
committed
Boost 1.90 migration: uniform version across all platforms, remove workarounds
Bump Conan from 1.78 to 1.90, delete #if BOOST_VERSION conditionals in process includes (4 files), collapse 3-tier CMake Boost fallbacks to single Boost::headers target, replace boost::random with <random>. Remove dead boost/process include from web_server (unused). Update docs to reflect 1.90 everywhere.
1 parent e1b0d39 commit f3874c0

10 files changed

Lines changed: 15 additions & 67 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ Original forum thread: <https://bitcointalk.org/index.php?topic=18313>
2121

2222
| OS | Version | Compiler | Boost | Arch | Status |
2323
|----|---------|----------|-------|------|--------|
24-
| Ubuntu | 24.04.4 LTS | GCC 13.3 | 1.78 (Conan) | x86_64 | Working |
24+
| Ubuntu | 24.04.4 LTS | GCC 13.3 | 1.90 (Conan) | x86_64 | Working |
2525
| macOS | 26.3.1 (Tahoe) | Apple Clang 21.0 | 1.90 (Homebrew) | x86_64 Intel | Working |
2626
| macOS || Apple Clang | 1.90 (Homebrew) | arm64 (M-series) | Supported, untested |
27-
| Windows | 11 (26100) | MSVC 2022 | 1.78 (Conan) | x86_64 | Working |
28-
> Other OS versions or Boost releases may require minor fixes.
29-
> Boost API changes between major versions are the most common source of build failures.
27+
| Windows | 11 (26100) | MSVC 2022 | 1.90 (Conan) | x86_64 | Working |
3028

3129
---
3230

conanfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[requires]
2-
boost/1.78.0
2+
boost/1.90.0
33
nlohmann_json/3.12.0
44
yaml-cpp/0.8.0
55
gtest/1.14.0

doc/build-unix.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The same steps work on Ubuntu 22.04 and Debian 12 with minor version differences
3030
| Kernel | 6.17.0 |
3131
| GCC | 13.3.0 |
3232
| CMake | 3.28.3 |
33-
| Boost | 1.78.0 (via Conan) / 1.83.0 (system) |
33+
| Boost | 1.90.0 (via Conan) |
3434
| LevelDB | 1.23 |
3535
| libsecp256k1 | 0.4.1 |
3636
| Architecture | x86_64 |
@@ -64,7 +64,7 @@ sudo apt-get install -y \
6464
| `libsecp256k1-dev` | secp256k1 — ECDSA crypto for btclibs |
6565
| `python3-pip` | needed to install Conan |
6666

67-
> All other dependencies (Boost 1.78, nlohmann_json, yaml-cpp, GoogleTest, zlib,
67+
> All other dependencies (Boost 1.90, nlohmann_json, yaml-cpp, GoogleTest, zlib,
6868
> bzip2, libbacktrace) are downloaded and compiled automatically by Conan.
6969
7070
---
@@ -121,7 +121,7 @@ conan install .. \
121121
This downloads and compiles all managed dependencies into `~/.conan2/` and
122122
generates `conan_toolchain.cmake` and `CMakePresets.json` in `build/`.
123123

124-
**First run**: ~15–20 min (Boost 1.78 compiles from source).
124+
**First run**: ~15–20 min (Boost 1.90 compiles from source if no pre-built binary exists).
125125
**Subsequent runs**: seconds (packages are cached in `~/.conan2/`).
126126

127127
---

src/btclibs/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,4 @@ set(sources
4545
add_library(btclibs STATIC ${sources}) #${SOURCE} ${HEADER})
4646
target_include_directories(btclibs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} util crypto compat)
4747

48-
# Use Boost target names that work with both old and new CMake/Boost versions
49-
if(TARGET Boost::headers)
50-
target_link_libraries(btclibs Boost::headers nlohmann_json::nlohmann_json)
51-
elseif(TARGET Boost::boost)
52-
target_link_libraries(btclibs Boost::boost nlohmann_json::nlohmann_json)
53-
else()
54-
target_link_libraries(btclibs ${Boost_LIBRARIES} nlohmann_json::nlohmann_json)
55-
target_include_directories(btclibs PRIVATE ${Boost_INCLUDE_DIRS})
56-
endif()
48+
target_link_libraries(btclibs Boost::headers nlohmann_json::nlohmann_json)

src/c2pool/payout/developer_payout.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
#include <sstream>
55
#include <cstdlib>
66
#include <algorithm>
7-
#include <boost/version.hpp>
8-
#if BOOST_VERSION >= 108800
9-
#include <boost/process/v1.hpp>
10-
#else
117
#include <boost/process.hpp>
12-
#endif
138
#include <nlohmann/json.hpp>
149
#include <core/filesystem.hpp>
1510

@@ -249,11 +244,7 @@ bool PayoutManager::detect_wallet_address_rpc() {
249244
// Try to get a receiving address
250245
std::string full_command = command + " getnewaddress \"c2pool_node_owner\"";
251246

252-
#if BOOST_VERSION >= 108800
253-
namespace bp = boost::process::v1;
254-
#else
255247
namespace bp = boost::process;
256-
#endif
257248
bp::ipstream pipe_stream;
258249
bp::child rpc_process(full_command, bp::std_out > pipe_stream, bp::std_err > bp::null);
259250

src/c2pool/payout/payout_manager.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
#include <cstdlib>
1212
#include <filesystem>
1313
#include <core/filesystem.hpp>
14-
// Boost 1.88+ ships process v2 as default; we need v1 API (ipstream, child)
15-
#include <boost/version.hpp>
16-
#if BOOST_VERSION >= 108800
17-
#include <boost/process/v1.hpp>
18-
#else
1914
#include <boost/process.hpp>
20-
#endif
2115
#include <nlohmann/json.hpp>
2216
#include <core/log.hpp>
2317

@@ -1101,11 +1095,7 @@ bool PayoutManager::try_detect_wallet_address() {
11011095
return false;
11021096
}
11031097

1104-
#if BOOST_VERSION >= 108800
1105-
namespace bp = boost::process::v1;
1106-
#else
11071098
namespace bp = boost::process;
1108-
#endif
11091099
bp::ipstream pipe_stream;
11101100
bp::child proc(cli_cmd + " getnewaddress \"c2pool_node_owner\"",
11111101
bp::std_out > pipe_stream, bp::std_err > bp::null);

src/core/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,7 @@ find_package(yaml-cpp REQUIRED)
4040
add_library(core STATIC ${source})
4141
target_link_libraries(core btclibs)
4242

43-
# Use Boost target names that work with both old and new CMake/Boost versions
44-
if(TARGET Boost::headers)
45-
target_link_libraries(core Boost::headers Boost::log Boost::log_setup Boost::thread Boost::filesystem yaml-cpp nlohmann_json::nlohmann_json ${LEVELDB_LIBRARIES})
46-
elseif(TARGET Boost::boost)
47-
target_link_libraries(core Boost::boost Boost::log Boost::log_setup Boost::thread Boost::filesystem yaml-cpp nlohmann_json::nlohmann_json ${LEVELDB_LIBRARIES})
48-
else()
49-
target_link_libraries(core ${Boost_LIBRARIES} yaml-cpp nlohmann_json::nlohmann_json ${LEVELDB_LIBRARIES})
50-
target_include_directories(core PRIVATE ${Boost_INCLUDE_DIRS})
51-
endif()
43+
target_link_libraries(core Boost::headers Boost::log Boost::log_setup Boost::thread Boost::filesystem yaml-cpp nlohmann_json::nlohmann_json ${LEVELDB_LIBRARIES})
5244

5345
# Add LevelDB include directories
5446
target_include_directories(core PUBLIC ${LEVELDB_INCLUDE_DIRS})

src/core/random.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
#include "random.hpp"
2-
#include <boost/random.hpp>
2+
#include <random>
33
#include <ctime>
44
#include <cmath>
55

66
namespace core::random
77
{
8-
using namespace boost::random;
9-
10-
boost::random::mt19937 generator(std::time(nullptr));
8+
std::mt19937 generator(std::time(nullptr));
119

1210
///[min, max)
1311
int random_int(int min, int max)
1412
{
1513
if (min == max)
1614
return min;
17-
boost::random::uniform_int_distribution<> rnd(min, max - 1);
15+
std::uniform_int_distribution<> rnd(min, max - 1);
1816
return rnd(generator);
1917
}
2018

2119
///[min, max]
2220
float random_float(float min, float max)
2321
{
2422
float Min = float(min), Max = float(max);
25-
boost::random::uniform_int_distribution<> rnd(Min, Max);
23+
std::uniform_int_distribution<> rnd(Min, Max);
2624
float res = ((float)rnd(generator) / Max);
2725
float range = Max - Min;
2826
res = (res * range) + Min;
@@ -51,15 +49,14 @@ namespace core::random
5149
/// l = desired mean value
5250
double expovariate(double l)
5351
{
54-
boost::random::exponential_distribution<double> rnd(l);
52+
std::exponential_distribution<double> rnd(l);
5553
return rnd(generator);
56-
// return (log(RandomInt(1, RAND_MAX) + 1) - log(RAND_MAX)) / (-1 / l);
5754
}
5855

5956
unsigned long long random_nonce()
6057
{
61-
boost::random::uniform_int_distribution<unsigned long long> rnd(0, 0xFFFFFFFFFFFFFFFF);
58+
std::uniform_int_distribution<unsigned long long> rnd(0, 0xFFFFFFFFFFFFFFFF);
6259
return rnd(generator);
6360
}
6461

65-
} // namespace core::random
62+
} // namespace core::random

src/core/web_server.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
#ifndef _WIN32
3131
#include <unistd.h>
3232
#endif
33-
#include <boost/version.hpp>
34-
#if BOOST_VERSION >= 108800
35-
#include <boost/process/v1.hpp>
36-
#else
37-
#include <boost/process.hpp>
38-
#endif
3933
#include <boost/algorithm/string.hpp>
4034
#include "btclibs/base58.h"
4135
#include "btclibs/bech32.h"

src/core/web_server.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717

1818
#include <boost/asio.hpp>
1919
#include <boost/beast.hpp>
20-
#include <boost/version.hpp>
21-
#if BOOST_VERSION >= 108800
22-
#include <boost/process/v1.hpp>
23-
#else
24-
#include <boost/process.hpp>
25-
#endif
2620
#include <nlohmann/json.hpp>
2721
#include <jsonrpccxx/server.hpp>
2822

0 commit comments

Comments
 (0)