From 88890b9bb111c786d710fb4329e6ba8f032a67f2 Mon Sep 17 00:00:00 2001 From: Kenneth Raplee <101818165+kenrap@users.noreply.github.com> Date: Sun, 25 Oct 2026 19:33:17 +0000 Subject: [PATCH] Build against recent system Boost (>= 1.87) (#15835) Boost 1.87 removed io_service and io_context::reset(), and 1.88 moved the classic Boost.Process API under boost/process/v1/ and dropped deadline_timer from boost/asio.hpp. Use io_context, restart() and steady_timer, and include Boost.Process only through the new slic3r/Utils/BoostProcessCompat.hpp, which picks the v1 headers on 1.88+. The bundled Boost 1.84 build is unchanged. --- .clang-tidy | 4 +++- src/slic3r/GUI/HttpServer.hpp | 4 ++-- src/slic3r/GUI/MediaPlayCtrl.cpp | 10 ++------ src/slic3r/GUI/PostProcessor.cpp | 4 +--- src/slic3r/GUI/ProcessRunner.cpp | 10 +------- src/slic3r/GUI/ProcessRunner.hpp | 6 +---- src/slic3r/GUI/RemovableDriveManager.cpp | 5 +--- src/slic3r/GUI/WebUserLoginDialog.cpp | 4 ++-- src/slic3r/Utils/Bonjour.cpp | 29 ++++++++++++------------ src/slic3r/Utils/Bonjour.hpp | 16 ++++++------- src/slic3r/Utils/BoostProcessCompat.hpp | 23 +++++++++++++++++++ src/slic3r/Utils/Serial.cpp | 12 +++++----- src/slic3r/Utils/Serial.hpp | 6 ++--- src/slic3r/plugin/PluginLoader.cpp | 8 +------ 14 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 src/slic3r/Utils/BoostProcessCompat.hpp diff --git a/.clang-tidy b/.clang-tidy index ab2a1dfbd7..0dea849099 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -27,6 +27,7 @@ CheckOptions: # are included through clipper2/clipper.h, or clipper2_z.hpp, which defines # USINGZ first. minilzo's config # headers are internal to minilzo.h. + # The boost/process headers are only included through Utils/BoostProcessCompat.hpp. # FFmpeg's C headers are left alone because they are only included inside # extern "C", which an inserted include would miss. OS-specific headers (GLib, # GTK, D-Bus, POSIX, the Windows SDK) are only used inside platform #if blocks, @@ -72,4 +73,5 @@ CheckOptions: mcut[/\\]platform\.h; boost[/\\]polygon[/\\].*; clipper2[/\\]clipper\.(core|engine|offset|minkowski|rectclip|export|triangulation|version)\.h; - lzo(conf|defs)\.h + lzo(conf|defs)\.h; + boost[/\\]process[/\\].* diff --git a/src/slic3r/GUI/HttpServer.hpp b/src/slic3r/GUI/HttpServer.hpp index d609821bc6..ed9dc8239e 100644 --- a/src/slic3r/GUI/HttpServer.hpp +++ b/src/slic3r/GUI/HttpServer.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -137,7 +137,7 @@ private: { public: HttpServer& server; - boost::asio::io_service io_service; + boost::asio::io_context io_service; boost::asio::ip::tcp::acceptor acceptor; std::set> sessions; diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index c16731793b..cb6716cd7e 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -41,10 +41,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -63,10 +59,8 @@ #include #include #undef pid_t -#include -#ifdef __WIN32__ -#include -#else +#include +#ifndef __WIN32__ #include #include #endif diff --git a/src/slic3r/GUI/PostProcessor.cpp b/src/slic3r/GUI/PostProcessor.cpp index c918650aa7..34087aa7cb 100644 --- a/src/slic3r/GUI/PostProcessor.cpp +++ b/src/slic3r/GUI/PostProcessor.cpp @@ -27,8 +27,6 @@ // BBS #include -#include -#include #include #include #include @@ -187,7 +185,7 @@ static int run_script(const std::string& script, const std::string& gcode, std:: // POSIX #include // getenv() -#include +#include namespace process = boost::process; diff --git a/src/slic3r/GUI/ProcessRunner.cpp b/src/slic3r/GUI/ProcessRunner.cpp index 3be56c032f..3320321d3f 100644 --- a/src/slic3r/GUI/ProcessRunner.cpp +++ b/src/slic3r/GUI/ProcessRunner.cpp @@ -1,9 +1,6 @@ #include "ProcessRunner.hpp" -#include -#include -#include -#include +#include #include #include #include @@ -12,12 +9,7 @@ #include #include #include -#include -#include #include -#ifdef _WIN32 -#include -#endif namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/ProcessRunner.hpp b/src/slic3r/GUI/ProcessRunner.hpp index 0fd902acf5..a3383f158a 100644 --- a/src/slic3r/GUI/ProcessRunner.hpp +++ b/src/slic3r/GUI/ProcessRunner.hpp @@ -1,7 +1,7 @@ #ifndef slic3r_GUI_ProcessRunner_hpp_ #define slic3r_GUI_ProcessRunner_hpp_ -#include +#include #include #include @@ -13,10 +13,6 @@ #include #include -#include - -namespace boost::process { class child; } - namespace Slic3r { namespace GUI { class ProcessRunner : public wxEvtHandler diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index f628a9a312..e0a9267d2c 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -2,9 +2,6 @@ #include "libslic3r/Platform.hpp" #include #include -#include -#include -#include #include #include #include @@ -39,7 +36,7 @@ #include #include #include -#include +#include #endif namespace Slic3r { diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index 7f7c8c51c0..de236addd5 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -1,6 +1,6 @@ #include "WebUserLoginDialog.hpp" -#include +#include #include #include "slic3r/GUI/HttpServer.hpp" #include @@ -70,7 +70,7 @@ namespace { int reserve_loopback_port() { try { - boost::asio::io_service io_service; + boost::asio::io_context io_service; boost::asio::ip::tcp::acceptor acceptor(io_service, {boost::asio::ip::tcp::v4(), 0}); return static_cast(acceptor.local_endpoint().port()); } catch (...) { diff --git a/src/slic3r/Utils/Bonjour.cpp b/src/slic3r/Utils/Bonjour.cpp index e67d3f0240..cf26905709 100644 --- a/src/slic3r/Utils/Bonjour.cpp +++ b/src/slic3r/Utils/Bonjour.cpp @@ -2,19 +2,21 @@ #include #include +#include #include #include #include #include #include -#include +#include #include #include #include +#include #include #include #include -#include +#include #include #include #include @@ -29,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -641,7 +642,7 @@ UdpSession::UdpSession(Bonjour::ReplyFn rfn) : replyfn(rfn) buffer.resize(DnsMessage::MAX_SIZE); } -UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, const asio::ip::address& interface_address, std::shared_ptr< boost::asio::io_service > io_service) +UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, const asio::ip::address& interface_address, std::shared_ptr< boost::asio::io_context > io_service) : replyfn(replyfn) , multicast_address(multicast_address) , socket(*io_service) @@ -675,7 +676,7 @@ UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multica } -UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, std::shared_ptr< boost::asio::io_service > io_service) +UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, std::shared_ptr< boost::asio::io_context > io_service) : replyfn(replyfn) , multicast_address(multicast_address) , socket(*io_service) @@ -731,7 +732,7 @@ void UdpSocket::receive_handler(SharedSession session, const boost::system::erro // let io_service to handle the datagram on session // from boost documentation io_service::post: // The io_service guarantees that the handler will only be called in a thread in which the run(), run_one(), poll() or poll_one() member functions is currently being invoked. - io_service->post(boost::bind(&UdpSession::handle_receive, session, error, bytes)); + boost::asio::post(*io_service, boost::bind(&UdpSession::handle_receive, session, error, bytes)); // immediately accept new datagrams async_receive(); } @@ -888,7 +889,7 @@ void Bonjour::priv::lookup_perform() { service_dn = (boost::format("_%1%._%2%.local") % service % protocol).str(); - std::shared_ptr< boost::asio::io_service > io_service(new boost::asio::io_service); + std::shared_ptr< boost::asio::io_context > io_service(new boost::asio::io_context); std::vector sockets; @@ -940,7 +941,7 @@ void Bonjour::priv::lookup_perform() socket->send(); // timer settings - asio::deadline_timer timer(*io_service); + asio::steady_timer timer(*io_service); retries--; std::function timer_handler = [&](const error_code& error) { // end @@ -953,7 +954,7 @@ void Bonjour::priv::lookup_perform() // restart timer } else { retries--; - timer.expires_from_now(boost::posix_time::seconds(timeout)); + timer.expires_after(std::chrono::seconds(timeout)); timer.async_wait(timer_handler); // trigger another round of queries for (auto * socket : sockets) @@ -961,7 +962,7 @@ void Bonjour::priv::lookup_perform() } }; // start timer - timer.expires_from_now(boost::posix_time::seconds(timeout)); + timer.expires_after(std::chrono::seconds(timeout)); timer.async_wait(timer_handler); // start io_service, it will run until it has something to do - so in this case until stop is called in timer io_service->run(); @@ -983,7 +984,7 @@ void Bonjour::priv::resolve_perform() rpls.push_back(reply); }; - std::shared_ptr< boost::asio::io_service > io_service(new boost::asio::io_service); + std::shared_ptr< boost::asio::io_context > io_service(new boost::asio::io_context); std::vector sockets; // resolve interfaces - from PR#6646 @@ -1033,7 +1034,7 @@ void Bonjour::priv::resolve_perform() socket->send(); // timer settings - asio::deadline_timer timer(*io_service); + asio::steady_timer timer(*io_service); retries--; std::function timer_handler = [&](const error_code& error) { int replies_count = replies.size(); @@ -1047,7 +1048,7 @@ void Bonjour::priv::resolve_perform() // restart timer } else { retries--; - timer.expires_from_now(boost::posix_time::seconds(timeout)); + timer.expires_after(std::chrono::seconds(timeout)); timer.async_wait(timer_handler); // trigger another round of queries for (auto * socket : sockets) @@ -1055,7 +1056,7 @@ void Bonjour::priv::resolve_perform() } }; // start timer - timer.expires_from_now(boost::posix_time::seconds(timeout)); + timer.expires_after(std::chrono::seconds(timeout)); timer.async_wait(timer_handler); // start io_service, it will run until it has something to do - so in this case until stop is called in timer io_service->run(); diff --git a/src/slic3r/Utils/Bonjour.hpp b/src/slic3r/Utils/Bonjour.hpp index be7d89a8f1..3a301b5dfd 100644 --- a/src/slic3r/Utils/Bonjour.hpp +++ b/src/slic3r/Utils/Bonjour.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -165,11 +165,11 @@ public: UdpSocket(Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address , const boost::asio::ip::address& interface_address - , std::shared_ptr< boost::asio::io_service > io_service); + , std::shared_ptr< boost::asio::io_context > io_service); UdpSocket(Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address - , std::shared_ptr< boost::asio::io_service > io_service); + , std::shared_ptr< boost::asio::io_context > io_service); void send(); void async_receive(); @@ -182,7 +182,7 @@ protected: boost::asio::ip::address multicast_address; boost::asio::ip::udp::socket socket; boost::asio::ip::udp::endpoint mcast_endpoint; - std::shared_ptr< boost::asio::io_service > io_service; + std::shared_ptr< boost::asio::io_context > io_service; std::vector requests; }; @@ -196,7 +196,7 @@ public: , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address , const boost::asio::ip::address& interface_address - , std::shared_ptr< boost::asio::io_service > io_service) + , std::shared_ptr< boost::asio::io_context > io_service) : UdpSocket(replyfn, multicast_address, interface_address, io_service) , txt_keys(txt_keys) , service(service) @@ -213,7 +213,7 @@ public: , std::string protocol , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address - , std::shared_ptr< boost::asio::io_service > io_service) + , std::shared_ptr< boost::asio::io_context > io_service) : UdpSocket(replyfn, multicast_address, io_service) , txt_keys(txt_keys) , service(service) @@ -251,7 +251,7 @@ public: , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address , const boost::asio::ip::address& interface_address - , std::shared_ptr< boost::asio::io_service > io_service) + , std::shared_ptr< boost::asio::io_context > io_service) : UdpSocket(replyfn, multicast_address, interface_address, io_service) , hostname(hostname) @@ -263,7 +263,7 @@ public: ResolveSocket(const std::string& hostname , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address - , std::shared_ptr< boost::asio::io_service > io_service) + , std::shared_ptr< boost::asio::io_context > io_service) : UdpSocket(replyfn, multicast_address, io_service) , hostname(hostname) diff --git a/src/slic3r/Utils/BoostProcessCompat.hpp b/src/slic3r/Utils/BoostProcessCompat.hpp new file mode 100644 index 0000000000..ef567e2dfd --- /dev/null +++ b/src/slic3r/Utils/BoostProcessCompat.hpp @@ -0,0 +1,23 @@ +#ifndef slic3r_Utils_BoostProcessCompat_hpp_ +#define slic3r_Utils_BoostProcessCompat_hpp_ + +#include + +// Since Boost 1.88 the classic boost/process headers are only available +// under boost/process/v1/, select those there and the originals otherwise. +#if BOOST_VERSION >= 108800 +#define BOOST_PROCESS_VERSION 1 +#include +#else +#include +#endif + +#ifdef _WIN32 +#if BOOST_VERSION >= 108800 +#include +#else +#include +#endif +#endif + +#endif // slic3r_Utils_BoostProcessCompat_hpp_ diff --git a/src/slic3r/Utils/Serial.cpp b/src/slic3r/Utils/Serial.cpp index 1b54125c0f..b1bede2cbe 100644 --- a/src/slic3r/Utils/Serial.cpp +++ b/src/slic3r/Utils/Serial.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -289,11 +289,11 @@ std::vector scan_serial_ports() namespace asio = boost::asio; -Serial::Serial(asio::io_service& io_service) : +Serial::Serial(asio::io_context& io_service) : asio::serial_port(io_service) {} -Serial::Serial(asio::io_service& io_service, const std::string &name, unsigned baud_rate) : +Serial::Serial(asio::io_context& io_service, const std::string &name, unsigned baud_rate) : asio::serial_port(io_service, name) { set_baud_rate(baud_rate); @@ -406,12 +406,12 @@ bool Serial::read_line(unsigned timeout, std::string &line, error_code &ec) #else this->get_io_service(); #endif - asio::deadline_timer timer(io_service); + asio::steady_timer timer(io_service); char c = 0; bool fail = false; while (true) { - io_service.reset(); + io_service.restart(); asio::async_read(*this, boost::asio::buffer(&c, 1), [&](const error_code &read_ec, size_t size) { if (ec || size == 0) { @@ -422,7 +422,7 @@ bool Serial::read_line(unsigned timeout, std::string &line, error_code &ec) }); if (timeout > 0) { - timer.expires_from_now(boost::posix_time::milliseconds(timeout)); + timer.expires_after(std::chrono::milliseconds(timeout)); timer.async_wait([&](const error_code &ec) { // Ignore timer aborts if (!ec) { diff --git a/src/slic3r/Utils/Serial.hpp b/src/slic3r/Utils/Serial.hpp index c5c4d19fc5..5d01d81b33 100644 --- a/src/slic3r/Utils/Serial.hpp +++ b/src/slic3r/Utils/Serial.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -42,8 +42,8 @@ extern std::vector scan_serial_ports_extended(); class Serial : public boost::asio::serial_port { public: - Serial(boost::asio::io_service &io_service); - Serial(boost::asio::io_service &io_service, const std::string &name, unsigned baud_rate); + Serial(boost::asio::io_context &io_service); + Serial(boost::asio::io_context &io_service, const std::string &name, unsigned baud_rate); Serial(const Serial &) = delete; Serial &operator=(const Serial &) = delete; ~Serial(); diff --git a/src/slic3r/plugin/PluginLoader.cpp b/src/slic3r/plugin/PluginLoader.cpp index 70601b3a5b..ca4f74c96d 100644 --- a/src/slic3r/plugin/PluginLoader.cpp +++ b/src/slic3r/plugin/PluginLoader.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include "slic3r/plugin/PluginDescriptor.hpp" #include #include @@ -31,13 +31,7 @@ #include "slic3r/plugin/PythonPluginInterface.hpp" #include #include -#include -#include -#include #include -#ifdef _WIN32 -#include -#endif #include #include