[distcc] Re: implicit compiler name

Martin Pool mbp at samba.org
Mon Sep 16 23:41:01 GMT 2002

On 16 Sep 2002, Dimitri PAPADOPOULOS-ORFANOS <papadopo at shfj.cea.fr> wrote:
> > > Then there would still be the option of letting distcc run the
> > > compiler the name of which is given by the symlink. This way
> > > you don't have to modify Makefiles and you can easily switch
> > > between a GNU compiler and a native compiler:
> > > 	CC  -> distcc CC
> > > 	g++ -> distcc g++
> > 
> > But then, again, it's not that simple.
> > 
> > Consider PATH=/usr/local/ccache/bin:/usr/local/distcc/bin:/usr/bin:...
> > such that:
> > 
> > /usr/local/ccache/bin/gcc -> ccache
> > /usr/local/distcc/bin/gcc -> distcc
> > /usr/local/bin/gcc is the real thing
> > 
> > distcc has to be smart enough not only to know that the real gcc is
> > looking for has to be different from a link to itself, but also that
> > it must be *after* itself in the PATH, otherwise running gcc will
> > enter infinite recursion between ccache and distcc.

Presumably it would try to find the first gcc that is not a symlink.
That would handle this case.  However, it fails in a confusing way if
somebody makes a hardlink or a copy rather than a symlink.  That also
avoids the problem with distcc being installed as distcc-0.9.

One thing I considered was setting an environment variable
DISTCC_STOP_RECURSION, so that we can at least *detect* the situation,
if not prevent it.  

You could even (though this is a bit gross) use this to "probe" all
the cc's on the path until we find the right one.

> It's probably not that simple, and distcc probably will have to know about 
> ccache if it is to be used with ccache.
> So yes, there may be difficulties, but I believe it's worth the
> pain.

I don't want to rush in to doing this -- it's harder to take features
out than put them in.

The transparent scheme Dimitri describes would be nice in some ways.
I suppose the nicest attribute is that you could install distcc
system-wide and have it just work for everybody.  It might be nice if
when distcc is appropriately mature, the Debian GNU package would ask

  "Do you want to make distcc the system-wide default?"

I think it does something like this for compilercache, which is a
predecessor of ccache written in Perl.

On the other hand, I think it is only actually *necessary* to do path
tricks when all these conditions obtain:

 - Something in the build system (e.g. some versions of libtool) can't
   handle CC='distcc g++'

 - Don't want the performance hit of using a distc++ shell script that
   does "exec distcc g++ $@"

 - Need to use more than one different compiler (e.g. gcc, g++, or CC)
   from within the same Makefile rule

   If you need to use different compilers, but for different
   directories or different Makefile rules, you can easily reset the
   DISTCC_CC environment variable for that rule.  Presumably you
   already have to do something like this to tell Make to call g++ for
   the files called .c anyhow.   

In my experience it is pretty problematic to try to link C++ code
built with different versions of g++, let alone gcc and other
compilers.  I know it's not impossible, but it makes me wonder how
many people are counting on doing it.


More information about the distcc mailing list