Boost::ASIO (used by Boost::Process) uses (falsely?) deprecated std::allocator #22254

issue Sjors opened this issue on June 15, 2021
  1. Sjors commented at 7:04 PM on June 15, 2021: member

    Observed by @fanquake in #21935#pullrequestreview-683513857

    (depends build) Boost Process seems to use Boost ASIO, which uses std::allocator<void>, which was deprecated in C++17. This leads to a nice stack of warnings, at least on macOS:

    bitcoin/depends/x86_64-apple-darwin20.5.0/include/boost/asio/associated_allocator.hpp:78:49: warning: 'allocator<void>' is deprecated [-Wdeprecated-declarations]
    template <typename T, typename Allocator = std::allocator<void> >
                                                    ^
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:730:28: note: 'allocator<void>' has been explicitly marked deprecated here
    class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
                               ^
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:1058:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
    #  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
                                          ^
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:1035:48: note: expanded from macro '_LIBCPP_DEPRECATED'
    #    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
    

    I'm also seeing unused-result warnings (from Boost) when building on my Ubuntu machine:

    In file included from /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/detail/execute_impl.hpp:24,
                     from /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/child.hpp:22,
                     from /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/async_system.hpp:22,
                     from /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process.hpp:24,
                     from util/system.cpp:9:
    /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/detail/posix/executor.hpp: In member function ‘void boost::process::detail::posix::executor<Sequence>::write_error(const std::error_code&, const char*) [with Sequence = boost::fusion::joint_view<boost::fusion::tuple<boost::process::detail::posix::exe_cmd_init<char> >, boost::fusion::filter_view<const boost::fusion::tuple<const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::process::detail::posix::pipe_out<1, -1>&, boost::process::detail::posix::pipe_out<2, -1>&, boost::process::detail::posix::pipe_in&>, boost::process::detail::is_initializer<mpl_::arg<-1> > > >]’:
    /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/detail/posix/executor.hpp:156:16: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      156 |         ::write(_pipe_sink, &len, sizeof(int));
          |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/detail/posix/executor.hpp:159:16: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      159 |         ::write(_pipe_sink, &len, sizeof(int));
          |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/ubuntu/bitcoin/depends/x86_64-pc-linux-gnu/include/boost/process/detail/posix/executor.hpp:160:16: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      160 |         ::write(_pipe_sink, msg, len);
          |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
      AR       libbitcoin_util.a
    

    I tried with Boost 1.72 - 1.76 (most recent version on 2021-06-15) but to no avail.

    Possible solutions:

    In addition to annoying warnings, this would require someone with a c++20 compiler to use --disable-external-signer.

  2. Sjors added the label Bug on Jun 15, 2021
  3. Sjors renamed this:
    Boost::ASIO (used by Boost::Process) uses deprecated std::allocator
    Boost::ASIO (used by Boost::Process) uses (falsely?) deprecated std::allocator
    on Jun 15, 2021
  4. akhil14shukla commented at 12:44 PM on July 4, 2021: none

    I checked the repo for boost/asio dependency, and I didn't find any trace of it in the search results. It seems that while building we check the BOOST library thus also checking the boost/asio and leading to warnings. Adding a condition to skip this boost/asio should suppress the warnings.

  5. Sjors commented at 9:36 AM on July 6, 2021: member

    I tried removing boost/asio from depends with a patch, but we do seem to need it:

    In file included from util/system.cpp:14:
    In file included from /Users/sjors/dev/bitcoin/depends/x86_64-apple-darwin20.5.0/include/boost/process.hpp:23:
    /Users/sjors/dev/bitcoin/depends/x86_64-apple-darwin20.5.0/include/boost/process/async.hpp:35:10: fatal error: 'boost/asio/io_context.hpp' file not found
    #include <boost/asio/io_context.hpp>
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    make[2]: *** [util/libbitcoin_util_a-system.o] Error 1
    
  6. Sjors commented at 12:23 PM on April 29, 2022: member

    Hopefully we can replace Boost::Process altogether, see #24907

  7. fanquake commented at 7:40 PM on August 8, 2022: member

    std::allocator<void> was undeprecated in LLVM: https://github.com/llvm/llvm-project/commit/87784cc6fb3453a17e0e7826b943a1d93cbfeccf. There's no need for us to keep an issue open for this for now.

  8. fanquake closed this on Aug 8, 2022

  9. bitcoin locked this on Aug 8, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-03 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me