Skip to content

Conversation

@snnn
Copy link

@snnn snnn commented Mar 4, 2024

To fix a build error:

src\arm\windows\init-by-logical-sys-info.c(309,17): Error C2065: 'cpuinfo_uarchs': undeclared identifier

In short, Arm64EC is a new application binary interface (ABI) for apps running on Arm devices with an x64 like ABI.

Reference:

  1. VC++ predefined-macros
  2. ARM64EC overview

@snnn snnn changed the title Update cpuinfo.h: add support for ARM64EC Update cpuinfo.h: add support for Windows ARM64EC Mar 4, 2024
#endif

#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
#if defined(__x86_64__) || defined(__x86_64) || (defined(_M_X64) && !defined(_M_ARM64EC)) || (defined(_M_AMD64) && !defined(_M_ARM64EC))
Copy link

Choose a reason for hiding this comment

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

I checked https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
MSVC architecture related defination is complex, suggest to add more comments.

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

It feels wrong to define CPUINFO_ARCH_X86_64 on ARM platform, please explain why this is necessary for Win ARM64

#endif

#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
#if defined(__x86_64__) || defined(__x86_64) || (defined(_M_X64) && !defined(_M_ARM64EC)) || (defined(_M_AMD64) && !defined(_M_ARM64EC))
Copy link
Contributor

Choose a reason for hiding this comment

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

Defining CPUINFO_ARCH_X86_64 for _M_ARM64EC feels wrong, please explain why this is needed

Copy link
Author

@snnn snnn May 9, 2024

Choose a reason for hiding this comment

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

_M_X64 Defined as the integer literal value 100 for compilations that target x64 processors or ARM64EC. So _M_X64 could be defined when the CPU is actually an ARM CPU.
Here the condition is defined(_M_X64) && !defined(_M_ARM64EC)) . When _M_ARM64EC is 1, the expression is false.

Copy link
Author

Choose a reason for hiding this comment

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

It feels wrong to define CPUINFO_ARCH_X86_64 on ARM platform,

It is the problem I am facing and fixing. _M_X64 is defined when the ABI is ARM64EC. So, without this change, CPUINFO_ARCH_X86_64 is defined when the target ABI is ARM64EC which is target for ARM64 CPUs.

@snnn
Copy link
Author

snnn commented Dec 20, 2024

@malfet , would you mind taking another look at this PR? We need this change to make https://github.com/microsoft/onnxruntime work for ARM64EC builds. A lot of Microsoft applications ship with ARM64EC ABI.

@snnn
Copy link
Author

snnn commented Nov 7, 2025

Close it since the is no update.

@snnn snnn closed this Nov 7, 2025
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.

4 participants