Mingw-packages: CCache completely unusable (fixed as of 3.2.4+110_g1cfdf73, needs update)

Created on 6 Apr 2016  Â·  11Comments  Â·  Source: msys2/MINGW-packages

Almost all file-based operations fail presumably due to bad file path handling.

[.582561 13520] can't rename file C:\xxx/.ccache/ccache.conf.tmp.zzz.13520.P1kAlM to C:\xxx/.ccache/ccache.conf OS returned error: ../ccache-3.2.2/util.c failed with error 2: The system cannot find the file specified.
[.582561 13520] FATAL: could not set cache size limit: rename C:\xxx/.ccache/ccache.conf.tmp.zzz.13520.P1kAlM to C:\xxx/.ccache/ccache.conf: Invalid argument

For more information please check MSYS2 ticket #253: _ccache not working_ on SourceForge, thanks.


Edit: The latest code from git works, here's a build of commit 1cfdf73 as proof of that.
We just need a -git package to solve this.

Most helpful comment

I just came across this bug when trying to set up ccache on MSYS2.

At the moment, this closed issue is the only documentation I can find, and it doesn't say what the resolution is (which appears to be that workaround scripts are shipped with the package).

Please could you document the "mingw way" in the man page, or other appropriate location (e.g. whatever the mingw equivalent of README.Debian is)?

All 11 comments

Well you can try figure what is wrong or wait while someone look into it. I'm not have time to handle all issues.

Well you can try figure what is wrong [...]

Done :smile:

Well does 3.2.4 works or need to wait 3.2.5? I'm not going to build git package for it

3.2.4 with MinGW patch https://git.samba.org/?p=ccache.git;a=commit;h=361d9ad46d3276148f5b64654bb775205b728318 seems to work.

Compiling with ccache 3.2.2 produces errors,
patched ccache 3.2.4 compiles fine and ccache works when compiling manually but not with makepkg:

$ ccache -s
cache directory                     D:\msys64\home\mati865/.ccache
primary config                      D:\msys64\home\mati865/.ccache/ccache.conf
secondary config      (readonly)    D:/msys64/mingw64/etc/ccache.conf
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                            49
called for link                        1
called for preprocessing              11
compile failed                         6
preprocessor error                     5
bad compiler arguments                 1
autoconf compile/link                 24
no input file                          3
files in cache                         0
cache size                           0.0 kB
max cache size                       5.0 GB

I'll prepare PR soon.

EDIT: To make it work with makepkg CC must be replaced with CC="ccache gcc" as changing flag !ccache to ccache in makepkg.conf doesn't.

I made some more tests and package from my pull request can successfully be used to compile packages manually or using makepkg-mingw after adding ccache to CC (ex. CC="ccache gcc"). Recompilation is way faster with it. It would be nice to add symlinks in /mingw64/lib/ccache/bin so we could just modify path and have it working
but I've had errors: Recursive invocation (the name of the ccache binary must be "ccache").

To make ccache flag working for makepkg and makepkg-mingw we need ccache package for msys repo. However it will require some patching as currently it's completely broken. During compilation of 3.2.4 version there is following warning:

../ccache-3.2.4/util.c: In function ‘mkstemp’:
../ccache-3.2.4/util.c:243:2: warning: ‘mktemp’ is deprecated: the use of `mktemp' is dangerous; use `mkstemp' instead [-Wdeprecated-declarations]
  mktemp(template);
  ^
In file included from /usr/include/sys/_default_fcntl.h:7:0,
                 from /usr/include/sys/fcntl.h:3,
                 from /usr/include/fcntl.h:15,
                 from /usr/include/sys/file.h:26,
                 from ../ccache-3.2.4/system.h:24,
                 from ../ccache-3.2.4/ccache.h:4,
                 from ../ccache-3.2.4/util.c:20:
/usr/include/sys/unistd.h:260:8: note: declared here
 char * _EXFUN(mktemp, (char *));
        ^

When compiling git version -Werror is default flag and compilation fails. Suppressing it builds broken package.

According to news MinGW patches will be added in 3.3.0 (link) so it will take some time.

When compiling git version -Werror is default flag and compilation fails. Suppressing it builds broken package.

Then my MSYS build shouldn't work, but it does as far as I can tell.
(If you touch dev_mode_disabled before ./configure it should build fine.)


Oh wait, I see now: ./configure #defines HAVE_MKSTEMP 1 but for whatever freaky reason it isn't defined when compiling util.c, that's weird!

 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util.c b/util.c
index 1a7f3fd..adfd8a8 100644
--- a/util.c
+++ b/util.c
@@ -237,6 +237,7 @@ copy_fd(int fd_in, int fd_out)
    gzclose(gz_in);
 }

+#ifndef _WIN32
 #ifndef HAVE_MKSTEMP
 /* cheap and nasty mkstemp replacement */
 int
@@ -247,7 +248,6 @@ mkstemp(char *template)
 }
 #endif

-#ifndef _WIN32
 static mode_t
 get_umask(void)
 {

Probably this is the reason https://sourceforge.net/p/mingw-w64/bugs/471/

MSYS2 ccache

Here is reason of mkstemp warning in ccahe.h:250:

/* mkstemp() on some versions of cygwin don't handle binary files, so
   override */
#ifdef __CYGWIN__
#undef HAVE_MKSTEMP
#endif

However ccache for msys2 still doesn't work after removing it.

MinGw-w64-ccache:

I've found workaround to make it work with export PATH="/mingw64/lib/ccache/bin/:$PATH".
In directory /mingw64/lib/ccache/bin I've created bash scripts for symlinks which are not supported:

$ ls
c++  cpp  gcc                 x86_64-mingw32-g++
cc   g++  x86_64-mingw32-c++  x86_64-mingw32-gcc

Every script executes ccache with parameter, here are 2 examples:

$ cat gcc
#!/bin/bash

ccache /mingw64/bin/gcc "$@"

$ cat x86_64-mingw32-g++
#!/bin/bash

ccache /mingw64/bin/x86_64-w64-mingw32-g++ "$@"

The same for /mingw32.

I don't know if such workarounds are accepted by MSYS2 team. Maybe they will find better way to do it? I'm open to suggestions.

I think issue is resolved.

I think issue is resolved.

Agreed, case closed :smile:

I just came across this bug when trying to set up ccache on MSYS2.

At the moment, this closed issue is the only documentation I can find, and it doesn't say what the resolution is (which appears to be that workaround scripts are shipped with the package).

Please could you document the "mingw way" in the man page, or other appropriate location (e.g. whatever the mingw equivalent of README.Debian is)?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WuZhengqiang666 picture WuZhengqiang666  Â·  3Comments

oscarbg picture oscarbg  Â·  7Comments

MenaceInc picture MenaceInc  Â·  6Comments

WilliamKappler picture WilliamKappler  Â·  4Comments

salowenh picture salowenh  Â·  8Comments