如何在 Mac OS X 上手动构建通用 ruby?用rvm怎么样?
我从 官方 git 镜像 获取了 ruby 源代码,然后查看了 ruby_1_9_2
分支机构。
git clone http://github.com/ruby/ruby.git git checkout ruby_1_9_2
所以,现在我想编译 1.9.2-head。但正如您稍后将看到的,我希望有一个也适用于 1.8 的解决方案。
编译这个的标准方法是:
autoconf ./configure make make install
这可行,但它产生了一个仅限 x86_64 的版本:
$ ruby -v ruby 1.9.2dev (2010-06-14 revision 28321) [x86_64-darwin10.3.0]
显然,我不关心 PPC,因为我使用的是 10.6,但我想同时拥有 i386 和 x86_64,因为 < a href="http://rubyforge.org/pipermail/rb-appscript-discuss/2010-May/000343.html" rel="nofollow noreferrer">有些事情需要在32位中完成。
所以,我想知道的是:
- 构建具有 i386 和 x86_64 架构的胖二进制文件的魔法。
- 我也有兴趣对我的 RVM ruby 版本做同样的事情。
可能不必要的系统信息:
$ system_profiler -detailLevel mini SPSoftwareDataType | ack '^ {6}' | head -3 System Version: Mac OS X 10.6.4 (10F569) Kernel Version: Darwin 10.4.0 64-bit Kernel and Extensions: No $ uname -a Darwin meaningless.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
I got the ruby sources from the official git mirror, then checked out the ruby_1_9_2
branch.
git clone http://github.com/ruby/ruby.git git checkout ruby_1_9_2
So, for now, I want to compile 1.9.2-head. But as you'll see later I'm hoping for a solution that works for 1.8 too.
The standard way to compile this is:
autoconf ./configure make make install
That works, but it yields me a x86_64-only build:
$ ruby -v ruby 1.9.2dev (2010-06-14 revision 28321) [x86_64-darwin10.3.0]
I don't care about PPC, obviously, since I'm on 10.6, but I want to have both i386 and x86_64, because some things need to be done in 32-bit.
So, what I want to know:
- the magic chants to build a fat binary with both i386 and x86_64 archs.
- I would also be interested in doing the same with my RVM ruby versions.
Probably unecessary system information:
$ system_profiler -detailLevel mini SPSoftwareDataType | ack '^ {6}' | head -3 System Version: Mac OS X 10.6.4 (10F569) Kernel Version: Darwin 10.4.0 64-bit Kernel and Extensions: No $ uname -a Darwin meaningless.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
至于 RVM,它说你不能拥有胖二进制文件,但事实并非如此,因为包含 我的补丁。
使用最新的 rvm,您可以使用与手动构建中相同的配置标志来安装 ruby-1.9.2-head:
证明它应该有效:
As for RVM, it says you can't have fat binaries, but that's not true as of this commit which incorporates my patch.
Using the latest rvm you can install
ruby-1.9.2-head
using the same configure flag as in the manual build:Proof that it's supposedly working:
在
./configure
中使用--with-arch
选项:--with-arch
采用逗号分隔的 Ruby 架构列表应该建造。由 kch 添加:
成功构建后的输出:
Use the
--with-arch
option to./configure
:--with-arch
takes a comma-separated list of architectures for which Ruby should be built.added by kch:
Output after a successful build: