Skip to content

Fix build when targeting Arm64EC using Clang #2012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025

Conversation

dpaoliello
Copy link
Contributor

These fix building benchmark targeting Arm64EC Windows when using Clang (i.e., with Clang's preprocessor defines rather than the MSVC-compatibility defines).

Copied from llvm/llvm-project#150068

Copy link

google-cla bot commented Jul 22, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -79,7 +79,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
int64_t ret;
__asm__ volatile("rdtsc" : "=A"(ret));
return ret;
#elif defined(__x86_64__) || defined(__amd64__)
#elif (defined(__x86_64__) || defined(__amd64__)) && !defined(__arm64ec__)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is __x86_64__ or __amd64__ really defined when __arm64ec__ is defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes:
https://github.com/llvm/llvm-project/blob/b13bca7387a7aad6eaf3fa1c55bd06fe091f65ed/clang/lib/Basic/Targets/AArch64.cpp#L404-L414

You should think of Arm64EC as "x64 code running on an Arm64 machine with a weird instruction set". So, by default, it needs to use the x64 layout for objects to be compatible with any real x64 code that is linked into the same binary or called across binaries.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but ARM is ARM, it is not Intel arch, which x86_64 and AMD64 are.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a code comment to explicitly state this, err, very interesting design decision...

Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

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

Thanks!

@LebedevRI LebedevRI merged commit 12ff2c2 into google:main Jul 31, 2025
84 checks passed
@LebedevRI
Copy link
Collaborator

@dpaoliello thank you!

@dpaoliello dpaoliello deleted the arm64ec branch July 31, 2025 16:29
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.

2 participants