clang-cl.exe compiler test fails with --coverage flag
Windows 10 Visual Studio 17 2022 Community Edition (bug also appears in Visual Studio 2019 Professional)
C:\Users\me\source\scratch\build>cmake -T ClangCL -D CMAKE_CXX_FLAGS="--coverage" ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is Clang 14.0.5 with MSVC-like command-line
-- The CXX compiler identification is Clang 14.0.5 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/x64/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/me/source/scratch/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_3dd07.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.3.1+2badb37d1 for .NET Framework
lld-link : error : undefined symbol: llvm_gcda_start_file [C:\Users\me\source\scratch\build\CMakeFiles\CMakeTmp\cmTC_3dd07.vcxproj]
>>> referenced by cmTC_3dd07.dir\Debug\testCXXCompiler.obj:(__llvm_gcov_writeout)
lld-link : error : undefined symbol: llvm_gcda_emit_function [C:\Users\me\source\scratch\build\CMakeFiles\CMakeTmp\cmTC_3dd07.vcxproj]
>>> referenced by cmTC_3dd07.dir\Debug\testCXXCompiler.obj:(__llvm_gcov_writeout)
lld-link : error : undefined symbol: llvm_gcda_emit_arcs [C:\Users\me\source\scratch\build\CMakeFiles\CMakeTmp\cmTC_3dd07.vcxproj]
>>> referenced by cmTC_3dd07.dir\Debug\testCXXCompiler.obj:(__llvm_gcov_writeout)
lld-link : error : undefined symbol: llvm_gcda_summary_info [C:\Users\me\source\scratch\build\CMakeFiles\CMakeTmp\cmTC_3dd07.vcxproj]
>>> referenced by cmTC_3dd07.dir\Debug\testCXXCompiler.obj:(__llvm_gcov_writeout)
lld-link : error : undefined symbol: llvm_gcda_end_file [C:\Users\me\source\scratch\build\CMakeFiles\CMakeTmp\cmTC_3dd07.vcxproj]
>>> referenced by cmTC_3dd07.dir\Debug\testCXXCompiler.obj:(__llvm_gcov_writeout)
lld-link : error : undefined symbol: llvm_gcov_init [C:\Users\me\source\scratch\build\CMakeFiles\CMakeTmp\cmTC_3dd07.vcxproj]
>>> referenced by cmTC_3dd07.dir\Debug\testCXXCompiler.obj:(__llvm_gcov_init)
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/me/source/scratch/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/me/source/scratch/build/CMakeFiles/CMakeError.log".
CMakeLists.txt
cmake_minimum_required (VERSION 3.20)
project (test1)
set (CMAKE_CXX_STANDARD 11)
add_executable(test1 main.cpp)
main.cpp
#include <iostream>
int main()
{
std::cout << "hello World" << std::endl;
return 0;
}
Possibly related to: https://bugs.llvm.org/show_bug.cgi?id=40877