-
Notifications
You must be signed in to change notification settings - Fork 635
Description
When the @rsp support pull request landed I was eager to use that on Windows/MSVC.
Context
The internal requirement was that the build process should be pretty much as is, changing to ninja from msbuild was not an option. So I first tried to hook in sccace in a clean way.
I use directory.build.props and a bat-file to get sccache prefixed before the call to cl.exe. More details here.
That worked: sccache gets to see the compile call, but I get Uncachable reason: multiple input files when the call is
d:\tools\sccache.exe cl.exe @C:\Users\me\AppData\Local\Temp\tmpfa7e185af63d4159b8ef0462dcbf1754.rsp
The rsp file do list multiple source files.
So I then changed the "compile call" to be python somescript.py %*, that is, I have a pythonscript which gets called with the rsp-file as parameter.
I parse the rsp-file. I group the conents into either "flag" or "source file".
Then for each source file:
- I create a new
rsp-file with all the flags and then just that source name. - I call
sccache cl.exe @full_path_to_new_rsp_file.rsp
With this extra step, I can compile from visual studio. With rebuild I get cache hits. When it gets to linking, there is an error.
Actual problem
The rsp file contains /Fo"somename.dir\\Debug\\", so object files should go into a sub directory relative to the source location.
Assume that the rsp-file lists foo.c as file to compile.
When I use cl.exe @myrspfile.rsp I get somename.dir\Debug\foo.obj.
When I use sccache cl.exe @myrspfile.rsp I instead get somename.dir\Debug.obj
And this is the reason for link failure - /Fo can contain a directory name and does not have to be the filename for the output obj file.