views:

155

answers:

2

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?

+6  A: 

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!

FX
Thanks! I've taken a look at the driver code (darwin-driver.c) but since I cannot quickly find the call to fork() we won't be going that way. On the other hand, yesterday we quickly created the ppc build and lipo seems rather simple to use so we'll merge i386 and ppc .so's with lipo. Thank you!
Ivan Vučica
The driver doesn't call fork() directly, it calls a function named pexecute(), which hides system-specific behaviour (GCC works on non-POSIX platforms such as Windows! the library providing this is libiberty, which is included in GCC).
FX
+1  A: 

Will just turning off one core do? Apparently, installing the Apple Developer Tools (XCode et al.) gives you a Processor system preference pane, allowing you to turn off one core. I was trying to test this, but the XCode install failed for some reason...

EDIT: I know this was a while ago, but I just thought of something. Why not build with -march=i386 and -march=ppc separately and then combine the binaries using lipo?

Chinmay Kanchi
I've just got it installed and it works as advertised. If the prefPane fails to install after installing the developer tools, you can find it at /Developer/Extras/PreferencePanes/ , provided you installed the dev tools at the default location.
Chinmay Kanchi
We're currently building PPC-only version (deadlines, oh deadlines), so I can't test. But I suspect this does the same thing as /Library/Application Support/HW Prefs/CPU Palette which did NOT help, since GCC didn't act upon the fact that there's only one core active and it happily spawned the second process.
Ivan Vučica