Merge bitcoin/bitcoin#36218: build: avoid pipe2 on Darwin (for now)

9c7748315d build: avoid pipe2 on Darwin (for now) (fanquake)

Pull request description:

  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:
  ```bash
  [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`.

ACKs for top commit:
  hebasto:
    ACK 9c7748315d, tested on macOS Tahoe 26.6.2 with CLT 27.0:
  willcl-ark:
    ACK 9c7748315d

Tree-SHA512: 5aa97b93e7038344a5118eef2660b101e443eff52ab94fb4b8eb88ec4e09b8a3000b9b4e2aa59b406d8acbb6d9add8f0c3a2dd5e1db53b1dfc97a0fcbaf48995
This commit is contained in:
merge-script
2026-09-10 17:03:21 +01:00

View File

@@ -8,7 +8,9 @@ include(CheckCXXSymbolExists)
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)
check_cxx_symbol_exists(pipe2 "unistd.h" HAVE_DECL_PIPE2)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
check_cxx_symbol_exists(pipe2 "unistd.h" HAVE_DECL_PIPE2)
endif()
check_cxx_symbol_exists(setsid "unistd.h" HAVE_DECL_SETSID)
if(NOT WIN32)