Hello,
I think I discovered a scenario that results in cache misses in spite of
using CCACHE_BASEDIR.
Consider the following command:

CCACHE_BASEDIR=$PWD /bin/bash -c "ccache clang++
-fdebug-prefix-map=/proc/self/cwd= -g -c -MD -MF hello.d -o hello.o
hello.cpp"

It seems to me that is is perfectly alright to ask for debug prefix mapping
like: "-fdebug-prefix-map=/proc/self/cwd="
Unfortunately, ccache is ending up hashing gnu_getcwd(); thus, even though
we use CCACHE_BASEDIR setting, such a cache cannot be shared by other
users' from different workspaces resulting in cache misses.

I tested the following code to fix this problem(there by making such a
cache sharable) I'm looking forward to your feedback on this.

--- ccache-3.3_orig/ccache-3.3/ccache.c    2016-08-27 16:57:18.000000000
+0200
+++ ccache-3.3/ccache.c    2017-09-06 11:21:06.065818333 +0200
@@ -1525,6 +1525,11 @@
                     free(cwd);
                     cwd = dir;
                 }
+                                if (strcmp(new, "") == 0) {
+                                   cc_log("forReview: empty string on the
right size of debug_prefix_map: %s", debug_prefix_map);
+                                   cwd = format("%s/", ".");
+                                   cc_log("forReview: Hence, hashing '%s'
as CWD", cwd);
+                                }
                 free(old);
                 free(new);

If the string after "=" in the mapping is null string, then, I hash "./".

regards,
Venkat.


On Mon, Sep 4, 2017 at 4:24 PM, Joel Rosdahl <j...@rosdahl.net> wrote:

> Hi Karanam,
>
> > From just ccache's point of view, is there a way to force relative
> paths into the
> > .d files at all?
>
> Yes, ccache version 3.3 and newer knows how to do this. See the release
> notes for ccache 3.3: http://ccache.samba.org/
> releasenotes.html#_ccache_3_3
>
> -- Joel
>
_______________________________________________
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache

Reply via email to