Skip to content

[rapidjson] Fix ARM64EC detection for _umul128 - #54321

Merged
Billy O'Neal (BillyONeal) merged 2 commits into
microsoft:masterfrom
rohanjain101:users/rohanjain/rapidjson-arm64ec
Oct 6, 2026
Merged

Billy O'Neal (BillyONeal) merged 2 commits into
microsoft:masterfrom
rohanjain101:users/rohanjain/rapidjson-arm64ec

Conversation

@rohanjain101

@rohanjain101 rohanjain101 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Backports Tencent/rapidjson#2399 (open), which fixes Tencent/rapidjson#2389.

include/rapidjson/internal/biginteger.h and include/rapidjson/internal/diyfp.h detect ARM64EC with _ARM64EC_. The compiler does not predefine that macro; <windows.h> defines it. The compiler-predefined macro is _M_ARM64EC (MSVC predefined macros). Unless <windows.h> is included first, ARM64EC builds (which also define _M_AMD64) take the x64 branch and use #pragma intrinsic(_umul128), which is not available on ARM64EC:

include\rapidjson\internal\biginteger.h(23): warning C4163: '_umul128': not available as an intrinsic function
include\rapidjson\internal\diyfp.h(29): warning C4163: '_umul128': not available as an intrinsic function

Consumers building with /WX fail. fix-arm64ec-umul128.patch replaces _ARM64EC_ with _M_ARM64EC in both headers, so the existing softintrin path is used regardless of include order. The patch is a no-op unless _M_ARM64EC is defined. It can be dropped once the port moves to a commit that includes Tencent/rapidjson#2399.

Tested:

  • vcpkg install rapidjson:x64-windows succeeds and the installed headers contain the patched guards.

  • A TU that parses and writes numbers with rapidjson::Document, compiled with MSVC 19.42.34439 cl /c /EHsc /W4 /std:c++17 /arm64EC: the warnings above appear before the patch. After the patch the TU builds cleanly, including with /WX. x64 and ARM64 are clean before and after.

  • Our CI builds rapidjson for ARM64EC (/arm64EC) with this same change applied, and builds the consumers that include these headers.

  • Changes comply with the maintainer guide.

  • SHA512s are updated for each updated download. (No downloads changed.)

  • The "supports" clause reflects platforms that may be fixed by this new version. (Unchanged.)

  • Any fixed CI baseline entries are removed from that file. (None.)

  • Any patches that are no longer applied are deleted from the port's directory. (None.)

  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.

  • Only one version is added to each modified port's versions file.

This change was prepared with help from GitHub Copilot.

Rohan Jain and others added 2 commits October 5, 2026 15:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 22:47

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.

Copilot review overview

🟢 Approval recommended

The focused fix is consistent across both affected headers, and all port-version metadata is coherent.

Review effort: Balanced
Findings: None

What changed in this PR

Backports RapidJSON’s ARM64EC detection fix so _umul128 uses the soft-intrinsic path correctly.

Changes:

  • Replaces _ARM64EC_ checks with compiler-defined _M_ARM64EC.
  • Applies the patch and increments the port version.
  • Updates baseline and version metadata.
File Description
ports/​rapidjson/​fix-arm64ec-umul128.patch Corrects ARM64EC guards in two headers.
ports/​rapidjson/​portfile.cmake Applies the upstream patch.
ports/​rapidjson/​vcpkg.json Increments the port version.
versions/​baseline.json Updates the baseline port version.
versions/​r-/​rapidjson.json Adds the verified port-version entry.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@BillyONeal Billy O'Neal (BillyONeal) 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.

Thanks for the fix and notifying upstream! One note from GPT 6.1 Sol:

  • F1 — Pre-existing installed-content licensing discrepancy. ports/rapidjson/vcpkg.json declares only MIT, but the installed msinttypes stdint.h and inttypes.h carry BSD-3-Clause terms; see include/rapidjson/msinttypes/stdint.h. The copyright file and header notices are retained; this is not missing attribution. A follow-up should accurately declare installed-content licensing and update the corresponding version metadata. MIT AND BSD-3-Clause is a straightforward expression, not the uniquely required solution. Retain the compatibility headers, and do not add JSON solely because the copyright text mentions noninstalled JSON_checker sources. This pre-existing issue need not block this focused compatibility PR.

EDIT: I think the right fix is probably to just not install those files at all because MSVC has come with stdint.h for more than 10 years now...

@BillyONeal
Billy O'Neal (BillyONeal) enabled auto-merge (squash) October 6, 2026 00:03
@BillyONeal
Billy O'Neal (BillyONeal) merged commit 434307d into microsoft:master Oct 6, 2026
@rohanjain101
rohanjain101 deleted the users/rohanjain/rapidjson-arm64ec branch October 7, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual Studio 2026 Windows build with ARM64EC warning _umul128 not available

3 participants