zstd
zstd copied to clipboard
Can not build with clang-cl from LLVM 13.0.0 and MSVC v16.11.9
Describe the bug This is a build issue that has come up after upgrading Visual Studio to v16.11.9. The build still worked with LLVM 13.0.0 and MSVC v16.11.7, but fails after the upgrade of MSVC.
Also the build seems to work when setting -march=native instead of -march=skylake.
We use the following settings:
CFLAGS='/D_ITERATOR_DEBUG_LEVEL=0 /DWINVER=0x0A00 /D_WIN32_WINNT=0x0A00 /DDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /MDd /Z7 -march=skylake'
CXXFLAGS='/D_ITERATOR_DEBUG_LEVEL=0 /DWINVER=0x0A00 /D_WIN32_WINNT=0x0A00 /DDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /std:c++20 /MDd /Z7 -march=skylake'
LDFLAGS='/DEBUG:FULL'
CMAKE_FLAGS='-GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=20 -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_POLICY_DEFAULT_CMP0121=NEW -DCMAKE_POLICY_DEFAULT_CMP0115=NEW -DCMAKE_POLICY_DEFAULT_CMP0108=NEW -DCMAKE_POLICY_DEFAULT_CMP0107=NEW -DCMAKE_POLICY_DEFAULT_CMP0103=NEW -DCMAKE_POLICY_DEFAULT_CMP0100=NEW -DCMAKE_CUDA_COMPILER=nvcc.exe -DZSTD_BUILD_STATIC=OFF -DZSTD_BUILD_SHARED=ON -DZSTD_PROGRAMS_LINK_SHARED=ON -DZSTD_BUILD_TESTS=OFF -DZSTD_LEGACY_SUPPORT=OFF -DZSTD_MULTITHREAD_SUPPORT=ON -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_CONTRIB=OFF'
Here is the error I get:
[19/31] C:\BDA\ci\LLVM-13.0.0\bin\clang-cl.exe -DXXH_NAMESPACE=ZSTD_ -DZSTD_DLL_EXPORT=1 -DZSTD_HEAPMODE=0 -DZSTD_LEGACY_SUPPORT=0 -DZSTD_MULTITHREAD -D_CONSOLE -D_CRT_SECURE_NO_WARNINGS -Dlibzstd_shared_EXPORTS -IC:/data/ci-tmp-C10Sk32c192930139c1300/Debug/zstd/lib -IC:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/lib -IC:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/../../lib -IC:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/../../lib/common /D_ITERATOR_DEBUG_LEVEL=0 /DWINVER=0x0A00 /D_WIN32_WINNT=0x0A00 /DDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /MDd /Z7 -march=skylake /DWIN32 /D_WINDOWS /W3 /clang:-Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -DDEBUGLEVEL=1 /MDd /Zi /Ob0 /Od /RTC1 -DZSTD_DISABLE_ASM /showIncludes /Folib/CMakeFiles/libzstd_shared.dir/C_/BDA/bld/XTJyb_7r/0/zstd/lib/common/pool.c.obj /Fdlib\CMakeFiles\libzstd_shared.dir\ -c -- C:/BDA/bld/XTJyb_7r/0/zstd/lib/common/pool.c
FAILED: lib/CMakeFiles/libzstd_shared.dir/C_/BDA/bld/XTJyb_7r/0/zstd/lib/common/pool.c.obj
C:\BDA\ci\LLVM-13.0.0\bin\clang-cl.exe -DXXH_NAMESPACE=ZSTD_ -DZSTD_DLL_EXPORT=1 -DZSTD_HEAPMODE=0 -DZSTD_LEGACY_SUPPORT=0 -DZSTD_MULTITHREAD -D_CONSOLE -D_CRT_SECURE_NO_WARNINGS -Dlibzstd_shared_EXPORTS -IC:/data/ci-tmp-C10Sk32c192930139c1300/Debug/zstd/lib -IC:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/lib -IC:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/../../lib -IC:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/../../lib/common /D_ITERATOR_DEBUG_LEVEL=0 /DWINVER=0x0A00 /D_WIN32_WINNT=0x0A00 /DDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /MDd /Z7 -march=skylake /DWIN32 /D_WINDOWS /W3 /clang:-Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -DDEBUGLEVEL=1 /MDd /Zi /Ob0 /Od /RTC1 -DZSTD_DISABLE_ASM /showIncludes /Folib/CMakeFiles/libzstd_shared.dir/C_/BDA/bld/XTJyb_7r/0/zstd/lib/common/pool.c.obj /Fdlib\CMakeFiles\libzstd_shared.dir\ -c -- C:/BDA/bld/XTJyb_7r/0/zstd/lib/common/pool.c
In file included from C:/BDA/bld/XTJyb_7r/0/zstd/lib/common/pool.c:26:
In file included from C:/BDA/bld/XTJyb_7r/0/zstd/build/cmake/../../lib/common/threading.h:44:
In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\um\windows.h:171:
In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\shared\windef.h:24:
In file included from C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\shared\minwindef.h:182:
C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\um\winnt.h(3501,1): error: conflicting types for '_m_prefetchw'
_m_prefetchw (
^
C:\BDA\ci\LLVM-13.0.0\lib\clang\13.0.0\include\prfchwintrin.h(50,1): note: previous definition is here
_m_prefetchw(void *__P)
^
1 error generated.
To Reproduce Steps to reproduce the behavior:
- Check out e47e674c (v1.5.2)
- Set environment variables
CFLAGSandCXXFLAGSlike above - Install Visual Studio v16.11.9 and LLVM 13.0.0 on Windows 10
- Make sure LLVM is in
PATH - Configure cmake with above
CMAKE_FLAGSand run the build - See error
Desktop (please complete the following information):
- OS: Windows 10 (current latest with all updates)
- Version e47e674c (v1.5.2)
- Compiler clang-cl
- Flags see above
- Build system Ninja
The same error happens with LLVM 13.0.1-rc3.
I can confirm that the error goes away when the compiler flag -march=skylake is removed, or when it is replaced by -march=native or -march=haswell.
The description of the issue seems to correspond to a Visual Studio issue,
hopefully a temporary one.
For some reasons, there are duplicated symbols in compiler-provided libraries when this new version of Visual Studio is combined with clang.
They may have not detected this problem because it's outside of their test coverage.
It would be useful to report this issue to the Visual Studio support team, as it may help them fix this issue into their next release.
In the meantime, I believe there is nothing that should be altered within zstd source code to cope with this transient situation. The work-around you have already discovered (use --march=native) looks to me a pretty reasonable temporary solution.
Solved as of zstd v1.5.2 with ClangCl from LLVM 15.0.6 and MSVC v17.04