Bug 10383 - consider using default CCACHE_DIR=${XDG_CACHE_DIR:-$HOME/.cache}/ccache
consider using default CCACHE_DIR=${XDG_CACHE_DIR:-$HOME/.cache}/ccache
Status: RESOLVED WONTFIX
Product: ccache
Classification: Unclassified
Component: ccache
unspecified
All All
: P5 normal
: ---
Assigned To: Joel Rosdahl
Joel Rosdahl
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-16 15:55 UTC by liquider
Modified: 2014-12-07 15:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description liquider 2014-01-16 15:55:27 UTC
Please consider storing ccache's cache into $XDG_CACHE_DIR/ccache or $HOME/.cache/ccache if former variable not available, provided CCACHE_DIR is not specifically set.
I understand this breaks a decade old default, but I suppose few will disapprove the change — it's only cache. :)

Here are some arguments pro:
http://ploum.net/207-modify-your-application-to-use-xdg-folders/
https://www.google.com/search?q=XDG_CACHE_HOME+cache

I understand you may cater for wider variety of Unices. Surely no one will mind a less polluted home.
Comment 1 Joel Rosdahl 2014-04-12 20:57:37 UTC
(In reply to comment #0)
> Please consider storing ccache's cache into $XDG_CACHE_DIR/ccache or
> $HOME/.cache/ccache if former variable not available, provided CCACHE_DIR
> is not specifically set.

I assume you mean XDG_CACHE_HOME, not XDG_CACHE_DIR?

> I understand this breaks a decade old default, but I suppose few will
> disapprove the change — it's only cache. :)

This sounds like a good idea in general, but I'm still undecided on whether it would be a good fit for ccache. The reason is that the ccache directory is in fact not entirely "only cache"... It holds three kinds of information:

1. Volatile files: temporary files used during compilation and cached compilation results. 

2. Statistics of cache hits/misses, etc.

3. Configuration, currently max cache size and max number of files in the cache. The plan for ccache 3.2 is to be able to store a lot more configuration in a configuration file inside $CCACHE_DIR: both configuration related to the actual cache but potentially also any setting (if the user wants). See https://git.samba.org/?p=ccache.git;a=blob;f=MANUAL.txt;h=a36c5050387e591ffb1d0e1fa40a43ce5f6c3005;hb=HEAD#l183 for documentation on this.

I think that it would be acceptable if statistics were thrown away if $XDG_CACHE_HOME was removed, but the configuration would not be OK to lose. If we go the XDG way, we would need to rethink and store configuration in a separate location, which of course would be $XDG_CONFIG_HOME/ccache if CCACHE_DIR is unset. But what should happen if CCACHE_DIR *is* set? I have to think more about this.

> I understand you may cater for wider variety of Unices. Surely no one
> will mind a less polluted home.

To complicate matters, it's not only Unices but also Windows and maybe other operating systems as well.
Comment 2 Joel Rosdahl 2014-12-04 21:26:09 UTC
I've decided to not go with the XDG_CACHE_DIR approach for the following reason:

When using a shared cache, it's important that all users use the same settings, e.g. max_size, umask, compression and cache_dir_levels. Therefore I would like to associate the configuration of a cache with the cache itself so that the settings automatically will apply to all uses of the cache. It must thus be possible to infer the location of the configuration file from the cache location. Storing the configuration inside XDG_CACHE_DIR does not make sense since the configuration is not volatile information. Storing it in something like $XDG_CACHE_DIR/../.config/ccache does not make sense either since it's not guaranteed to work. The configuration would have to be stored in XDG_CONFIG_DIR, but reading configuration from XDG_CONFIG_DIR when CCACHE_DIR is set to a shared directory does not make sense.

I see no reasonable way of using XDG_CACHE_DIR for ccache. I'm open to new ideas regarding how to do it, though. Until then, I'm closing the request as WONTFIX, sorry.
Comment 3 liquider 2014-12-05 00:52:02 UTC
It's a bit late to introduce CCACHE_CONFIG_DIR, I suppose. No biggie. :)
Comment 4 Joel Rosdahl 2014-12-07 15:42:20 UTC
> It's a bit late to introduce CCACHE_CONFIG_DIR, I suppose. No biggie. :)

Well, there is a CCACHE_CONFIGPATH variable already. But I don't want to break backward compatibility for the use case where the user has set CCACHE_DIR to a non-standard location.