Skip to content

GH-51690: [C++] Don't define __SSE2__ globally with MSVC - #53952

Open
kou wants to merge 1 commit into
apache:mainfrom
kou:gh-51690-msvc-sse-definitions
Open

kou wants to merge 1 commit into
apache:mainfrom
kou:gh-51690-msvc-sse-definitions

Conversation

@kou

@kou kou commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

simdjson >= 5 uses GCC builtins such as __builtin_ctz when __SSE2__ is defined. So we can't build Apache Arrow C++ with simdjson >= 5 and MSVC because we define __SSE2__ globally.

What changes are included in this PR?

We don't need to define __SSE2__ because xsimd detects SSE2 by _M_X64 with MSVC.

We still need to define __SSE4_1__/__SSE4_2__ for xsimd because MSVC doesn't define them even with /arch:SSE4.2. But we define them only where SSE4.2 is enabled. So they are no longer defined with ARROW_SIMD_LEVEL=NONE.

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

simdjson >= 5 uses GCC builtins such as __builtin_ctz when __SSE2__ is
defined. So we can't build Apache Arrow C++ with simdjson >= 5 and
MSVC because we define __SSE2__ globally.

We don't need to define __SSE2__ because xsimd detects SSE2 by _M_X64
with MSVC.

We still need to define __SSE4_1__/__SSE4_2__ for xsimd because MSVC
doesn't define them even with /arch:SSE4.2. But we define them only
where SSE4.2 is enabled. So they are no longer defined with
ARROW_SIMD_LEVEL=NONE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 07:48
@kou

kou commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@github-actions crossbow submit verify-rc-source-windows

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #51690 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.

🟢 Approval recommended

Flag consumers support the updated list, xsimd feature detection remains intact, and no blocking issues were identified.

0 open findings

What changed in this PR

Fixes the MSVC build failure with simdjson 5+ by removing conflicting global SIMD definitions while preserving xsimd support.

Changes:

  • Removes the global __SSE2__ definition.
  • Scopes SSE4.x definitions to SSE4.2-enabled compilation.
  • Joins the expanded flag list when constructing common compiler flags.
File Description
cpp/​cmake_modules/​SetupCxxFlags.cmake Scopes MSVC SIMD definitions and updates compiler flag assembly.

🧠 Review effort: Balanced


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

@github-actions

Copy link
Copy Markdown

Revision: 342b329

Submitted crossbow builds: ursacomputing/crossbow @ actions-574d24d44c

Task Status
verify-rc-source-windows GitHub Actions

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants