[distcc] implicit compiler name (again)

Dimitri Papadopoulos papadopo at REMOVE.shfj.DECOY.cea.fr
Thu Dec 19 16:19:04 GMT 2002


Hi,

3rd party tools such as the Insure++ memory debugger, or the MPICH
compiler call "g++" or "gcc", usually the first one found in the
PATH. They cannot be easily forced into calling "distcc gcc" or
"distcc g++".

Sorry to insist on the subject, I know it has been widely discussed:
	http://lists.samba.org/pipermail/distcc/2002q3/000213.html
However this looks like a (good?) (new) reason to enable implicit
compiler  names in distcc, at least as an option.

What is your opinion?

Please find attached the current version of the wrapper script we are
using for this purpose.

Note that this script is able to read the list of hosts from an NFS
distributed file (in our case /usr/local/etc/distccrc) and feed it
into DISTCC_HOSTS. The code is commented out, but maybe it's useful
to someone else.

Best Regards,
-- 
Dimitri
-------------- next part --------------
#!/bin/sh

DISTCC_HOME=/usr/local/distcc

# the location of the link pointing to this script
root=`dirname $0`
root=`cd "$root"; /bin/pwd`
# the name of the link pointing to this script - the name of the target compiler
name=`basename $0`

#if [ -z "$DISTCC_HOSTS" ]; then
#    rc='/usr/local/etc/distccrc'
#    if [ -r "$rc" ]; then
#	DISTCC_HOSTS="localhost `cat "$rc"`"
#	export DISTCC_HOSTS
#    fi
#fi

if [ "$name" == 'distcc' ]; then
    # traditional use of distcc
    exec "$DISTCC_HOME/bin/distcc" $@
else
    # find the first occurence of the compiler that is not a link to distcc
    unset found
    # set IFS special variable, the separator for splitting PATH is ":"
    [ "$IFS" ] && KEEP_IFS="$IFS"
    IFS=:
    for item in $PATH; do
	if [ -d "$item" ]; then
	    item=`cd "$item"; /bin/pwd`
	    # find a compiler with the same name as the script
	    compiler="$item/$name"
	    if [ -x "$compiler" -a ! -d "$compiler" -a "$item" != "$root" ]; then
		# found a compiler in a location different from the script
		found="$compiler"
		break
	    fi
	fi
    done
    # reset IFS now that the PATH has been parsed
    [ "$KEEP_IFS" ] && IFS="$KEEP_IFS" || unset IFS
    # now run the real distcc passing the found compiler as an argument
    if [ "$found" ]; then
	exec "$DISTCC_HOME/bin/distcc" "$found" $@
    else
	echo "$name: not found" 1>&2
	exit 1
    fi
fi


More information about the distcc mailing list