[ccache] Multiple targets with preprocessor mode and -g (was Re: Single 'source' collection, multiple targets)

De Mare, Mathias (Mathias) mathias.de_mare at alcatel-lucent.com
Wed Apr 24 00:20:17 MDT 2013

Hello Joel,

Thanks for helping!

I just tried your script, and I also get 1 cache miss and 1 preprocessed cache hit.
I'm wondering if I made a mistake in my original test by configuring the CCACHE_BASEDIR incorrectly.

So looks like the issue was me, sorry for bothering!


From: joel.rosdahl at gmail.com [mailto:joel.rosdahl at gmail.com] On Behalf Of Joel Rosdahl
Sent: dinsdag 23 april 2013 22:30
To: De Mare, Mathias (Mathias)
Cc: ccache list
Subject: Re: [ccache] Multiple targets with preprocessor mode and -g (was Re: Single 'source' collection, multiple targets)

Hi Mathias,

> # 1 "/home/mdemare/testdir/target2//" <--- this is an issue!

The basedir feature is supposed to rewrite that path as well, and it seems to work when I test it using this quick shell script:


mkdir testdir.$$
cd testdir.$$

export CCACHE_DIR=$PWD/ccache.$$

mkdir a b
touch src.c
(cd a && $ccache $gcc -g -c ../src.c)
(cd b && $ccache $gcc -g -c ../src.c)
$ccache -s
cd ..
rm -rf testdir.$$

When I run it, it prints one cache miss and one preprocessed cache hit. I tested both ccache 3.1.8 and current master. What happens when you run it?

-- Joel

On 18 April 2013 14:00, Mathias De Maré <mathias.de_mare at alcatel-lucent.com<mailto:mathias.de_mare at alcatel-lucent.com>> wrote:
On 04/18/2013 01:15 PM, Mathias De Maré wrote:
Now, I actually have another issue which is partly related.
It seems building for multiple targets with the preprocessor mode and compiler option '-g' doesn't work for us.
The preprocessed file contains the location where the build is executed.
An example:
# 1 "src/foo.cpp"
# 1 "/home/mdemare/testdir/target2//" <--- this is an issue!
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "src/foo.cpp"
int main() {
    return 0;
If I build for one target in '/home/mdemare/testdir/target1' and for another target in '/home/mdemare/testdir/target2', this results in a cache miss.
Using the direct mode (since there is no preprocessing), this issue does not occur.

I'm not 100% sure, but I think this is something that ccache should change when using 'CCACHE_BASEDIR'.
Apparently, it's possible to use the gcc option '-fno-working-directory'. This gets rid of the issue for the example above.

ccache mailing list
ccache at lists.samba.org<mailto:ccache at lists.samba.org>

More information about the ccache mailing list