Building universal binaries on Mac - Forcing single compiler child process

我只是一个虾纸丫 提交于 2019-12-24 13:47:43

问题


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?


回答1:


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!




回答2:


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?



来源:https://stackoverflow.com/questions/1536897/building-universal-binaries-on-mac-forcing-single-compiler-child-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!