fix Windows ARM64 build and detect ARM64EC as ARM64 #389
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR solves two issues when building for Windows on ARM:
blake3_dispatch.c
due to a missing include.The first issue manifests as follows. You can repro in an ARM64 Visual Studio Developer Command Prompt:
The second issue is more subtle. When building for the ARM64EC ABI, the compiler defines the
_M_X64
macro and not the_M_ARM64
macro, to make incremental porting existing X64 Windows code to ARM easier.This means that the BLAKE3 library was detecting ARM64EC as AMD64 and defining
IS_X86
andIS_X86_64
. This causes the library to compile in the SSE2 and SSE4.1 vector implementations of the algorithm instead of NEON, which amazingly does work even when building for Windows on ARM64, because Windows provides an emulated implementation of Intel SIMD instruction sets up to SSE4.2 in thesoftintrin.lib
library. The end result is not ideal though, because it mixes native ARM64 code for the portable parts of the algorithm with emulated Intel SIMD intrinsics.The second change is thus to make the CPU architecture detection in
blake3_impl.h
aware of the ARM64EC ABI so it can choose the NEON implementation.