Skip to content

GH-50987: [C++] Fix builds with the macOS 11.3 SDK - #50997

Merged
pitrou merged 2 commits into
apache:mainfrom
1fanwang:gh-50987-std-identity-macos-sdk
Sep 7, 2026
Merged

pitrou merged 2 commits into
apache:mainfrom
1fanwang:gh-50987-std-identity-macos-sdk

Conversation

@1fanwang

@1fanwang 1fanwang commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

The R macOS CRAN nightly stopped building Arrow C++ after #50785. It uses the macOS
11.3 SDK to match CRAN's builder, and fails on one file with "no template named
'identity' in namespace 'std'" at lines 230, 307 and 323. That SDK's libc++ predates
the standard identity functor, which arrived in libc++ 12 with the macOS 12 SDK, so
the name is absent whatever standard is selected. The cran-m1 job uses a current SDK
and passes, which is why only this builder is red.

Before this change the R package cannot be built on CRAN's macOS builder. After it,
the file compiles there.

Closes #50987.

What changes are included in this PR?

That file is the only one in the C++ tree naming the missing symbol, at the three
sites above. It now uses a small equivalent functor in the same translation unit, so
the compile-time fast path that skips per-bit work still matches and the bitmap copy
keeps its memcpy shortcut. The bitwise-not functor is older and untouched. No
behavior or API change.

Are these changes tested?

Reproduced on a real macOS 11.3 SDK, whose internal identity helper sits at the same
header line cited in the CI log, confirming the same libc++. From a checkout of this
branch:

$ curl -fsSL https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz | tar -xJ -C /tmp
$ SDK=/tmp/MacOSX11.3.sdk
$ F=cpp/src/arrow/util/bitmap_ops.cc
$ clang++ -std=gnu++20 -isysroot "$SDK" -I cpp/src -fsyntax-only "$F" && echo ok
ok
$ git checkout upstream/main -- "$F"
$ clang++ -std=gnu++20 -isysroot "$SDK" -I cpp/src -fsyntax-only "$F"
230:57: error: no template named 'identity' in namespace 'std'
307:23: error: no template named 'identity' in namespace 'std'
323:30: error: no template named 'identity' in namespace 'std'
6 errors generated.

Behavior is unchanged. The bit utility test target builds and its bitmap copy,
invert and reverse cases pass, covering both branches of the mapping helper: the
byte-aligned memcpy path and the bit-offset path that calls the functor.

[  PASSED  ] 4 tests.

The local run compiles the failing translation unit, not the full R build, which the
CRAN job here covers.

Are there any user-facing changes?

No.

std::identity reached libc++ only in version 12, which ships with the
macOS 12 SDK. The R macOS CRAN nightly builds against the 11.3 SDK and
fails with "no template named 'identity' in namespace 'std'".

Replace it with a local functor so the is_same_v fast path in
MapBitmapUnary keeps matching.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI lite review requested due to automatic review settings August 25, 2026 16:41
@1fanwang
1fanwang requested a review from pitrou as a code owner August 25, 2026 16:41
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50987 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes Arrow C++ builds against older macOS SDK/libc++ versions (notably macOS 11.3) by removing the dependency on std::identity in bitmap_ops.cc, while preserving the existing fast memcpy-based bitmap copy path.

Changes:

  • Add a local Identity functor (equivalent to std::identity) and include <utility> for std::forward.
  • Replace std::identity usages with the local Identity in MapBitmapUnary call sites and its compile-time fast-path check.

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

@github-actions github-actions Bot added the awaiting review Awaiting review label Aug 25, 2026
@thisisnic

Copy link
Copy Markdown
Member

@github-actions crossbow submit test-r-macos-as-cran

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Revision: c52b428

Submitted crossbow builds: ursacomputing/crossbow @ actions-1b11590188

Task Status
test-r-macos-as-cran GitHub Actions

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is localized and mechanical (replacing std::identity with an equivalent local functor) and preserves the existing optimized code paths.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@thisisnic thisisnic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CI failures unrelated - cc @pitrou - is this OK to merge?

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Sep 7, 2026
@pitrou

pitrou commented Sep 7, 2026

Copy link
Copy Markdown
Member

LGTM, thank you @thisisnic and @1fanwang

@pitrou
pitrou merged commit 89b3a60 into apache:main Sep 7, 2026
64 of 66 checks passed
@pitrou pitrou removed the awaiting merge Awaiting merge label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++] std::identity in bitmap_ops.cc breaks build with macOS 11.3 SDK

4 participants