Compiling x86 under Darwin OS/X

Gentoo’s source-based nature requires lots of compiling to be done on a regular basis. So I have been using distcc to distribute the compile tasks to other computers on my network. This post details the steps required to setting up a i686-pc-linux-gnu (although could be easily modified for any architecture) compiler toolchain under OS X and linking it to linux machines through the use of distcc.

An important point:

OS X 10.4.2 = powerpc-apple-darwin8.2.1

The procedure is the same as in win32, except for a change in environment variables. These are for the latest version of Tiger 10.4.2:

darwin$ export PREFIX=/usr/local/cross-linux
darwin$ export SRC_ROOT=~/
darwin$ export BUILD=powerpc-apple-darwin8.2.1
darwin$ export HOST=powerpc-apple-darwin8.2.1
darwin$ export TARGET=i686-pc-linux-gnu
darwin$ export BUILDDIR=$SRC_ROOT/build
darwin$ export PATH=$PATH:$PREFIX/bin

After building binutils on OS X you can copy over the same glibc package that was prepared for cygwin. It was also necessary to copy asm-generic from /usr/include.

Keep an eye out when building gcc for this line, if you see this you’re on the right track.

Links are now set up to build a cross-compiler for i686-pc-linux-gnu
  from powerpc-apple-darwin8.2.1.

Build and install distcc and boom: your osx boxes are now in the pool!

Note: When setting up the distcc launch script the

--nice 19

command didn’t fly well under OS X, I had to omit it in order for the daemon to run properly.

Leave a Comment