Skip to content

socketpair: use pipe2() on Apple OSes (requires SDK 27) - #23126

Closed
vszakats wants to merge 20 commits into
curl:masterfrom
vszakats:apple-pipe2
Closed

vszakats wants to merge 20 commits into
curl:masterfrom
vszakats:apple-pipe2

Conversation

@vszakats

@vszakats vszakats commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

pipe2() became available with Apple OS 27. It requires SDK 27 to build
for. Use it in curl unconditionally if targeting 27+, and use it
dynamically otherwise if the runtime environment supports it.

Also:

  • GHA/macos: enable the latter, common use-case in CI.
  • Tested all combinations in temporary CI runs.

Ref: https://developer.apple.com/documentation/system/filedescriptor/pipe(options:)

Reported-by: Alexander Köplinger
Ref: #21236 (comment)
Follow-up to ed27269 #23087
Follow-up to 1737e47 #21271 #21236


@vszakats vszakats added the appleOS specific to an Apple operating system label Sep 27, 2026
@vszakats
vszakats marked this pull request as draft September 27, 2026 21:14
@github-actions github-actions Bot added the CI Continuous Integration label Sep 27, 2026
@vszakats
vszakats requested a balanced review from Copilot September 28, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Platform guards omit several supported Apple targets, and the new preprocessor condition has incorrect grouping.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Enables pipe2() on Apple 27+ while retaining compatibility with older deployment targets.

Changes:

  • Adds compile-time and runtime availability handling for pipe2().
  • Adds Xcode 27 CI coverage targeting macOS 10.15.
File Description
lib/​socketpair.c Selects pipe2() when available.
lib/​curl_setup.h Enables HAVE_PIPE2 for Apple 27+ targets.
.github/​workflows/​macos.yml Adds Xcode 27 compatibility coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/curl_setup.h Resolved
Comment thread lib/socketpair.c Resolved
vszakats added a commit that referenced this pull request Sep 28, 2026
CMake tries and incorrectly fails to detect that GCC supports the
`-mmacosx-version-min=` option. This results in missing to automatically
forward the `CMAKE_OSX_DEPLOYMENT_TARGET` value.

Pass it manually as a workaround. Note that no GCC CI job is passing an
OS target version at the moment. The issue came up in a temporary test
job. Merge it just in case and to sync with curl-for-win.

As of current latest CMake 4.4.3:
```
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - no
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - no
```
(It also incorrectly fails to detect `-isysroot` support.)

The reason for the mis-undetection is that CMake is using the
`gcc -v --help` command to list available options, then checking for
exit code and the output for the strings, but the exit code is `1`, and
thus considered a failure, even though the strings are present.
The failure comes from:
```
ld: unknown options: --help collect2: error: ld returned
1 exit status
```

Turns out this was fixed in CMake master 4 days ago:
https://gitlab.kitware.com/cmake/cmake/-/commit/cc6bcefc6a686a0caea5ea7c4258f3070c4e2983
The bug was introduced in 4.4.0 via:
https://gitlab.kitware.com/cmake/cmake/-/commit/a1b5c0da877f78db3e5dfc8d9ec4f9dac21f7a5c

Cherry-picked from #23126

Closes #23131
@vszakats
vszakats force-pushed the apple-pipe2 branch 2 times, most recently from 2a1b7dc to dcc1d05 Compare September 28, 2026 09:06
@vszakats
vszakats marked this pull request as ready for review September 28, 2026 09:50
@vszakats
vszakats requested a balanced review from Copilot September 28, 2026 10:09
@vszakats vszakats changed the title socketpair: try using pipe2() on Apple OSes socketpair: use pipe2() on Apple OSes (requires SDK 27) Sep 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation and CI coverage are sound; only non-blocking stale build-system comments remain.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
Resolved since last review (1)

Comment thread lib/curl_setup.h Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Apple SDK and runtime availability behavior across multiple OS variants warrants final human validation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The platform guards, runtime fallback, and CI coverage consistently implement the intended compatibility behavior.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@vszakats vszakats closed this in c2a94ba Sep 28, 2026
@vszakats
vszakats deleted the apple-pipe2 branch September 28, 2026 10:46
vszakats added a commit that referenced this pull request Sep 28, 2026
Refs:
https://developer.apple.com/documentation/security/secpolicycreaterevocation(_:)?language=objc
https://developer.apple.com/documentation/security/sectrustevaluatewitherror(_:_:)?language=objc

Also:
- checked rest of Apple version guards if they support more OS flavors,
  and did not find anything missing, according to SDK 26 headers and
  online documentation.

Ref: #23126 (comment)

Closes #23149
vszakats pushed a commit that referenced this pull request Oct 16, 2026
Fixing (seen with clang, FreeBSD/Linux with no or disabled eventfd):
```
lib/socketpair.c:75:6: error: code will never be executed [-Wunreachable-code]
   75 |   if(pipe(socks))
      |      ^~~~
```

Follow-up to c2a94ba #23126

Closes #23437
vszakats added a commit to vszakats/curl that referenced this pull request Nov 3, 2026
To avoid a static linkage issue when using SDK 27 while targeting old
macOS versions (such as macOS 12). Maybe something to revisit in the
future when we either understood how to supports this now cleanly, or
enough time has passed that support can be enabled without causing
fallouts in real-world senarios.

Reported-by: Dan Rosser
Fixes curl#23650
Follow-up to ee3c438 curl#23437
Follow-up to c2a94ba curl#23126
vszakats added a commit that referenced this pull request Nov 4, 2026
To avoid a static linkage issue when using SDK 27 while targeting old
macOS versions (such as macOS 12). Maybe something to revisit in the
future when we either understood how to support this cleanly, or enough
time has passed that support can be enabled without causing fallouts in
real-world senarios.

Reported-by: Dan Rosser
Closes #23650
Follow-up to ee3c438 #23437
Follow-up to c2a94ba #23126

Closes #23717
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

appleOS specific to an Apple operating system CI Continuous Integration connecting & proxies

Development

Successfully merging this pull request may close these issues.

2 participants