frerich / clcache

A compiler cache for MSVC, much like ccache for gcc
Other
325 stars 83 forks source link

Error while writting clcache stats.txt #339

Closed 9a4gl closed 5 years ago

9a4gl commented 5 years ago

Almost every time I do rebuild whole solution (building from visual studio), it fails and I output I see:

9>Traceback (most recent call last): 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main 9> "__main__", mod_spec) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code 9> exec(code, run_globals) 9> File "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\CL.exe\__main__.py", line 9, in <module> 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 1577, in main 9> return processCompileRequest(cache, compiler, sys.argv) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 1604, in processCompileRequest 9> return scheduleJobs(cache, compiler, cmdLine, environment, sourceFiles, objectFiles) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 1656, in scheduleJobs 9> exitCode, out, err, doCleanup = future.result() 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\concurrent\futures\_base.py", line 425, in result 9> return self.__get_result() 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\concurrent\futures\_base.py", line 384, in __get_result 9> raise self._exception 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\concurrent\futures\thread.py", line 57, in run 9> result = self.fn(*self.args, **self.kwargs) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 1677, in processSingleSource 9> return processDirect(cache, objectFile, compiler, cmdLine, sourceFile) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 1707, in processDirect 9> return processCacheHit(cache, objectFile, cachekey) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 1495, in processCacheHit 9> stats.registerCacheHit() 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 753, in __exit__ 9> self._stats.save() 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 663, in save 9> json.dump(self._dict, f, sort_keys=True, indent=4) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\contextlib.py", line 119, in __exit__ 9> next(self.gen) 9> File "c:\users\tihomir\appdata\local\programs\python\python37\lib\site-packages\clcache\__main__.py", line 124, in atomicWrite 9> os.replace(tempFileName, fileName) 9>PermissionError: [WinError 5] Access is denied: 'C:\\Users\\tihomir\\clcache\\stats.txt.new' -> 'C:\\Users\\tihomir\\clcache\\stats.txt'

then 9>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(423,5): error MSB6006: "CL.exe" exited with code 1.

and at the end: 9>Done building project "myproject.vcxproj" -- FAILED.

Is there a workaround for this ?

Using clcache 4.2.0 installed using pip

BR, Tihomir

izmmisha commented 5 years ago

Try to move clcache dir out of user profile dir (C:\Users\tihomir\clcache -> C:\clcache for example). You can use CLCACHE_DIR environment variable.

9a4gl commented 5 years ago

Hm, actually I have moved to D:\clcache and I haven't saw this problem anymore. Thanks

apriori commented 5 years ago

I still have this problem with clache being used by gitlab runners. Each runner has its own copy of a clcache dir, but the build process uses cmake with ninja in a multithreaded way.

Traceback (most recent call last):
  File "clcache_main.py", line 2, in <module>
  File "clcache\__main__.py", line 1577, in main
  File "clcache\__main__.py", line 1604, in processCompileRequest
  File "clcache\__main__.py", line 1656, in scheduleJobs
  File "concurrent\futures\_base.py", line 398, in result
  File "concurrent\futures\_base.py", line 357, in __get_result
  File "concurrent\futures\thread.py", line 55, in run
  File "clcache\__main__.py", line 1677, in processSingleSource
  File "clcache\__main__.py", line 1707, in processDirect
  File "clcache\__main__.py", line 1495, in processCacheHit
  File "clcache\__main__.py", line 753, in __exit__
  File "clcache\__main__.py", line 663, in save
  File "contextlib.py", line 89, in __exit__
  File "clcache\__main__.py", line 124, in atomicWrite
PermissionError: [WinError 5] Zugriff verweigert: 'C:/Gitlab-Runner/builds/44bc1753/0/smart_optics/Software_Development/someproject/cache\\stats.txt.new' -> 'C:/Gitlab-Runner/builds/44bc1753/0/smart_optics/Software_Development/someproject/cache\\stats.txt'