在 Mac 上构建通用二进制文件 - 强制单个编译器子进程
干杯,
在公司,我们正在创建游戏的移植版本,我们需要编译 PythonOgre,一个Python 的 Ogre3d 包装器。这是一个巨大的代码块,特别是生成的包装器代码。我们有一台配备 1GB RAM 的 Mac Mini。
我们已经构建了 i386 版本。由于我们只有 1GB RAM,因此我们强制构建系统仅使用一个核心;同时运行的第二个进程很好地进入了虚拟内存。
现在,我们需要生成通用二进制文件,因为发行商坚持支持 PPC。为了便于构建通用二进制文件,我们修改了 CFLAGS
和 CXXFLAGS
以在编译包装器代码 (Ogre3d) 时包含 -arch i386 -arch ppc
本身似乎已经是一个通用的二进制文件)。
然而,苹果公司决定在创建通用二进制文件时使用两个核心,这导致系统崩溃并死机。 (无论如何,以 0.9-1.4% 的 CPU 使用率爬行。)虽然通常我们会欣赏这一点,但在 1GB Mac Mini 上,这完全阻碍了我们的开发。
除了获得新的构建机器、放弃 PPC 支持并生成仅 PPC 构建之外,我们唯一的办法就是阻止 GCC 生成第二个同时进程。
我们该怎么做呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我检查了 Apple 的 GCC 驱动程序的源代码(支持这些
-arch
选项并运行子进程的驱动程序),并且没有您可以选择的选项或环境变量。我认为留给您的唯一选择是:
driverdriver.c
以便顺序启动进程(而不是并行)lipo
我希望这会有所帮助!
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:
driverdriver.c
so that processes are launched sequentially (rather than in parallel)lipo
I hope this helps!
只关闭一个核心就可以了吗?显然,安装 Apple Developer Tools(XCode 等)会为您提供一个处理器系统首选项窗格,允许您关闭一个核心。我试图测试这个,但 XCode 安装由于某种原因失败了...
编辑:我知道这是不久前的事,但我只是想到了一些事情。为什么不分别使用 -march=i386 和 -march=ppc 进行构建,然后使用 lipo 组合二进制文件?
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?