'man make.conf' has this to say about FEATURES=ccache: Enable portage support for the ccache package. If the ccache dir is not present in the user's environment, then portage will default to ${PORTAGE_TMPDIR}/ccache (with userpriv) and to /root/.ccache otherwise. But if ${CCACHE_DIR} is not in the environment, ebuild.sh will set ${CCACHE_DIR} to /var/tmp/ccache regardless of FEATURES=userpriv. I actually think /var/tmp/ccache is a far saner location in both cases (who wants >1GiB of cache data on their root partition?), but a problem arises with the ccache's statistics reporting. ccache defaults to /root/.ccache when ${CCACHE_DIR} isn't set. Portage defaults to /var/tmp/ccache. So, when you run 'ccache -s' it'll report the statistics from the /root cache and not the /var/tmp cache that's actually being used. The result is stats that never update. One way to fix this is to make sure ${CCACHE_DIR} is always set somewhere in the environment (/etc/env.d?). Another way is to go back to the documented behaviour, but I think I'd rather blow a goat. We need a way to make 'ccache -s' work with FEATURES=userpriv anyways.
CCACHE_DIR=/var/tmp/ccache ccache -s too difficult to figure out, or? Kinda miss what does this have to do w/ portage...
At most a doc bug I'd say (env.d is a no go).
$CCACHE_DIR defaults to $HOME/.ccache if it is not set. Since `emerge' is invoked by root in normal circumstances $CCACHE_DIR will be set to $HOME/.ccache when userpriv isn't set. This is normal and expected behaviour. Without userpriv the user is compiling as root and the ccache is root's. With userpriv the user is compiling as `portage' and the ccache belongs to the portage user. As such to check the ccache stats for the portage user one must set the CCACHE_DIR envvar to whatever portage's $HOME/.ccache is or whatever $CCACHE_DIR is set to in /etc/make.conf. This is not a 'bug' and if this was assigned to me I'd mark it invalid with a note to the poster to remember what user is compiling with regards to userpriv.
Sorry, I wasn't very clear (lack of sleep) (In reply to comment #3) > $CCACHE_DIR defaults to $HOME/.ccache if it is not set. Since `emerge' is > invoked by root in normal circumstances $CCACHE_DIR will be set to > $HOME/.ccache when userpriv isn't set. > > This is normal and expected behaviour. Without userpriv the user is compiling > as root and the ccache is root's. Right, so without userpriv the cache should go into /root/.ccache, which is what the documentation says as well. But portage doesn't actually check for userpriv, and just dumps it into /var/tmp/ccache regardless. ebuild.sh: 1381 if hasq ccache ${FEATURES} ; then 1382 #We can enable compiler cache support 1383 if [ -z "${PATH/*ccache*/}" ]; then 1384 # Remove the other reference. 1385 remove_path_entry "ccache" 1386 fi 1387 1388 if [ -d /usr/lib/ccache/bin ]; then 1389 export PATH="/usr/lib/ccache/bin:${PATH}" 1390 elif [ -d /usr/bin/ccache ]; then 1391 export PATH="/usr/bin/ccache:${PATH}" 1392 fi 1393 1394 [ -z "${CCACHE_DIR}" ] && export CCACHE_DIR="/var/tmp/ccache" 1395 1396 addread "${CCACHE_DIR}" 1397 addwrite "${CCACHE_DIR}" 1398 1399 [ -n "${CCACHE_SIZE}" ] && ccache -M ${CCACHE_SIZE} &> /dev/null 1400 fi which is why this is either a portage bug or a portage documentation bug. ;) I noticed it's mentioned in make.conf.example as well but a little vague on the details. (In reply to comment #1) > CCACHE_DIR=/var/tmp/ccache ccache -s too difficult to figure out, or? Apparently. I answer this question every month or so on the forums. ;P Whatever the outcome, I'd like to submit a doc patch to clarify things a bit and maybe save some of the confusion users are having.
(In reply to comment #4) > Right, so without userpriv the cache should go into /root/.ccache, which is > what the documentation says as well. But portage doesn't actually check for > userpriv, and just dumps it into /var/tmp/ccache regardless. Uh no, portage just plain shouldn't touch /root at all...
Created attachment 105117 [details, diff] portage-ccache-doc.diff then it's the documentation. what do you think of something like this? does make.conf.txt need to be changed too?
(In reply to comment #6) Yeah, really ccache should only stick stuff into ~/.ccache with non-portage compiles.
Patch applied in trunk, thanks.
This is in svn r5543 and has been released in 2.1.2_rc4-r9.