Because of This Post I start this HowTo.
0. Introduction
Many people have bought an amd64 box and want it help their other x86 boxes compiling their stuff...
It's easier than most people think! Some guides advice to use crossdev. But that's not neccesairy! x86_64 gcc can compile fully x86-compatible 32-bit binaries with the -m32 option. That's it. But to make this thing working with distcc in a gentoo way, check this out.
1. Get the Stuff
Of course you need distcc at all boxes and the target's(I'll call the x86 machine target in this HowTo) gcc version installed on the host(s)(I'll call the amd64 helper(s) host(s))(Note: The target's gcc version hasn't to be the default on the hosts).
Get gcc-config and target's binutils version as well.
2. Let's wrap around
Now we install the x86 wrapper script on the host.
At first, you'll notice that gcc-config -B shows something like /usr/x86_64-pc-linux-gnu/gcc-bin/4.1.1
We create the pseudo gcc-bin dir with mkdir -p $(echo `gcc-config -B` | sed -e 's:x86_64:i686:').
Or, if your host's default gcc version isn't the one the target uses with mkdir -p $(echo `gcc-config -B x86_64-pc-linux-gnu-<target's gcc version>` | sed -e 's:x86_64:i686:').
Next, switch to this new dir: cd /usr/i686-pc-linux-gnu/gcc-bin/<t's version>
Here, create a file named i686-pseudo-wrapper.sh with the following content
Code: Select all
#!/bin/bash
# wrapper script for the pseudo i686 compiler on amd64 machines
# by all-inc.
$(echo $(/usr/bin/which $0) | /usr/bin/sed -e 's:i686:x86_64:g') -m32 "$@"for c in {g++,gcc,c++,cpp}; do ln -s i686-pseudo-wrapper.sh ${c}; ln -s ${c} i686-pc-linux-gnu-${c}; done
(I think we can omit ln -s i686-pc-linux-gnu-gcc i686-pc-linux-gnu-gcc-<t's ver>)
3. Configure distccd(on the hosts!)
Go into /etc/conf.d and cp distccd distccd-x86
This is our special x86 compiler distccd configuration file. Change the red marked settings:
Now, cd /etc/init.d and do ln -s distccd distccd-x86 or cp distccd distccd-x86 if you prefer to not edit distccd(Note: The way we edit distccd won't affect the default amd64 distccd). I use the symlink because of flexibility. If you have three distccds, e.g. distccd-x86-3.4.4, distccd-x86-4.1.1 and distccd-amd64-3.4.4, you only have to create the configs in conf.d and the symlinks.my /etc/conf.d/distccd-x86 without comments wrote:DISTCCD_OPTS="-j4"
DISTCCD_EXEC="/usr/bin/distccd"
DISTCCD_PIDFILE="/var/run/distccd/distccd-x86-<optional gcc version>.pid"
DISTCCD_OPTS="${DISTCCD_OPTS} --port 3633" Change the default port only if you want your standard amd64 distccd listen at the default port 3632
DISTCCD_OPTS="${DISTCCD_OPTS} --log-level critical"
DISTCCD_OPTS="${DISTCCD_OPTS} --listen 192.168.0.24 --allow 192.168.0.0/24" This should fit your network
DISTCCD_NICE="10"
Edit distccd (or distccd-x86 if you don't like the symlink method) and change the red stuff(or, if you did't use the symlink method, only make static changes...so don't use variables like $_a_suffix etc.):
Now, your x86 distccd is finish! start it with /etc/init.d/distccd-x86depend() {
need net
use ypbind
}
_a_suffix="$(echo ${SVCNAME} | cut -s -d "-" -f 2)" #extract arch from suffix
[[ -z ${_a_suffix} ]] && _a_suffix="amd64"
_g_suffix="$(echo ${SVCNAME} | cut -s -d "-" -f 3)" #extract gcc-version from suffix
[[ -z ${_g_suffix} ]] && _gcc_profile="" || _gcc_profile="x86_64-pc-linux-gnu-${_g_suffix}"
start() {
[ -e "${DISTCCD_PIDFILE}" ] && rm -f ${DISTCCD_PIDFILE} &>/dev/null
ebegin "Starting distccd/${_a_suffix}-${_g_suffix:-"default"}"
chown distcc `dirname ${DISTCCD_PIDFILE}` &>/dev/null
_binpath="$(gcc-config -B ${_gcc_profile})"
[[ ${_a_suffix} == "x86" ]] && \
_PATH=$(echo ${_binpath} | \
sed -e 's:x86_64:i686:g') || \
_PATH=${_binpath}
TMPDIR="${TMPDIR}" \
PATH="${_PATH}" \
/sbin/start-stop-daemon --start --quiet --startas ${DISTCCD_EXEC} \
--pidfile ${DISTCCD_PIDFILE} -- \
--pid-file ${DISTCCD_PIDFILE} -N ${DISTCCD_NICE} --user distcc \
${DISTCCD_OPTS}
eend $?
}
stop() {
ebegin "Stopping distccd/${_a_suffix}-${_g_suffix:-"default"}"
start-stop-daemon --stop --quiet --pidfile "${DISTCCD_PIDFILE}"
rm -f "${DISTCCD_PIDFILE}"
eend $?
}
(Note: If the host's default gcc version isn't the target's one, please use /etc/conf.d,init.d/distccd-x86-<t's gcc version> so the right bin paths are extracted.)
4. Configure distcc(on the target!)
simply add host-ip:3633/3 or something similar that fits your needs to /etc/distcc/hosts
(Note: You don't need to set the port if you use the default port for distccd-x86)
And of course set MAKEOPTS="-j4" or similar in your make.conf.
Now test it!
I use this method for quiet a while and I already ran emerge -uD world on a x86 successfully, so I think it works
I hope you liked this HowTo. If, or if not, please give me your feedback here. If you find errors or typos, PM me PLEASE
With best regards, Sebastian Stammler


