[ccache] Cache Clean-up Patch

RW fbsd06 at mlists.homeunix.com
Thu Apr 10 15:09:20 GMT 2008


ccache cleans-up old files based on file modification time. When a
cache hit occurs the stderr file and the output file get their mtimes
updated. Cached object files don't get updated except as a
side-effect of updating the output file when it's hard-linked.  

In other words the cache purges object files on a "least-recently
compiled" or  "least-recently used" basis according to whether the
output is copied or linked. I think this a bug, and have a patch
that I've been using to make it consistently LRU. It updates the object
file at the same time as stderr (before the hard-linking stage). 

Any comments?  Should I do anything with this? ccache doesn't seem to
have been updated since 2004.


--- ccache.c.orig       2008-03-24 13:39:47.000000000 +0000
+++ ccache.c    2008-03-24 13:44:46.000000000 +0000
@@ -484,7 +484,10 @@
                free(stderr_file);
                return;
        }
-
+       /* update timestamps for LRU cleanup
+          also gives output_file a sensible mtime when hard-linking (for make)
+       */
+       utime(hashname, NULL);
        utime(stderr_file, NULL);

        if (strcmp(output_file, "/dev/null") == 0) {
@@ -517,10 +520,6 @@
                        failed();
                }
        }
-       if (ret == 0) {
-               /* update the mtime on the file so that make doesn't get confused */
-               utime(output_file, NULL);
-       }

        /* get rid of the intermediate preprocessor file */
        if (i_tmpfile) {




More information about the ccache mailing list