I am trying to find a solution to David, but ran into the problem "distcc seems to have called recursively!" in distcc plain mode. This is due to the fact that when the host distcc request performs preprocessing (cpp), it will call the host ccache file, but distcc-wrap intercepts and spawns a nested distcc and generates a recursive call:
g ++ β ccache β distcc β distcc-wrap β preprocess using g ++ β ccache β distcc β .... etc.
My solution is to use DISTCC_CMDLIST , from man distccd :
DISTCC_CMDLIST
If the DISTCC_CMDLIST environment variable is set, load the list of supported commands from a file named DISTCC_CMDLIST and refuse to service any command, the last last words of DISTCC_CMDLIST_MATCHWORDS do not match the last words of the command in this list. See Comments in src / serve.c.
Assuming you want to use /usr/local/ccache/g++ (which is a /usr/bin/ccache ) on the remote computer to run the compilation, instead of using the absolute path extended by the host machine, you can do it like this:
create the file /path/to/.distcc/DISTCC_CMDLIST with this line:
/usr/local/ccache/g++
export DISTCC_CMDLIST=/path/to/.distcc/DISTCC_CMDLIST
restart the distccd daemon distccd distccd --no-detach -a <host IPs> --daemon
What happens when the remote distcc server receives an extended command from the host lke /usr/bin/g++ main.cc -c , it will map the real compiler from / usr / bin / g ++ to / usr / local / ccache / g ++. The mapping is performed using:
extracts the base name from the compiler path in the receiving command ( g++ in this case)
Look at the DIST_CMDLIST file to see if any basename string has a g++ value. In this case, it will be /usr/local/ccache/g++
rewrite the command /usr/local/ccache/g++ main.cc -c . which will invoke ccache on the remote server.
The above is just an example, and you can expand the compiler display by changing the DISTCC_CMDLIST_NUMWORDS value from 1 to other values ββto do more tricks.
source share