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

0.7.6 doesn't handle MSVC /Tp option correctly #2062

Open virtuald opened 9 months ago

virtuald commented 9 months ago

I'm building a python package using setuptools, so I don't have a ton of control over the command line issued. However, 0.5.3 worked, and the ccache action we're using bumped to 0.7.4 (which I then bumped to 0.7.6) and my compiles are failing now.

You can see in the command line that there's a ... /Tpplayingwithfusion/pwf.cpp ..., which then leads to the following sccache error:

sccache: encountered fatal error
sccache: error: while hashing the input file 'D:/Tpplayingwithfusion/pwf.cpp'
sccache: caused by: while hashing the input file 'D:/Tpplayingwithfusion/pwf.cpp'
sccache: caused by: The system cannot find the path specified. (os error 3)

I presume this is a regression in sccache, since I'm using the same python interpreter/setuptools/etc?

According to the MSVC docs, /Tp is an option that specifies that the following filename is a C++ file regardless of extension: https://learn.microsoft.com/en-us/cpp/build/reference/tc-tp-tc-tp-specify-source-file-type?view=msvc-170

Python's distutils (in setuptools) forces /Tp and /Tc options: https://github.com/pypa/setuptools/blob/04a6bfe785ea45d32357b60a2f9692956c4d8beb/setuptools/_distutils/_msvccompiler.py#L369

Sorry I can't give you a smaller reproducer, but this seems pretty straightforward?

virtuald commented 9 months ago

ccache fixed this in https://github.com/ccache/ccache/commit/7b8aaf562febeed81a1d27a6e498d63b8b4f6877. There's apparently a /Fo option also that ccache didn't support, it's possible sccache doesn't either (I haven't checked).