ipc: add windows support #32387

pull ryanofsky wants to merge 33 commits into bitcoin:master from ryanofsky:pr/ipc-win changing 76 files +1462 −623
  1. DrahtBot commented at 12:43 PM on April 30, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32387.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK hebasto

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35916 (fuzz: improve ipc fuzz coverage by enirox001)
    • #35879 (ci: Fix $BASE_ROOT_DIR installation by maflcko)
    • #35877 (build: ci/doc win64-cross build via nix by maflcko)
    • #35852 (scripted-diff: Use inline const(expr) over static constexpr in headers by maflcko)
    • #33585 (cmake: Use builtin support for .manifest files by purpleKarrot)
    • #32162 (depends: Switch from multilib to platform-specific toolchains by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • It it possible -> It is possible [β€œIt it” is a typo and breaks the sentence]

    <sup>2026-08-04 23:12:46</sup>

  2. ryanofsky force-pushed on Apr 30, 2025
  3. ryanofsky commented at 12:47 PM on April 30, 2025: contributor

    Updated 9df5a838aa9c020adf8d024393749d75bd932ec2 -> 87432b6a4325e09a13c912d77b386daa3832b34d (pr/ipc-win.1 -> pr/ipc-win.2, compare) fixing accidentally disabled tests

  4. hebasto commented at 1:47 PM on April 30, 2025: member

    Concept ACK.

  5. DrahtBot added the label CI failed on Apr 30, 2025
  6. DrahtBot commented at 3:00 PM on April 30, 2025: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task multiprocess, i686, DEBUG: https://github.com/bitcoin/bitcoin/runs/41420704031</sub> <sub>LLM reason (✨ experimental): The CI failure is caused by an assertion failure in the IPC test suite due to a nullptr dereference.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  7. Sjors commented at 7:12 PM on April 30, 2025: member

    I guess the easiest way to test this would be to combine it with:

    1. #31756 so I can bake a Widnows guix build instead of learning to compile on Windows; and
    2. #30437 to have something to test against
  8. ryanofsky force-pushed on Apr 30, 2025
  9. ryanofsky commented at 9:24 PM on April 30, 2025: contributor

    Updated 87432b6a4325e09a13c912d77b386daa3832b34d -> 0a35e21103b7fed6e46c809e9029446277b6f6ee (pr/ipc-win.2 -> pr/ipc-win.3, compare) to fix test CI failure https://cirrus-ci.com/task/5583224107171840 due to bad std::optional access Updated 0a35e21103b7fed6e46c809e9029446277b6f6ee -> 27328195136754babe8d8f5d99f4f0b6a5ab2e55 (pr/ipc-win.3 -> pr/ipc-win.4, compare) to fix CI test failure https://cirrus-ci.com/task/5668412652781568 in rpc_misc.py echoipc call due to CLOEXEC flag


    re: #32387 (comment)

    Agree changes in #31756 should make this easier to test (though I might be able to make a minimal change here to turn on multiprocess windows build).

    Having #30437 or #32297 merged first would also make test coverage more meaningful because they both add functional tests for -ipcbind and -ipcconect options.

    In general there is more work to do here and I hope other PRs can be merged before this one.

  10. ryanofsky force-pushed on May 1, 2025
  11. DrahtBot removed the label CI failed on May 1, 2025
  12. ryanofsky force-pushed on May 2, 2025
  13. ryanofsky commented at 9:12 PM on May 2, 2025: contributor

    Updated 27328195136754babe8d8f5d99f4f0b6a5ab2e55 -> f215e742045401ab386f0cd67d06b358558ecf89 (pr/ipc-win.4 -> pr/ipc-win.5, compare) fixing many windows bugs.

    With this update, IPC code is mostly working on windows: mpexample and mptest programs work, test_bitcoin IPC calls over socketpairs work, bitcoin-node echoipc command is able to create a subprocess and successfully make calls to it, and bitcoin-node -ipcbind option creates a unix socket file. Some problems remain:

    • This is a hang on shutdown that prevents child processes from exiting. You can kill them manually and everything works fine, but this problem needs to be debugged.
    • bitcoin-mine -ipcconnect seems unable to find the unix socket, failing with "Error: The system cannot find the file specified" even though the socket exists. Two test_bitcoin unix socket tests also give similar errors.
    • The test_bitcoin parse address tests fails because some checks are looking for / not \ separators.
  14. ryanofsky force-pushed on May 6, 2025
  15. ryanofsky commented at 3:09 PM on May 6, 2025: contributor

    Updated f215e742045401ab386f0cd67d06b358558ecf89 -> 5f272b7cc3b72fe4a59f590825b68dc2c342baca (pr/ipc-win.5 -> pr/ipc-win.6, compare) with more fixes.

    <!-- begin push-7 -->

    Updated 5f272b7cc3b72fe4a59f590825b68dc2c342baca -> 13aef5ad7669e0302e27f96876615907dc98c3c3 (pr/ipc-win.6 -> pr/ipc-win.7, compare)<!-- end --> improving comments.

    With the new fixes, IPC is fully working on windows: both creating child processes and communicating over socket pairs, and listening and making connections over unix sockets. (Latter currently requires adding a SetupNetworking call to bitcoin-mine in #30437). The code changes are also mostly straightforward and clean, although I want to split commits to make them easier to review.

    Will leave this PR in a draft state for now since other multiprocess PRs should have higher priority (see tracking issue #28722)

    --

    <!-- begin push-8 -->

    Rebased 13aef5ad7669e0302e27f96876615907dc98c3c3 -> cbd06846803e800f23f4498e27f930e09d260000 (pr/ipc-win.7 -> pr/ipc-win.8, compare)<!-- end --> due to conflicts with #32345

    <!-- begin push-9 -->

    Rebased cbd06846803e800f23f4498e27f930e09d260000 -> 3d0737720ae6bbd2c3eb4382e41fa49dd3d727d9 (pr/ipc-win.8 -> pr/ipc-win.9, compare)<!-- end --> due to conflicts with #33517

    <!-- begin push-10 -->

    Rebased 3d0737720ae6bbd2c3eb4382e41fa49dd3d727d9 -> 24f5e883f20d0c65bc163dba0e3d8c2f031c63c7 (pr/ipc-win.9 -> pr/ipc-win.10, compare)<!-- end --> due to conflict with #33960

    <!-- begin push-11 -->

    Rebased 24f5e883f20d0c65bc163dba0e3d8c2f031c63c7 -> ac0b14c567f40ed813f9bf2ebe316fcd8249ffbe (pr/ipc-win.10 -> pr/ipc-win.11, compare)<!-- end --> on top of https://github.com/bitcoin-core/libmultiprocess/pull/231 pr/win.3 and #35084 pr/ipc-wins.1

    <!-- begin push-12 -->

    Updated ac0b14c567f40ed813f9bf2ebe316fcd8249ffbe -> 533b3460457c0f26727646677cccb303a4036c7e (pr/ipc-win.11 -> pr/ipc-win.12, compare)<!-- end --> to fix ci errors https://github.com/bitcoin/bitcoin/actions/runs/24465570509 vcpkg capnproto dependency error, ipc_test cmake include directory errors, lint subtree error

    <!-- begin push-13 -->

    Updated 533b3460457c0f26727646677cccb303a4036c7e -> ec10ff7c9d9a82b5caee50e2d0d6b90a55fa8ea4 (pr/ipc-win.12 -> pr/ipc-win.13, compare)<!-- end --> to fix ci errors https://github.com/bitcoin/bitcoin/actions/runs/24539458137 in base prs: lint ipc_test.cpp boost test name error, and HasReason boost test include errors

    <!-- begin push-14 -->

    Updated ec10ff7c9d9a82b5caee50e2d0d6b90a55fa8ea4 -> 23b1d507334c6e429ca87ad6af2b401313a5623b (pr/ipc-win.13 -> pr/ipc-win.14, compare)<!-- end --> to fix bitcoin core macos exception type error https://github.com/bitcoin/bitcoin/actions/runs/24542080405/job/71749864777?pr=32387

    <!-- begin push-15 -->

    Updated 23b1d507334c6e429ca87ad6af2b401313a5623b -> 0211390861baa245ec77766f9a6f1d17ad441649 (pr/ipc-win.14 -> pr/ipc-win.15, compare)<!-- end --> to fix pthreads include error https://github.com/bitcoin/bitcoin/actions/runs/24543367909/job/71753783189?pr=32387 in native windows build and enable ipc in windows cross builds

    <!-- begin push-16 -->

    Updated 0211390861baa245ec77766f9a6f1d17ad441649 -> cac16bb4859b6b2ec96063ea52d71d997643c87c (pr/ipc-win.15 -> pr/ipc-win.16, compare)<!-- end --> to fix CI errors https://github.com/bitcoin/bitcoin/actions/runs/24545738655/job/71762261393?pr=32387 bitcoin-gui RC file error and commit message formatting lint error, also adding mp::MakeStream method to simplify changes

    <!-- begin push-17 -->

    Updated cac16bb4859b6b2ec96063ea52d71d997643c87c -> 6baabfe441da0a6430993d0e11d407a6416ece6f (pr/ipc-win.16 -> pr/ipc-win.17, compare)<!-- end --> to fix more RC file errors caused by build path problem in previous attempted fix https://github.com/bitcoin/bitcoin/actions/runs/24568789956/job/71836011315?pr=32387, which caused cross compiled windows builds to now fail as well as the native build. Also move previous fix for pthreads include error to a new commit also implementing a fix for a unistd include error in the msvc build. Also rearrange commits and add a whitespace fix to fix a lint error.

    <!-- begin push-18 -->

    Updated 6baabfe441da0a6430993d0e11d407a6416ece6f -> d53bc6c783e7e91bc06f23140f8415eb48c9ab0b (pr/ipc-win.17 -> pr/ipc-win.18, compare)<!-- end --> to fix another msvc (non-mingw) posix error with execvp, and a wsasocket error https://github.com/bitcoin/bitcoin/actions/runs/24575486745/job/71859566530?pr=32387, also more cross-compiled test manifest rc errors

    <!-- begin push-19 -->

    Updated d53bc6c783e7e91bc06f23140f8415eb48c9ab0b -> aa323482ccb40edf3b6bfed16d3e136257ca5d6e (pr/ipc-win.18 -> pr/ipc-win.19, compare)<!-- end --> to fix more ci errors https://github.com/bitcoin/bitcoin/actions/runs/24582112980/job/71882361998?pr=32387: MSVC errors dealing with std::variant (known compiler bug) and workaround for lack of fork in mpgen(). Also ipc_tests.cpp fix for incorrect closesocket call in test. Also added /k option to msvc build to try to get more complete lists of compiler errors

    <!-- begin push-20 -->

    Updated aa323482ccb40edf3b6bfed16d3e136257ca5d6e -> 68bc7eeff2ffd44d79e8669fc8dc8b335ae18e7d (pr/ipc-win.19 -> pr/ipc-win.20, compare)<!-- end --> to fix error from /k flag https://github.com/bitcoin/bitcoin/actions/runs/24587189710/job/71899642665?pr=32387, also cleaning up internal commits and replacing confusing SpawnProcess overload

    <!-- begin push-21 -->

    Updated 68bc7eeff2ffd44d79e8669fc8dc8b335ae18e7d -> 855cfb764d21e1b6f05c26d5cfadd0a2d165580d (pr/ipc-win.20 -> pr/ipc-win.21, compare)<!-- end --> reorganizing windows support comits and fixing ci errors: https://github.com/bitcoin/bitcoin/actions/runs/24589091659/job/71905779254?pr=32387 -Werror unused function warning in cross-compiled win32 job, and attempting to fix mpgen runtime error in visual studio ci job

    <!-- begin push-22 -->

    Updated 855cfb764d21e1b6f05c26d5cfadd0a2d165580d -> 2573aff25d9f773249ecd790af3a232de6397f46 (pr/ipc-win.21 -> pr/ipc-win.22, compare)<!-- end --> fixing bitcoin.exe wrapper exiting after spawning subprocesses to fix functional tests failures in windows cross-compiled binaries test https://github.com/bitcoin/bitcoin/actions/runs/24686166591/job/72198932709?pr=32387 and also adding better mpgen exception handling to determine why Windows native VS job still fails on windows, since it is still just exiting with code -1073740791 (STATUS_FAIL_FAST_EXCEPTION)

    <!-- begin push-23 -->

    Updated 2573aff25d9f773249ecd790af3a232de6397f46 -> 13de58e1b5ec29d0db22073faa3d5eee36a03616 (pr/ipc-win.22 -> pr/ipc-win.23, compare)<!-- end --> changing the way mpgen tool locates capnproto binaries to fix mpgen errors in https://github.com/bitcoin/bitcoin/actions/runs/24695410947/job/72226931947?pr=32387 and fixing the way socket error codes are translated to try to get better functional tests errors than "error: timeout on transient error: The operation completed successfully" in https://github.com/bitcoin/bitcoin/pull/32387

  16. ryanofsky force-pushed on May 6, 2025
  17. fanquake added this to a project on May 10, 2025
  18. fanquake changed the project status on May 10, 2025
  19. DrahtBot added the label Needs rebase on May 20, 2025
  20. ryanofsky referenced this in commit 7d9789401b on Aug 20, 2025
  21. ryanofsky force-pushed on Oct 15, 2025
  22. ryanofsky referenced this in commit 0f75629bc5 on Oct 22, 2025
  23. ryanofsky referenced this in commit 7d2f3c4371 on Oct 22, 2025
  24. ryanofsky force-pushed on Oct 22, 2025
  25. ryanofsky renamed this:
    [DRAFT] ipc: add windows support
    ipc: add windows support
    on Oct 22, 2025
  26. DrahtBot removed the label Needs rebase on Oct 22, 2025
  27. DrahtBot added the label Needs rebase on Dec 2, 2025
  28. ryanofsky force-pushed on Dec 12, 2025
  29. DrahtBot removed the label Needs rebase on Dec 12, 2025
  30. DrahtBot added the label CI failed on Dec 12, 2025
  31. DrahtBot commented at 4:18 PM on December 12, 2025: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task No wallet: https://github.com/bitcoin/bitcoin/actions/runs/20166538974/job/57891563544</sub> <sub>LLM reason (✨ experimental): Compilation failure: missing mp::Stream and mp::SocketId types (making CapnpProtocol abstract and uninstantiable).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  32. ryanofsky referenced this in commit 2975facdd1 on Apr 3, 2026
  33. ryanofsky referenced this in commit 070e0d1cc8 on Apr 3, 2026
  34. ryanofsky referenced this in commit 869691cc12 on Apr 15, 2026
  35. ryanofsky force-pushed on Apr 15, 2026
  36. ryanofsky force-pushed on Apr 16, 2026
  37. ryanofsky force-pushed on Apr 17, 2026
  38. ryanofsky force-pushed on Apr 17, 2026
  39. ryanofsky force-pushed on Apr 17, 2026
  40. ryanofsky force-pushed on Apr 17, 2026
  41. ryanofsky force-pushed on Apr 17, 2026
  42. ryanofsky force-pushed on Apr 17, 2026
  43. ryanofsky force-pushed on Apr 17, 2026
  44. ryanofsky force-pushed on Apr 17, 2026
  45. ryanofsky force-pushed on Apr 20, 2026
  46. Sjors referenced this in commit d42af54c56 on Apr 20, 2026
  47. Sjors referenced this in commit 7de24f776c on Apr 20, 2026
  48. Sjors referenced this in commit 2f549eb17d on Apr 20, 2026
  49. ryanofsky force-pushed on Apr 20, 2026
  50. ryanofsky force-pushed on Apr 21, 2026
  51. Sjors referenced this in commit baf5d5e571 on Apr 23, 2026
  52. Sjors referenced this in commit 36b415c486 on Apr 23, 2026
  53. Sjors referenced this in commit a20bfd86d2 on Apr 23, 2026
  54. DrahtBot added the label Needs rebase on May 22, 2026
  55. Kino1994 referenced this in commit df4bde1ae5 on Jun 28, 2026
  56. BigcoinBGC referenced this in commit f955c0b0ed on Jun 30, 2026
  57. ryanofsky force-pushed on Jul 22, 2026
  58. ryanofsky commented at 5:38 PM on July 22, 2026: contributor

    <!-- begin push-24 -->

    Rebased 13de58e1b5ec29d0db22073faa3d5eee36a03616 -> e99cb6170e6761f1678a7e8822fc7cd9a5606b2b (pr/ipc-win.23 -> pr/ipc-win.24, compare)<!-- end --> with many new fixes on top of base PRs https://github.com/bitcoin-core/libmultiprocess/pull/231, https://github.com/bitcoin-core/libmultiprocess/pull/317, https://github.com/bitcoin-core/libmultiprocess/pull/318, and #35084, also resolving conflicts with #35661 and #35684

    <!-- begin push-25 -->

    Updated e99cb6170e6761f1678a7e8822fc7cd9a5606b2b -> aa2892e82a334b6d2998937ffab27c2a6fa889dc (pr/ipc-win.24 -> pr/ipc-win.25, compare)<!-- end --> rebasing onto latest master and fixing lint errors (trailing newline in type-unordered-set.h, commit message format) https://github.com/bitcoin/bitcoin/actions/runs/29943010623/job/89001345876

    <!-- begin push-26 -->

    Rebased aa2892e82a334b6d2998937ffab27c2a6fa889dc -> 3177fbd5f2d553325f5414232d0be90aedec2aae (pr/ipc-win.25 -> pr/ipc-win.26, compare)<!-- end --> after #35084 to fix lint: duplicate #include <cerrno> in protocol.cpp https://github.com/bitcoin/bitcoin/actions/runs/29956699510/job/89047462559, also including upstream libmultiprocess updates

  59. DrahtBot removed the label Needs rebase on Jul 22, 2026
  60. ryanofsky force-pushed on Jul 22, 2026
  61. sedited referenced this in commit a9d181f2d3 on Jul 29, 2026
  62. DrahtBot added the label Needs rebase on Jul 29, 2026
  63. sync with libmultiprocess master
    commit e1dcc6eb1825c78772bf0ccf7eaee27c476c3dac
    5aa5b25a9a
  64. ipc: remove compatibility shim after libmultiprocess update e60c0a65d7
  65. Improve SpawnProcess API and documentation
    Remove recently introduced SpawnConnectInfo and SpawnConnectInfoToArgsFn type
    aliases since they are the same on all platforms and might obscure the fact
    that connect info should be treated as an opaque string.
    
    Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
    1a8dfe63e8
  66. util: Add Windows CommandLineFromArgv escaping function
    Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
    56773a7c53
  67. util: Add Windows support
    Add Windows-specific code to support building and running on Windows:
    
    - util.h: Guard ProcessId/SocketId/SocketError type aliases with WIN32
      ifdefs so they use SOCKET/uintptr_t on Windows and int on Unix.
      Add winsock2.h include on Windows.
    - util.cpp: Guard Unix-specific system headers with WIN32 ifdefs. Add
      Windows-specific includes (windows.h, winsock2.h). Guard MaxFd() with
      #ifndef WIN32. Add GetCurrentThreadId() branch in ThreadName(). Add
      win32Socketpair() forward-declare. Add Windows branch in SocketPair()
      using win32Socketpair(). Add CommandLineFromArgv() helper needed to
      construct CreateProcess command lines. Add Windows branch in
      SpawnProcess() using named pipes and WSADuplicateSocket to pass socket
      to child. Add Windows branch in StartSpawned() reading socket from
      named pipe. Add Windows branch in WaitProcess() using
      WaitForSingleObject/GetExitCodeProcess.
    - proxy.cpp: Add SocketOutputStream class on Windows (analogous to
      FdOutputStream but using SOCKET/send()). Add Windows branch in
      EventLoop constructor to create m_post_writer using SocketOutputStream.
    733fa15b2d
  68. util: make pthreads optional on Windows to enable MSVC builds
    Allow code to compile without pthreads available, as required for MSVC
    compatibility. Avoid unconditional POSIX calls (fork, posix_spawn,
    pthread_getname_np) by moving them into #ifndef WIN32 or HAVE_PTHREAD_*
    guards. When pthreads is available on Windows (detected via cmake
    HAVE_PTHREAD_* checks), still use it for thread name reporting since it
    provides useful information at low cost.
    
    Also add Threads::Threads as an explicit dependency of the multiprocess
    library. proxy.cpp directly uses thread_local, std::this_thread, and
    std::thread, and the dependency was previously satisfied only through
    transitive linkage from CapnProto::kj-async.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    be968699cb
  69. test: fix listen_tests to compile and run on Windows
    Replace POSIX-only headers (sys/socket.h, sys/un.h, unistd.h) with
    Windows equivalents (afunix.h via util.h), guard them with #ifdef WIN32,
    use TCP sockets instead of Unix sockets for Wine compatibility, replace
    mkdtemp/unlink/rmdir with std::filesystem equivalents, and use
    SocketId/SocketError types instead of int/-1 for socket handles so the
    file compiles and works with MinGW.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    dd3d9920cd
  70. test: Initialize Winsock in listen_tests.cpp on Windows
    listen_tests.cpp tests fail on Windows with:
      "expected m_fd != SocketError [18446744073709551615 != 18446744073709551615]"
    
    socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) returns INVALID_SOCKET because
    WSAStartup() has not been called. The mp library calls WSAStartup() only inside
    ConnectSocketToProcess(), which listen_tests.cpp never reaches β€” it creates
    sockets directly using the BSD API.
    
    Fix: add a static initializer that calls WSAStartup(MAKEWORD(2,2), ...) at
    program startup before any test runs.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    ed5df19cd0
  71. ci: add Windows cross-compilation config using MinGW and Wine
    - shell.nix: add `windows` parameter that selects pkgs.pkgsCross.mingwW64
      as the cross target; also change crossPkgs default from import<nixpkgs>{}
      to null (cleaner API). When windows=true, add native pkgs.capnproto to
      nativeBuildInputs so capnp/capnpc-c++ are in PATH for cmake code generation,
      and add wine64Packages.staging so ctest can run mptest.exe via wine.
      Change llvmBase to always use pkgs (native) instead of crossPkgs.
    
    - ci/configs/windows.bash: new config that cross-compiles with mingw,
      sets CMAKE_SYSTEM_NAME=Windows, CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
      (so cmake finds native capnp from PATH), CMAKE_CROSSCOMPILING_EMULATOR=wine
      (so ctest runs mptest.exe via wine), and sets MPGEN_PRE_BUILD=1.
    
    - ci/scripts/ci.sh: add MPGEN_PRE_BUILD support: when set, build native mpgen
      in $CI_DIR-native before the main cross build, then inject
      -DMPGEN_EXECUTABLE into CMAKE_ARGS. This is needed because cmake's
      add_custom_command does not use CMAKE_CROSSCOMPILING_EMULATOR, so the
      cross-compiled mpgen.exe cannot be used as a code generator directly.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    85dc748731
  72. cmake: Fix mpgen capnp tool path for vcpkg/Windows builds
    Error seen (MSVC native build):
      mpgen error: mp\util.cpp:332: failed: CreateProcessA(...): #2 The system
      cannot find the file specified.
    
    Problem: mpgen constructs capnp tool paths as capnp_PREFIX + "/bin/capnp"
    and capnp_PREFIX + "/bin/capnpc-c++". capnp_PREFIX is derived from the
    capnproto include directory parent, so on a vcpkg install it resolves to
    something like vcpkg_installed/x64-windows-release. But vcpkg installs
    executables under tools/capnproto/, not bin/, so the constructed path
    does not exist and CreateProcessA fails with ERROR_FILE_NOT_FOUND.
    
    Fix: pass the CAPNP_EXECUTABLE and CAPNPC_CXX_EXECUTABLE cmake variables
    from CapnProtoConfig.cmake as compile definitions to mpgen, and use them
    in gen.cpp instead of constructing paths from capnp_PREFIX.
    
    Using these cmake variables rather than reading the CapnProto::capnp_tool
    imported target IMPORTED_LOCATION directly is important: on Debian/Ubuntu,
    IMPORTED_LOCATION is set to a non-existent path due to a multiarch cmake
    packaging bug in libcapnp-dev (see
    https://github.com/bitcoin-core/libmultiprocess/issues/328). The cmake
    variables avoid this because CapnProtoConfig.cmake hardcodes the correct
    paths on Debian/Ubuntu, and on other platforms (including vcpkg) the
    variables hold generator expressions that target_compile_definitions
    evaluates correctly at generation time.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    a2865964af
  73. workaround: MinGW thread_local use-after-free in ThreadContext
    MinGW has a bug where thread_local destructors can run on already-freed memory
    at thread exit, causing heap corruption. MSVC builds and non-Windows platforms
    are unaffected.
    
    This caused intermittent STATUS_HEAP_CORRUPTION in MinGW CI builds when
    ~ThreadContext walked freed memory at thread exit. See CurrentThread() in
    proxy-io.h for the full explanation and upstream bug references.
    
    Workaround: change CurrentThread() accessor in MinGW builds to return a
    heap-allocated object held by a trivially-destructible pointer, skipping
    destructor registration at thread exit. The object is deliberately
    leaked.
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    a7c89f2527
  74. ipc: Windows + ENABLE_IPC build fixes
    Various small fixes for making ENABLE_IPC build work on windows.
    0a8fa2e1dd
  75. ipc: Fix MSVC build error C3861 in ipc_tests.cpp
    MSVC does not provide mkstemp (a POSIX function available in MinGW but
    not the MSVC runtime), causing:
    
      error C3861: 'mkstemp': identifier not found
      error C4996: 'close': The POSIX name for this item is deprecated
    
    Fix by using _mktemp_s on WIN32, which fills in the XXXXXX suffix
    in-place without creating a file (so no fd to close or file to remove).
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    1afc1542e0
  76. ipc: Fix windows socket error formatting 3f25dde832
  77. ipc: Fix Windows connect() error for missing Unix socket path
    On Windows, connect() to a Unix domain socket path that doesn't exist
    may return a WSA error code (e.g. WSAECONNREFUSED) that doesn't map to
    std::errc::no_such_file_or_directory via std::system_category(), unlike
    POSIX where ENOENT is returned. After a failed connect, explicitly check
    if the socket path exists and throw the expected error if not.
    
    Also add an fs::exists(path, ec) overload to fs.h: the file's existing
    exists() wrappers shadow std::filesystem::exists(path, error_code&),
    causing the new call in process.cpp to fail to compile under MinGW.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    9ca797046d
  78. ipc: Work around MinGW system_category() not mapping WSAECONNREFUSED
    When the IPC socket file exists but no node is listening, ProcessImpl::connect
    throws std::system_error(WSAECONNREFUSED, std::system_category()). MinGW
    libstdc++'s system_category() does not map Winsock error values to std::errc
    conditions, so the std::errc::connection_refused check in connectAddress fails
    to catch it, and bitcoin-cli -ipcconnect=auto throws CConnectionFailed instead
    of falling back to HTTP.
    
    This is a workaround: the proper fix is for ProcessImpl::connect to throw
    std::errc::connection_refused (using generic_category) rather than relying on
    system_category() to map Winsock codes. As a workaround, check for
    WSAECONNREFUSED explicitly in system_category on WIN32.
    
    MSVC's STL does map WSAECONNREFUSED to errc::connection_refused, so this
    check is redundant but harmless there.
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    f19d94d18c
  79. ipc: Skip MAX_DOUBLE static_assert on MSVC to fix C2131
    Bug: MSVC C2131 "expression did not evaluate to a constant" on line:
      static_assert(ipc::capnp::messages::MAX_DOUBLE == std::numeric_limits<double>::max())
    
    Root cause: Capnp floating-point constants can't be constexpr on MSVC.
    In capnp's generated-header-support.h, CAPNP_NON_INT_CONSTEXPR_DECL_INIT
    is defined as empty on MSVC (with the comment "MSVC doesn't understand
    floating-point constexpr yet"), so MAX_DOUBLE is declared as
    `static const double MAX_DOUBLE;` without an initializer in the header.
    A `const double` (unlike `const int`) is not a constant expression in C++,
    so it can't be used in static_assert on MSVC.
    
    Fix: Guard with `#if !defined(_MSC_VER) || defined(__clang__)` to match
    the exact condition capnp itself uses for the same limitation. The other
    three static_asserts in the same block use integer constants (MAX_MONEY,
    DEFAULT_BLOCK_RESERVED_WEIGHT, DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS)
    which don't have this MSVC limitation and continue to run.
    
    Alternatives considered:
    - Convert to a runtime BOOST_CHECK: would require moving into a test
      function, more invasive change.
    - Use std::numeric_limits<double>::max() literal: wouldn't help since
      MAX_DOUBLE is the non-constexpr side.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    e10143e71a
  80. util: Fix ExecVp on Windows to wait for child process and return exit code
    On Windows, _wexecvp (like all _exec* variants in the MSVC CRT) works by
    calling CreateProcess to start the child, then immediately calling
    ExitProcess(0) on the parent. Unlike POSIX execvp, which replaces the
    current process image so the parent's PID becomes the child, this means
    the child is orphaned from the original caller's perspective: the shell
    or test framework waiting on bitcoin.exe sees it exit with code 0 while
    bitcoind.exe continues running in the background independently.
    
    This breaks functional tests that invoke bitcoin.exe as a wrapper (e.g.
    `bitcoin node -regtest`) because the test process has no way to wait for
    the node to stop or retrieve its exit code.
    
    Fix by switching to _wspawnvp(_P_WAIT, ...), which spawns the child and
    blocks until it exits, then calling _exit() with the child's exit code.
    From the caller's perspective ExecVp still never returns on success (the
    parent process exits inside it), so call sites don't need to change. On
    error the existing errno / -1 return convention is preserved.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    4deb339fdf
  81. bitcoin: Fix IPC child process exec on Windows due to missing .exe extension
    _wspawnvp (the Windows implementation of ExecVp) requires the full filename
    including ".exe" when given an explicit path. Unlike POSIX execvp, it does
    not add the extension automatically.
    
    Also, msvcrt's _wspawnvp returns EINVAL (not ENOENT) when a file is not
    found β€” both when ".exe" is absent and when the file simply doesn't exist.
    ucrt returns ENOENT correctly. The allow_notfound check in try_exec only
    caught ENOENT, so on msvcrt it never fell through to the next search path.
    
    Without both fixes, all IPC functional tests failed immediately with:
      "execvp failed to execute '...\libexec\bitcoin-node': Invalid argument"
    
    Fix: append ".exe" when the path has no extension, and catch both ENOENT
    and EINVAL as "file not found" on WIN32.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    e96603197f
  82. test: Enable tool_bitcoin.py test on Windows
    Now that util::ExecVp on Windows uses _wspawnvp(_P_WAIT) instead of
    _wexecvp, the bitcoin wrapper process blocks until the child exits and
    Python can capture its stdout/stderr and exit code normally. Remove the
    Windows skip added in #33229.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    00e401d170
  83. test: Add Windows AF_UNIX asyncio support to ipc_util.py
    Python's asyncio doesn't support create_unix_connection() on Windows. Implement
    it by patching asyncio.ProactorEventLoop, using ctypes ws2_32.connect() and
    a non-blocking select() loop. See ipc_util.py for details on why each of those
    choices was necessary.
    
    Also: run blocking do_fn() callables in run_in_executor() in wait_and_do();
    unlink stale AF_UNIX socket files before node restart on Windows (test_node.py);
    set UNIX_PATH_MAX = 108 for Windows (test_node.py); catch OSError in the
    connection retry loop in interface_ipc_mining.py.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    4fbb30e81d
  84. test: Fix interface_ipc_cli.py error assertions on Windows
    On POSIX, connect() to a stopped node returns ECONNREFUSED and bitcoin-cli
    prints "error: Connection refused" followed by help text. On Windows the
    equivalent WSAECONNREFUSED produces a different OS error string without help
    text. Fix the expected string and switch to a prefix match since the Windows
    message has no appended help text.
    
    Also, on Windows, bitcoind removes the IPC socket file on clean shutdown
    (unlike Linux where the file persists and connect() returns ECONNREFUSED).
    A subsequent connect attempt sees ENOENT ("No such file or directory").
    Update test_cli() to accept a tuple of alternative prefixes and use a
    two-entry tuple for the Windows case covering both error strings.
    
    Also add diagnostic logging retained for future debugging: ipc_socket_path
    in both backslash and forward-slash forms with encoded byte length (to
    diagnose MinGW path format issues), socket file existence before each
    explicit-path test, and per-call debug logging of returncode and stdout.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    c3969ba7ab
  85. cmake: Add add_windows_exe_resources() for Windows exe manifest/version
    Add a helper function that generates a target-specific resource file from a
    template and links it along with an application manifest, replacing the static
    per-binary *-res.rc files previously used by non-GUI executables and the
    bitcoin-qt-res.rc previously used by GUI executables.
    
    The new add_windows_exe_resources(target description [ICON_DIR dir]) function
    in AddWindowsResources.cmake handles both GUI and non-GUI executables through a
    single cmake/windows-res.rc.in template. When ICON_DIR is provided, the
    function prepends icon declarations to the generated RC file and sets
    ProductName to the project name, matching the previous GUI-specific behavior.
    
    Also adds the missing add_windows_exe_resources() call for bitcoin-node, which
    previously had no resource section and caused the Windows CI manifest
    validation check (mt.exe -validate_manifest) to fail.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    ef732c3c2c
  86. ipc: enable by default in windows builds 4905a43ad6
  87. ci: Enable IPC in Windows cross-compiled CI jobs
    Remove -DENABLE_IPC=OFF from both win64 cross-build environment files
    and install pycapnp in the Windows cross-build test runner. The
    depends/ system already builds capnp for the MinGW target (NO_IPC is
    not set), so cmake will find it via the toolchain file. This lets
    interface_ipc.py and related tests run in the "Windows, test
    cross-built" CI jobs.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    f6f218a9d7
  88. ci: Install capnproto via vcpkg and pycapnp for Windows IPC support
    Add an "ipc" feature to vcpkg.json with capnproto as a dependency and
    include it in default-features, so the Windows native VS CI job installs
    capnproto when ENABLE_IPC is ON (the default). The fuzz build already
    uses VCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON, so it is unaffected.
    
    Also install pycapnp in ci-windows.py alongside pyzmq so the IPC
    functional tests (interface_ipc.py) have their required Python library,
    matching what every other CI platform already does.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    25f30934ca
  89. ci: Add missing ipc and tests vcpkg features to Windows fuzz build
    The fuzz build in ci-windows.py set -DVCPKG_MANIFEST_FEATURES=wallet but
    omitted ipc and tests, so vcpkg installed wallet dependencies but not
    capnproto. The build then failed with:
      "Cap'n Proto is required but was not found"
    
    Fix: extend VCPKG_MANIFEST_FEATURES to ipc;tests;wallet.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    47093d4ddf
  90. lint: Skip subtree check for src/ipc/libmultiprocess
    WARNING: DO NOT MERGE β€” this draft PR modifies the libmultiprocess
    subtree directly (intentionally, for testing purposes) which causes
    the subtree link check to fail. Disabling the check here to avoid
    masking unrelated lint failures while the PR is open for testing.
    
    Restore the omitted entry before any merge attempt.
    
    Note: removing src/ipc/libmultiprocess from get_subtrees() also removes
    it from get_pathspecs_default_excludes(), so all other lint checks
    (trailing newline, whitespace, etc.) now run on files in that directory
    as well. This is why src/ipc/libmultiprocess/include/mp/type-unordered-set.h
    needs a trailing newline added here even though it is not otherwise
    modified by this PR: it has always been missing the newline, but was
    previously hidden from the lint check by the subtree exclusion.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
    ca847b5aca
  91. ryanofsky force-pushed on Aug 1, 2026
  92. ryanofsky force-pushed on Aug 1, 2026
  93. DrahtBot removed the label Needs rebase on Aug 1, 2026
  94. DrahtBot removed the label CI failed on Aug 1, 2026
  95. DrahtBot added the label IPC on Aug 1, 2026
  96. Kino1994 referenced this in commit 33bd9b5d17 on Aug 2, 2026
  97. ryanofsky referenced this in commit abf127a314 on Aug 3, 2026
  98. Revert "workaround: MinGW thread_local use-after-free in ThreadContext"
    This reverts commit 789ba90418822714c8f9c09e7daab188c652f3e3.
    df56b1e606
  99. doc: Clarify that cygwin/msys2 are not tested/supported d2f1af6e10
  100. build: ci/doc win64-cross build via nix 7d2d7427d4
  101. ci: Fix $BASE_ROOT_DIR installation 59cae595f3
  102. ci_bla 399c8820ce
  103. DrahtBot added the label CI failed on Aug 4, 2026
  104. ryanofsky force-pushed on Aug 4, 2026
  105. DrahtBot removed the label CI failed on Aug 5, 2026
  106. DrahtBot added the label Needs rebase on Aug 7, 2026
  107. DrahtBot commented at 9:41 AM on August 7, 2026: contributor

    <!--cf906140f33d8803c4a75a2196329ecb-->

    πŸ™ This pull request conflicts with the target branch and needs rebase.


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-08-11 10:51 UTC

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