Skip to content

Failing compilation errors gets swallowed when running msbuild #2661

@ak-slongchamps

Description

@ak-slongchamps

Note that I inject sccache.exe through the CLToolPath and CLToolExe properties in the MSBuild UI.
When using MSBuild, it seems sccache is unable to forward the errors from the compiler.

I added a simple invalid #pragma error for test purposes:

  1. When I specify the cl.exe of my usual Visual Studio, I get errors logged as expected:
C:\code\File.cpp(21,9): error C2220: the following warning is treated as an error 
  (compiling source file 'File.cpp')

C:\code\File.cpp(21,9): warning C4068: unknown pragma 'error' [C:\code\MyProject.vcxproj]
  (compiling source file 'File.cpp')
  1. When I pass sccache (which is renamed to cl.exe), I get the following instead:
Build FAILED.

C:\VS2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(617,5): error MSB6006: "cl.exe" exited with code 2. [C:\code\MyProject.vcxproj]
    0 Warning(s)
    1 Error(s)

Using SCCACHE_LOG=debug shows nothing, and there is no error in the file I pass to SCCACHE_ERROR_LOG.

When I run just the compilation command by itself, I do get the output, but it's as though then output is not forwarded in the same way as raw cl.exe, leading to no output. Interestingly though, the debug output of sccache itself is printed by msbuild when I set SCCACHE_ERROR_LOG=debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions