error C2164: '_mm_set_epi64x': intrinsic function not declared #1042
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#1042
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
xxhash v0.8.2
kernel-mode project using msvc2015
Debug/Release x86 configuration
msvc 2015 is relatively old at that point.
Any way you could test with an updated version of msvc ?
latest release is
v0.8.3. please update, it may that this issue or a similar enough one was fixed since v0.8.2.Hi @iaoedsz2008,
It seems strange situation.
Since it's compiled as
Release / x86(indicated at the upper left corner of the screen shot), MSVC 2015 must define_M_IX86:But it seems
_M_IX86is not defined for some reason.Therefore, it skips line 4862 (
_mm_load_si128) which is suitable for x86 target.And reaches line 4864. But since
_mm_set_epi64xis not declared, MSVC claims the error.Please check the following intrinsics lists:
_mm_set_epi64x._mm_set_epi64x.I think you should check your platform settings and predefined macros.
If you set
x86platform but MSVC 2015 doesn't define_M_IX86, it may mean something wrong in your build environment.edit: We have some test for MSVC x86 (Win32)
https://github.com/Cyan4973/xxHash/actions/runs/15399523908/job/43328545697#step:5:22
and it's compiled and tested (hopefully) well. But it doesn't mean our code and test are perfect. So could you check your
_MSC_VERand_M_IX86?For example, compile and run the following code will display them. (It may not suitable for kernel mode code, but I think you can understand it).
I've tested both in kernel mode and user mode, and found that the issue occurs at '_MSC_VER < 1900'. MSVC 2015 defines _MSC_VER as 1900, this should be changed to '_MSC_VER <= 1900'.
Also, the GitHub Actions link you shared uses MSVC 2019, not MSVC 2015.
Github Actions does not offer MSVC 2015 runners, hence the difficulties to test such an old version in CI.
The source file used in your second example seems to be from a different project than
xxhash, maybe for illustration.An equivalent segment from
xxhash.hwould be :https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h#L5276
As stated by the comment,
it was expecting MSVC 2015 to support
_mm_set_epi64x().But apparently, according to your tests, it doesn't.
So that's a change of expectation.
The proposed change itself is fairly simple, so it would be simple to do.
We just need to be sure that it's the right thing to do.
Since MSVC 2015 is not available on Github Actions,
I created a new test on
appveyor.ci, where it's still possible to launch MSVC 2015.Using latest
devbranch code,the test successfully completed
win32+AVX2build without any warning:https://ci.appveyor.com/project/YannCollet/xxhash/builds/52238159/job/s54st2b6d35wihtk#L114
Hence, so far, the test did not reproduce the reported issue.
After reviewing your test commands, I noticed the /arch:AVX2 flag. The current compilation error occurs in the XXH3_initCustomSecret_sse2 function, which remains unreferenced when AVX2 is enabled
There are actually both build modes, with and without AVX2.
On
x64, no-AVX2 impliesSSE2.But on
win32, maybe not.Follow up:
I added a test that checks compilation with Visual Studio 2015 for a win32 build with SSE2 enabled :
https://ci.appveyor.com/project/YannCollet/xxhash/builds/52238428/job/m5jst49n2ax2d70p#L91
The build does not fail.
It seems Microsoft's official x86 intrinsic table for MSVC 2022 is wrong. This table doesn't contain
_mm_set_epi64xbut actually MSVC 2022 supports it for x86.Because
%Program Files%/Microsoft Visual Studio/2022/.../MSVC/.../include/intrin.hcontains the following lineDetails of MSVC 2022 intrinsic headers
note that
_CHPE_ONLY_and_M_ARM64ECare symbols for Windows on ARM. So, we can ignore them for now.Hence as for MSVC2022,
xxhash.h's code and comment are true.Though we need to check actual intrinsic headers in MSVC2015. If it doesn't support
_mm_set_epi64xfor some reason, we should change our_MSC_VERcheck as @iaoedsz2008 proposed.I'm downloading MSVC2015 .iso image from archive, but it's painfully slow 😢
The updated appveyor CI test list is now part of the
devbranch,it contains a MSVC 2015 + win32 + SSE2 build test :
https://ci.appveyor.com/project/YannCollet/xxhash/builds/52238702/job/9buegshf84fhg4no#L91
and it builds fine, not even a warning.
I noticed that
AVX2_ENABLED=truein the environment variables. However, in another job where it's set to false, the configuration uses MSVC 2013 instead.https://ci.appveyor.com/project/YannCollet/xxhash/builds/52238702/job/9buegshf84fhg4no
https://ci.appveyor.com/project/YannCollet/xxhash/builds/52238702/job/xkmbnbgcgqsuqu49
After reviewing the AppVeyor logs again, I confirmed you were correct. I further investigated the issue locally and found that the kernel-mode header files are missing certain definitions.
I've checked genuine MSVC 2015 Community Edition:
I set its target to x86. Compiled and run the following code:
MSVC 2015 doesn't report any error and warning. Its output is:
Its
intrin.hcontains the following line:Details of MSVC 2015 intrinsic header
Note that
_M_CEE_PUREis deprecated symbol for /clr.Therefore as for MSVC 2015, we can use
_mm_set_epi64x()for both of x86 and x64 as @Cyan4973 and his new test proved.@iaoedsz2008, please check your build environment and
intrin.hagain. So far, I don't find any issue inintrin.hand our code.We replied almost simultaneously - please check my comments above.
files:
"C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\km\crt\emmintrin.h"
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\emmintrin.h"
@iaoedsz2008, great find!
So we need special clause for MSVC 2015 + kernel mode compilation (older Windows Driver Kit header).
1000% off-topic but I'm surprised Microsoft still supports Visual Studio 2015 officially for enterprise customers.
I've succeeded to reproduce
_mm_set_epi64x()issue with Microsoft Enterprise WDK for Visual Studio 2015 -EnterpriseWDK_rs1_release_14393_20160715-1616.EnterpriseWDK_rs1_release_14393_20160715-1616.zipcdto above extracted directory.main.cppIf we enable the
// Workaroundline,main.exe's exitcode is20as expected.main.cpp
Wow, thank you for taking the time to reproduce this issue!
Great investigation @t-mat !
In conclusion, it implies that the proposed fix is to disable
_mm_set_epi64x()for all versions ofMSVC 2015because one of them doesn't ship this symbol?It feels like a pity, but on the other hand, I don't think it matters so much, and it's likely preferable to reduce noise.