mysql,Linux,HighPerformance,ruby on Rails

2009年11月19日星期四

ruby编译中的二三事--你不了解的部分

如果你像我一样,对编译ruby经历过的话,肯定会遇到一些挫折,但通过google又能找到一些通用的tutorial,这些tutorial中总会给你一条"万能的指令"如:


 ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
但你理解这后面的flag的意思吗?我相信不一定有人能理解,我记下来,总让有心人能有所收获.

RubyCocoa compatibility and --enable-shared

In order to use RubyCocoa, the Ruby interpreter must be compiled with --enable-shared. By default, Ruby Enterprise Edition's interpreter is not compiled with --enable-shared. You can compile the Ruby Enterprise Edition interpreter with this flag by passing -c --enable-shared to its installer, like this:

./ruby-enterprise-X.X.X/installer -c --enable-shared

Please note that enabling --enable-shared will make the Ruby interpreter about 20% slower. It is for this reason that we don't recommend enabling --enable-shared on server environments, although it's fine for desktop environments.


Tcl/Tk compatibility and --enable-pthread

In order to use Tcl/Tk with threading support, the Ruby interpreter must be compiled with --enable-pthread. By default, Ruby Enterprise Edition's interpreter is not compiled with --enable-pthread. You can compile the Ruby Enterprise Edition interpreter with this flag by passing -c --enable-pthread to its installer, like this:

./ruby-enterprise-X.X.X/installer -c --enable-pthread

Please note that enabling --enable-pthread will make the Ruby interpreter about 50% slower. It is for this reason that we don't recommend enabling --enable-shared on server environments, although it's fine for desktop environments.

-D_XOPEN_SOURCE=1
这个最难理解,其实它是Clib库的一个宏,说白了就是为了支持更多的函数配置的开关
Glibc 所实现全部或部分规范下的功能有:
1.ISO C: C语言国际标准.
2.POSIX: 操作系统的 ISO/IEC 9945 (aka IEEE 1003) 标准.
3.Berkeley Unix: BSD 和 SunOS.
4.SVID: V 系统接口描述.
5.XPG: The X/Open Portability Guide.
为了实现扩展函数,可以设置D_XOPEN_SOURCE
Macro: _XOPEN_SOURCE
If you define this macro, functionality described in the X/Open Portability Guide is included. This is a superset of the POSIX.1 and POSIX.2 functionality and in fact _POSIX_SOURCE and _POSIX_C_SOURCE are automatically defined.
As the unification of all Unices, functionality only available in BSD and SVID is also included.
If the macro _XOPEN_SOURCE_EXTENDED is also defined, even more functionality is available. The exa functions will make all functions available which are necessary for the X/Open Unix brand.


That's all!

参考:
http://www.rubyenterpriseedition.com/documentation.html#_how_ree_installs_itself_into_the_system
http://hivelogic.com/articles/ruby-rails-leopard

没有评论:

发表评论