Ruby Forum Ruby-core > OSX patches

Posted by Laurent Sansonetti (Guest)
on 24.10.2007 18:15
(Received via mailing list)
Hi ruby-core,

# I work for Apple, in the OS team.

We internally have a set of patches that we apply to the Ruby 1.8
source tree to build the version of Ruby that ships with Mac OS X.
Some of them were written for Leopard (10.5, the upcoming version of
Mac OS X that will be released in a few days), others were written for
previous versions.

We would like to offer them upstream. Here is a brief description of
each of them. They all target the 1.8 branch, though some of them may
also be meaningful for trunk.

I uploaded the patches on a separate temporary website directory for
more convenience: http://chopine.be/lrz/ruby-osx-patches :

dot-darwin.diff: A very simple one. The --diagram option of rdoc
checks if the dot program exists in the system, and this test is
currently skipped for Windows environments (by looking for the "win"
word in the platform name), but also  for Mac OS X, which platform
name is "darwin". We want the test for darwin though.

etc-irbrc.diff: This is an addition to IRB, to allow it to load its
configuration file from a system-wide directory, /etc/irb#{rc}. This
change is only effective for non-Windows environments.

ignore-gsetcontext.diff: In Leopard, the setcontext/getcontext
functions have been modified to confirm to the UNIX norm, however,
their implementation changed to not use the default structure by
default, which makes Ruby segfaulting during initialization. This
patch just force the non-set/getcontext code path for Leopard
environments, but use set/getcontext for systems below.

md5_sha1_commoncrypto.diff: In Leopard, a new cryptographic API was
introduced, which is compatible with OpenSSL's libcrypto. This patch
enables the md5 and sha1 extensions to use the new CommonCrypto API
instead of libcrypto, if the new API is found on the system. The new
API is preferred on Leopard for performance purposes.

use-dyld.diff: Ruby currently uses the NSSymbol APIs for its C
extension loader on Mac OS X, however, this API was deprecated since
Tiger (10.4) and it's recommended to use the dyld API instead. This
patch makes Ruby using dlopen/dlsym instead of NSSymbol, for systems
greater or equal than Tiger.

use-setreugid.diff: Ruby marked the setreuid/setregid system calls
broken on Mac OS X, which is true for systems below or equal than
Tiger. However, in Leopard, these functions have been fixed to conform
to the UNIX specs. Ruby can therefore use them safely on Leopard or
greater.

words-bigendian-from-arch.diff: This patch moves some code that was
only effective for NeXT systems, for both Mac OS X and NeXT.
WORDS_BIGENDIAN isn't trusted from configure, but instead we use
__BIG_ENDIAN__. This is to make sure you can build Ruby for both ppc
and i386 architectures (as a fat binary) on ppc, then use the binary
on i386 without getting endianness problems.

That's all. It would be nice if you could look at them, and consider
merging them in the 1.8 branch. At least, ignore-gsetcontext.diff is
important, because without it Ruby cannot build on Leopard (miniruby
segfaults then). I would be happy to discuss the patches, and propose
updated versions if necessary.

Thanks,
Laurent
Posted by Michal Suchanek (Guest)
on 24.10.2007 20:21
(Received via mailing list)
On 24/10/2007, Laurent Sansonetti <laurent.sansonetti@gmail.com> wrote:
> greater.
>
Nice. I was wondering if somebody who understands the OS X dynamic
loading interface could do this.
Since my minimac returned from hardware upgrade I will test the patch
.. when I get through the other stuff that is waiting for it.

I wonder why they put such slow disks and so little memory into them.

Thanks

Michal
Posted by Nobuyoshi Nakada (nobu)
on 24.10.2007 21:05
(Received via mailing list)
Hi,

At Thu, 25 Oct 2007 01:13:40 +0900,
Laurent Sansonetti wrote in [ruby-core:12895]:
> We internally have a set of patches that we apply to the Ruby 1.8
> source tree to build the version of Ruby that ships with Mac OS X.
> Some of them were written for Leopard (10.5, the upcoming version of
> Mac OS X that will be released in a few days), others were written for
> previous versions.

AvailabilityMacros.h has been available on older versions?
Even on pre-OS X, though I guess ruby can't compile on there
anymore, is it OK?
Also, is it the Apple's official way to check the version?
Posted by Laurent Sansonetti (Guest)
on 24.10.2007 22:47
(Received via mailing list)
On 10/24/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
> AvailabilityMacros.h has been available on older versions?
> Even on pre-OS X, though I guess ruby can't compile on there
> anymore, is it OK?

AvailabilityMacros.h is available since 10.2. It doesn't exist on
10.0, 10.1 (which was a quick bugfix release for 10.0), or pre-OSX
systems. 10.0 and 10.1 are actually obsolete environments, and I'm not
even sure that ruby can build or run on pre-OSX systems (Fujimoto
Hisakuni wrote some support I think, but it may not be complete).

> Also, is it the Apple's official way to check the version?

Yes it is.

Laurent
Posted by Stephen Bannasch (Guest)
on 12.12.2007 18:36
(Received via mailing list)
At 5:47 AM +0900 10/25/07, Laurent Sansonetti wrote:
>>
>> Also, is it the Apple's official way to check the version?
>
>Yes it is.

I'd like to see these patches applied.

Has anybody found any problems with them?
Posted by Giles Bowkett (Guest)
on 13.12.2007 20:20
(Received via mailing list)
> I'd like to see these patches applied.
>
> Has anybody found any problems with them?

+1 for the /etc/irbrc patch.

skipping the others as over my head, except for dot-darwin. there's a
gem called Platform which might be preferable. it handles a wide range
of cases, including "cygwin," which is a Unix emulator for Windows.

--
Giles Bowkett

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com