VS: 17.9.5 ClangCL toolset targeting x64 fails on ARM64 host
Until recently it was possible to configure any given CMake project to make use of the LLVM toolchain available in a Visual Studio installation by providing a specific toolset parameter:
cmake -S . -B build_clang-cl -G 'Visual Studio 17 2022' -A x64 -T clangcl
This worked as expected, generating a Visual Studio project targeting x64 architecture with the LLVM toolchain.
With CMake 3.29 and Visual Studio 17.9.5, the same invocation fails:
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
Omitting the generator and target platform will succeed however (cmake -S . -B build_clang-cl -T clangCL
):
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is Clang 17.0.3 with MSVC-like command-line
-- The CXX compiler identification is Clang 17.0.3 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/ARM64/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/ARM64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (3.3s)
-- Generating done (0.0s)
-- Build files have been written to: <...>/cmake-cpp-test/build_clang-cl
Unfortunately providing a target architecture will break this again, so it only works when building for the host architecture (ARM64 in my case).
The original invocation worked without issue until recently, but I haven't been able to figure out if this is an issue with CMake 3.29, Visual Studio 17.9.5, or both.
Notice that the LLVM toolset is installed on the system (as can be seen by the invocation without generator and architecture) and is available for x64 as well:
CommandType Name Version Source
----------- ---- ------- ------
Application clang-cl.exe 0.0.0.0 C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\bin\clang-cl.exe
CommandType Name Version Source
----------- ---- ------- ------
Application cl.exe 14.39.335… C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe
(This is the output of get-command
with clang-cl
and cl
respectively in an x64 dev shell).
Trying to compile the generated test project CompilerIdCXX.vcxproj
in Visual Studio directly then yields the following error(s):
msvcrtd.lib(exe_main.obj): machine type x64 conflicts with arm64 | CompilerIdCXX | C:\Users\patthemav\GitHub\cmake-cpp-test\build_clang-cl\CMakeFiles\3.29.0\CompilerIdCXX\lld-link
Which suggests that something is broken with finding architecture-specific LLVM toolsets.