Search code examples
clangvisual-studio-2022clang-clllvm-cov

lld-link: warning: Cannot use debug info for clang_rt.profile-i386.lib


For easily (hopefully) reproducing this issue, I've created a minimal Github repo.

I am trying to get test coverage reporting working using clang, llvm-cov, etc. At one point it was working and I either don't remember what I could've done to cause this issue or this issue just started appearing after a clean and rebuild. The error is:

$> DIR=build && cmake --build $DIR --config Debug --target example-coverage
[2/3] Linking CXX executable example.exe
lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingFile.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(WindowsMMap.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingBuffer.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingPlatformWindows.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingMerge.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfiling.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingWriter.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingMergeFile.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingValue.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingInternal.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingUtil.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingNameVar.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory

lld-link: warning: Cannot use debug info for 'clang_rt.profile-i386.lib(InstrProfilingBiasVar.c.obj)' [LNK4099]
>>> failed to load reference 'D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980\objr\x86\projects\compiler-rt\lib\profile\CMakeFiles\clang_rt.profile-i386.dir\clang_rt.profile-i386.pdb': no such file or directory
[3/3] Running coverage for example...
FAILED: CMakeFiles/example-coverage C:/src/build/CMakeFiles/example-coverage
cmd.exe /C "cd /D C:\src\build && "C:\Program Files\CMake\bin\cmake.exe" -E env LLVM_PROFILE_FILE=example.profraw C:/src/build/example.exe && "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin\llvm-profdata.exe" merge --sparse example.profraw --output example.profdata && "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin\llvm-cov.exe" report C:/src/build/example.exe -instr-profile=example.profraw && C:\Users\erich\AppData\Roaming\Python\Python38\Scripts\gcovr.exe --cobertura-pretty example-coverage.xml -r C:/src/"
1 + 2 = 3
warning: example.profraw: unsupported instrumentation profile format version
error: no profile can be merged
ninja: build stopped: subcommand failed.

I don't know how this path to a .pdb file on a D: drive occurs, but that path does not exist. I do however have a D: drive though.

After a few hours of searching, I have not found anything that has helped me figure this out. Where does this path to D:\a\_work\1\s\Intermediate\vctools\libasan.nativeproj__384798980... come from?

The other odd thing is that I'm specifying to link with clang_rt.profile-x86_64, not clang_rt.profile-i386.


Solution

  • This is an MSVC bug caused by them shipping the wrong version of clang_rt.profile-x86_64.lib. See https://developercommunity.visualstudio.com/t/MSVC-ships-with-old-version-of-clang_rt/10178093