mozilla / sccache

Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.
Apache License 2.0
5.84k stars 550 forks source link

Automatically detect compiler when not specified #1063

Open SunBlack opened 3 years ago

SunBlack commented 3 years ago

The readme recommend to use CMAKE_<LANG>_COMPILER_LAUNCHER to use sccache. But this command is only processed in case you are using Makefile or Ninja.

For MSVC there is another way, which worked with clcache (which is not maintained anymore):

call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
msbuild.exe myproject.sln /p:Configuration=Release /p:CLToolExe=clcache.exe /p:CLToolPath="C:/Program Files/Python38/Scripts"

When using sccache we could use:

call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
msbuild.exe myproject.sln /p:Configuration=Release /p:CLToolExe=sccache.exe

But this lead to an invalid call:

C:\Users\myuser\scoop\shims\sccache.exe /c /I...
sccache : error : failed to execute compile [C:\path_to.vcxproj]
  sccache: caused by: cannot find binary path

Correct would be

C:\Users\myuser\scoop\shims\sccache.exe cl.exe /c /I...
sccache : error : failed to execute compile [C:\path_to.vcxproj]
  sccache: caused by: cannot find binary path

To bypass this I tried /p:CLToolExe="sccache.exe cl.exe", but this leads to:

error MSB6004: The specified task executable location "C:/Users/myuser/scoop/shims\sccache.exe cl.exe" is invalid.

So it seems there is currently no way to use this way, But I think this could be easily fixed when sccache automatically detects the compiler from the path.

ColoredCarrot commented 2 months ago

Just stumbled upon this (3 years later, hehe). @SunBlack did you end up finding a workaround?

SunBlack commented 2 months ago

Yes, by using ccache instead of sccache, because unfortunately here is no progress. Since ccache has been able to cache MSVC builds since version 4.6 (MSVC 2017 does not work for us, but 2019 and 2022 do if you have not activated static code analysis) and ccache can also be configured with a Redis backend, for example, I currently see no reason why you should use sccache if you only use C/C++.<

ColoredCarrot commented 2 months ago

Gotcha, thank you. That's unfortunate. ccache has been working excellently for us thus far (except for PCH), so we'll just stick with it and ditch sccache.

Thank you again for the quick answer!