build: avoid `pipe2` on Darwin (for now) #36218

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:macos_avoid_pipe2_atm changing 1 files +3 −1
  1. fanquake commented at 11:27 AM on September 10, 2026: member

    macOS 27 will support pipe2 at runtime, and Xcode 27 (and Command Line Tools) support it at compile time. This means a macOS < 27 system will detect support for pipe2, but then binaries will crash at runtime, as pipe2 is not available.

    Just avoid pipe2 on macOS for now, and continue using pipe. Note that the compilation also produces availability warnings:

    [415/1121] Building CXX object src/util/CMakeFiles/bitcoin_util.dir/tokenpipe.cpp.o
    ../src/util/tokenpipe.cpp:89:9: warning: 'pipe2' is only available on macOS 27.0 or newer [-Wunguarded-availability-new]
       89 |     if (pipe2(fds, O_CLOEXEC) != 0) {
          |         ^~~~~
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/unistd.h:219:9: note: 'pipe2' has been marked as being introduced in macOS 27.0 here, but the deployment target is macOS 26.0.0
      219 | int     pipe2(int [2], int);
          |         ^
    ../src/util/tokenpipe.cpp:89:9: note: enclose 'pipe2' in a __builtin_available check to silence this warning
       89 |     if (pipe2(fds, O_CLOEXEC) != 0) {
          |         ^~~~~
       90 |         return std::nullopt;
       91 |     }
    

    and this will need to be backported. When macOS 27 is released, we could change approach, but wanted to PR something straightforward (and backportable) for 32.x.

  2. build: avoid pipe2 on Darwin (for now)
    macOS 27 will support pipe2 at runtime, and Xcode 27 (and Command Line
    Tools) support it at compile time. This means a macOS < 27 system will
    detect support for pipe2, but then binaries will crash at runtime, as
    pipe2 is not available.
    
    Just avoid pipe2 on macOS for now, and continue using pipe. Note that
    the compilation also produces availability warnings, and this will need
    to be backported.
    9c7748315d
  3. fanquake added this to the milestone 32.0 on Sep 10, 2026
  4. fanquake added the label Needs backport (30.x) on Sep 10, 2026
  5. fanquake added the label Needs Backport (31.x) on Sep 10, 2026
  6. DrahtBot commented at 11:27 AM on September 10, 2026: 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/36218.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    ACK hebasto, willcl-ark

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  7. hebasto commented at 11:35 AM on September 10, 2026: member

    macOS 27 will support pipe2 at runtime, and Xcode 27 (and Command Line Tools) support it at compile time. This means a macOS < 27 system will detect support for pipe2...

    On macOS 26.5.2 with Xcode 27, pipe2 is not detected:

    
    -- Looking for pipe2
    -- Looking for pipe2 - not found
    
  8. fanquake commented at 11:45 AM on September 10, 2026: member

    pipe2 is not detected:

    Maybe there is some issue with your CI? pipe2 is certainly supported, i.e see https://github.com/python/cpython/issues/153711, https://github.com/Perl/perl5/issues/24804 etc.

  9. hebasto approved
  10. hebasto commented at 2:12 PM on September 10, 2026: member

    ACK 9c7748315d3124d1abe6a4606743cd9274beee66, tested on macOS Tahoe 26.6.2 with CLT 27.0:

    % xcode-select -p         
    /Library/Developer/CommandLineTools
    % xcrun --show-sdk-version
    27.0
    % xcrun --show-sdk-path   
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    

    Alternatively, a more general approach can be taken:

    --- a/cmake/introspection.cmake
    +++ b/cmake/introspection.cmake
    @@ -5,6 +5,8 @@
     include(CheckCXXSourceCompiles)
     include(CheckCXXSymbolExists)
     
    +set(CMAKE_REQUIRED_FLAGS ${working_compiler_werror_flag})
    +
     check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
     check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
     check_cxx_symbol_exists(fork "unistd.h" HAVE_DECL_FORK)
    
  11. willcl-ark approved
  12. willcl-ark commented at 3:58 PM on September 10, 2026: member

    ACK 9c7748315d3124d1abe6a4606743cd9274beee66

    Verified on MacOS 26.6.2 that master where it detects pipe2 segfaults:

    …/src/core/bitcoin on  master [$?⇕] via △ v4.4.2 : 🐍 (.venv) took 1m13s
    ₿ ./build/bin/bitcoind -datadir=/tmp/r1
    fish: Job 1, './build/bin/bitcoind -datadir=/…' terminated by signal SIGSEGV (Address boundary error)
    

    and this PR doesn't

    …os_avoid_pipe2_atm:refs/pull/36218/head [$?] via △ v4.4.2 : 🐍 (.venv)
    ₿ ./build/bin/bitcoind -datadir=/tmp/r2
    2026-09-10T15:56:50Z Bitcoin Core version v31.99.0-9c7748315d31 (release build)
    2026-09-10T15:56:50Z Log output may contain privacy-sensitive information. Be cautious when sharing logs.
    2026-09-10T15:56:50Z Using the 'arm_shani(1way;2way)' SHA256 implementation
    2026-09-10T15:56:50Z Default data directory /Users/will/Library/Application Support/Bitcoin
    2026-09-10T15:56:50Z Using data directory /tmp/r2
    
  13. fanquake commented at 4:01 PM on September 10, 2026: member

    Alternatively, a more general approach can be taken:

    Maybe we can investigate the general approach in future. I'm going to merge this now, so we can also backport, and somewhat front run the segfaults.

  14. fanquake merged this on Sep 10, 2026
  15. fanquake closed this on Sep 10, 2026

  16. fanquake deleted the branch on Sep 10, 2026
  17. fanquake removed the label Needs Backport (31.x) on Sep 10, 2026
  18. fanquake commented at 4:07 PM on September 10, 2026: member

    Backported to 31.x in #36221.

  19. fanquake referenced this in commit 78c86f07a7 on Sep 10, 2026
  20. fanquake removed the label Needs backport (30.x) on Sep 10, 2026
  21. DrahtBot added the label Build system on Sep 10, 2026
  22. fanquake commented at 4:31 PM on September 10, 2026: member

    Backported to 30.x in #36222.


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-09-15 17:51 UTC

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