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.85k stars 552 forks source link

msvc + sccache: "Failed to detect showIncludes prefix" #909

Open autoantwort opened 3 years ago

autoantwort commented 3 years ago

I have build the current master branch and "installed" is like described in Issue #107 (penultimate comment). But when I try to build the project inside Visual Studio I get the output:

1>------ Build started: Project: lib, Configuration: Debug Win32 ------
1>sccache : error : failed to execute compile
1>  sccache: caused by: Compiler not supported: "Failed to detect showIncludes prefix"
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
autoantwort commented 3 years ago

I have executed the test manally and the output was:

xx@xx MSYS /c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/test
$ cl.exe test.cpp -nologo -showIncludes -c -Fonul -I.
test.cpp
Hinweis: Einlesen der Datei: c:\program files (x86)\microsoft visual studio 14.0\vc\bin\test\test.h
autoantwort commented 3 years ago

With debug messages enabled I get the following output:

13>  [2020-12-16T19:44:11Z DEBUG sccache::config] Attempting to read config file at "C:\\Users\\xx\\AppData\\Roaming\\Mozilla\\sccache\\config\\config"
13>  [2020-12-16T19:44:11Z DEBUG sccache::config] Couldn't open config file: Das System kann den angegebenen Pfad nicht finden. (os error 3)
13>  [2020-12-16T19:44:11Z DEBUG sccache::commands] Server sent UnsupportedCompiler: "failed to detect showIncludes prefix with output: Tracker.exe: Response file C:\\Users\\xx\\AppData\\Local\\Temp\\tmp9625afad50c140a7858f1025888972c1.tmp not found.\r\nTracker.exe: Response file C:\\Users\\xx\\AppData\\Local\\Temp\\tmp9625afad50c140a7858f1025888972c1.tmp not found.\r\nTracker.exe: Response file C:\\Users\\xx\\AppData\\Local\\Temp\\tmp9625afad50c140a7858f1025888972c1.tmp not found.\r\n"
autoantwort commented 3 years ago

I tried to print out the exe name, but I failed with the following:

debug!("cl.exe: {}", exe.to_str().expect("error"));
glandium commented 3 years ago

but I failed with the following:

Can you give more details how you failed?

13> [2020-12-16T19:44:11Z DEBUG sccache::commands] Server sent UnsupportedCompiler: "failed to detect showIncludes prefix with output: Tracker.exe: Response file C:\\Users\\xx\\AppData\\Local\\Temp\\tmp9625afad50c140a7858f1025888972c1.tmp not found.\r\nTracker.exe: Response file C:\\Users\\xx\\AppData\\Local\\Temp\\tmp9625afad50c140a7858f1025888972c1.tmp not found.\r\nTracker.exe: Response file C:\\Users\\xx\\AppData\\Local\\Temp\\tmp9625afad50c140a7858f1025888972c1.tmp not found.\r\n"

What is Tracker.exe?

autoantwort commented 3 years ago

Can you give more details how you failed?

From #107:

sccache does support this already--if you copy the sccache.exe binary to cl.exe it will run as if you ran sccache.exe cl.exe, and use the next cl.exe available in your path.

It might be possible to work around this for one of the four compilers by moving the real cl.exe to a subdirectory and adding that to the path, but I'm not sure what else that would break (e.g. the real compiler may be expecting to be in a certain directory).

I have done this. I have moved dir/cl.exe to dir/test/cl.exe where dir is C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin. Then I copied the sccache.exe to dir and renamed it to cl.exe. Then I added dir/test and dir to the PATH.

In Visual Studio I right clicked the project and selected "Build"

What is Tracker.exe?

I don't know what Visual Studio is calling exactly when building the project.

funous commented 3 years ago

I have seen a similar issue. I suspect it's because my username (or rather home directory) contains non-ascii characters.

First I had to manually create C:\Users\<me>\AppData\Roaming\Mozilla\sccache\config\config. In this case, <me> was exactly my username. That got me further:

[2021-06-29T12:22:59Z DEBUG sccache::compiler::msvc] failed to detect showIncludes prefix with output: test.c
    Note: including file: C:\Users\<me-broken>\AppData\Local\Temp\sccache7s3qbu\test.h

[2021-06-29T12:22:59Z DEBUG sccache::server] check_compiler: Unsupported compiler: Failed to detect showIncludes prefix

Note that in the output, <me-broken> wasn't exactly my username, but the character š was replaced with s. This could be just a display issue (either with the debug log or in PowerShell).

In the end, I've renamed my home directory so that it does not contain any special characters and the problem seems to be resolved.

autoantwort commented 3 years ago

What is Tracker.exe?

According to this it is a tool used by Visual Studio to check if a project must be rebuilt or not. It tracks the input and output files of the subprocess, so that it can decide the next time if the subprocess must be run or not.

image The Tracker command line ends with ...c8.rsp"