Search code examples
pythonmacosgccmulticore

Building universal binaries on Mac - Forcing single compiler child process


Cheers,

at company, we're creating a port of our games, and we need to compile PythonOgre, a wrapper of Ogre3d for Python. This is an enormous chunk of code, particularly the generated wrapper code. We have a Mac Mini with 1GB RAM.

We've built i386 version. Since we have only 1GB of RAM, we've forced the build system to use only one core; second process running at the same time took a nice trip into the virtual memory.

Now, we need to produce universal binaries, because publisher insists on supporting PPC. To facilitate building of universal binaries, we've modified the CFLAGS and CXXFLAGS to include -arch i386 -arch ppc when compiling wrapper code (Ogre3d itself already seems to be an universal binary).

However, Apple has decided to use both cores when creating universal binary, and this has caused the system to roll over and die. (Well, crawl at 0.9-1.4% CPU usage, anyways.) While ordinarily we would appreciate this, on a 1GB Mac Mini, this completely blocks our development.

Aside from getting a new build machine, giving up on PPC support and producing a PPC-only build, the only recourse we have is to block GCC's spawning of second simultaneous process.

How would we go about that?


Solution

  • I've checked the source of Apple's GCC driver (the one that supports those -arch options and runs the children processes), and there's no option or environment variable that you can choose.

    The only options I see left to you are:

    • download the Apple driver (e.g. from there; end of the page) and modify the file driverdriver.c so that processes are launched sequentially (rather than in parallel)
    • do separate i386 and powerpc builds, and join the final build objects (executables, shared libraries, etc.) using lipo

    I hope this helps!