Problems compiling native gems under Snow Leopard + RVM

78 views
Skip to first unread message

Chad Woolley

unread,
Jun 29, 2010, 12:14:47 PM6/29/10
to RVM
This is the same sort of problem I had compiling Hpricot gem. Now it
happens with mysql gem. Only under RVM - not system ruby:

http://gist.github.com/456916

Any help is welcome.

Thanks,
-- Chad

Luis Lavena

unread,
Jun 29, 2010, 1:35:22 PM6/29/10
to rubyversi...@googlegroups.com

What version of mysql is installed? is a universal binaries or is 64bits one?

What architecture is the Ruby compiled by RVM? (file `which ruby`)

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Chad Woolley

unread,
Jun 30, 2010, 1:17:25 AM6/30/10
to rubyversi...@googlegroups.com
On Tue, Jun 29, 2010 at 10:35 AM, Luis Lavena <luisl...@gmail.com> wrote:
> On Tue, Jun 29, 2010 at 12:14 PM, Chad Woolley <thewoo...@gmail.com> wrote:
>> This is the same sort of problem I had compiling Hpricot gem.  Now it
>> happens with mysql gem.  Only under RVM - not system ruby:
>>
>> http://gist.github.com/456916
>>
>> Any help is welcome.
>>

Thanks for your help Luis.

>
> What version of mysql is installed? is a universal binaries or is 64bits one?

http://gist.github.com/456916#file_2. my_sql info

>
> What architecture is the Ruby compiled by RVM? (file `which ruby`)
>

http://gist.github.com/456916#file_3. ruby info

Why are some libraries under MySQL x86_64 arch, when mysql status
reports i386 as the arch?

Also, I can't seem to force the mysql_api.bundle to be i386 arch, even
if I pass env ARCHFLAGS="-arch i386" when building the gem. Not sure
what mkmf is doing...

Chad Woolley

unread,
Jul 8, 2010, 2:53:34 AM7/8/10
to RVM

Solved this. Root cause was that RVM/Ruby had compiled for i386
architecture rather than x86_64:
http://gist.github.com/456916#file_6._solved

Thanks for the help...
-- Chad

Wayne E. Seguin

unread,
Jul 8, 2010, 7:18:49 AM7/8/10
to rubyversi...@googlegroups.com
Hey Chad, I'm back from vacation now.

RVM doesn't 'specifically use' a given architecture, instead it leaves
that choice up to your OS and the compiler you are using.

Chad Woolley

unread,
Jul 8, 2010, 12:17:30 PM7/8/10
to rubyversi...@googlegroups.com
On Thu, Jul 8, 2010 at 4:18 AM, Wayne E. Seguin <waynee...@gmail.com> wrote:
> Hey Chad, I'm back from vacation now.
>
> RVM doesn't 'specifically use' a given architecture, instead it leaves
> that choice up to your OS and the compiler you are using.
>

Right. I found this out by digging into the ruby configure logic to
detect the architecture before I just tried reinstalling. No idea how
ruby detected a wrong platform - maybe I did the faulty install from a
terminal session which happened to have ARCHFLAGS set to '-arch i386'
from some previous process.

One thing I did realize - there are parts of the ruby configure/make
process (ones which use "cc" instead of "gcc") in which the
architecture CANNOT be overridden (e.g. to make a universal binary)
unless you manually edit the generated Makefile. Looks like an
oversight.

-- Chad

Chad Woolley

unread,
Jul 8, 2010, 9:26:23 PM7/8/10
to rubyversi...@googlegroups.com
On Thu, Jul 8, 2010 at 9:17 AM, Chad Woolley <thewoo...@gmail.com> wrote:
> On Thu, Jul 8, 2010 at 4:18 AM, Wayne E. Seguin <waynee...@gmail.com> wrote:
>> Hey Chad, I'm back from vacation now.
>>
>> RVM doesn't 'specifically use' a given architecture, instead it leaves
>> that choice up to your OS and the compiler you are using.
>>
>
> Right.  I found this out by digging into the ruby configure logic to
> detect the architecture before I just tried reinstalling.  No idea how
> ruby detected a wrong platform - maybe I did the faulty install from a
> terminal session which happened to have ARCHFLAGS set to '-arch i386'
> from some previous process.

Wayne,

Actually, I think logic in RVM may have been responsible for this. My
clue was the following comment on my gist:

' I usually put this line in my root .rvmrc file to always compile in
x86_64: export rvm_archflags="-arch x86_64" ' - From: spagalloco

That made me wonder what RVM did with rvm_archflags, which led me to
this line in RVM:

http://github.com/wayneeseguin/rvm/blob/master/scripts/utility#L515

In the case of my macbook, `sysctl hw.cpu64bit_capable` returns zero,
even though I am running snow leopard and (as I painfully found out)
need to set my -arch to x86_64 whenever I compile something.

Haven't dug into it, but this definitely seems like it could have been
the cause of my ruby incorrectly compiling for i386 architecture.

-- Chad

Wayne E. Seguin

unread,
Jul 12, 2010, 12:34:47 AM7/12/10
to rubyversi...@googlegroups.com
I thought that had been commented out / removed from running... We'll
look into it, thanks Chad.

Chad Woolley

unread,
Jul 12, 2010, 1:00:45 AM7/12/10
to rubyversi...@googlegroups.com
On Sun, Jul 11, 2010 at 9:34 PM, Wayne E. Seguin <waynee...@gmail.com> wrote:
> I thought that had been commented out / removed from running... We'll
> look into it, thanks Chad.

Today I tried it again, and sysctl hw.optional.x86_64 returns 1 now.
My machine must be schizo, but that supports the behavior I saw...

mcs

unread,
Jul 12, 2010, 5:25:05 PM7/12/10
to rvm (Ruby Version Manager)
On Jul 11, 10:00 pm, Chad Woolley <thewoolley...@gmail.com> wrote:
> On Sun, Jul 11, 2010 at 9:34 PM, Wayne E. Seguin <wayneeseg...@gmail.com> wrote:
>
> > I thought that had been commented out / removed from running... We'll
> > look into it, thanks Chad.
>
> Today I tried it again, and sysctl hw.optional.x86_64 returns 1 now.
> My machine must be schizo, but that supports the behavior I saw...

I also have MacBook (10.6) that has a identity crisis between 64 and
32 bit when compiling. I ran into trouble compiling Ruby 1.9. After I
got it to compile, I ran into erratic behavior/error when using
fibers. I tried all combinations of arch settings in my .rvmrc file,
all gave me the same problems. Reading through the log files led me to
try "export CFLAGS=-D_FILE_OFFSET_BITS=64". I eventually added it to
my dotfiles and I have not experienced any more issues. I am no expert
in compiling for different architectures, but this has fixed my
problems so far.

Let me know if you have further questions about my machine, to
determine if we are in the same boat.

Hope this helps.

Thanks to everyone on this email list, especially Wayne. Everyone has
been extremely helpful.

Wayne E. Seguin

unread,
Jul 12, 2010, 7:37:12 PM7/12/10
to rubyversi...@googlegroups.com
On Mon, Jul 12, 2010 at 5:25 PM, mcs <matthewc...@gmail.com> wrote:
> I also have MacBook (10.6) that has a identity crisis between 64 and
> 32 bit when compiling. I ran into trouble compiling Ruby 1.9. After I
> got it to compile, I ran into erratic behavior/error when using
> fibers. I tried all combinations of arch settings in my .rvmrc file,
> all gave me the same problems. Reading through the log files led me to
> try "export CFLAGS=-D_FILE_OFFSET_BITS=64". I eventually added it to
> my dotfiles and I have not experienced any more issues. I am no expert
> in compiling for different architectures, but this has fixed my
> problems so far.

Wow, this is very fascinating... I have added that to my notes thanks.


> Thanks to everyone on this email list, especially Wayne. Everyone has
> been extremely helpful.

You are most welcome of course :)

Chad Woolley

unread,
Jul 12, 2010, 10:50:44 PM7/12/10
to rubyversi...@googlegroups.com
On Mon, Jul 12, 2010 at 2:25 PM, mcs <matthewc...@gmail.com> wrote:
> On Jul 11, 10:00 pm, Chad Woolley <thewoolley...@gmail.com> wrote:
>> On Sun, Jul 11, 2010 at 9:34 PM, Wayne E. Seguin <wayneeseg...@gmail.com> wrote:
>>
>> > I thought that had been commented out / removed from running... We'll
>> > look into it, thanks Chad.
>>
>> Today I tried it again, and sysctl hw.optional.x86_64 returns 1 now.
>> My machine must be schizo, but that supports the behavior I saw...
>
> I also have MacBook (10.6) that has a identity crisis between 64 and
> 32 bit when compiling.

Is the logical thing to always compile 64 bit if snow leopard is
detected? Is it even possible to run snow leopard i386?

Wayne E. Seguin

unread,
Jul 13, 2010, 8:10:45 PM7/13/10
to rubyversi...@googlegroups.com
IIRC Snow Leopard Kernel runs as 32 bit by default however may run 64
bit binaries.
So I am fairly certain that you can run it completely in 32 bit mode
(hence their 'universal' binaries).

That said, I definitely think the best route is to run 64 bits at all
times if possible.

Darcy Laycock

unread,
Jul 16, 2010, 9:39:31 AM7/16/10
to rvm (Ruby Version Manager)
yehp, the default kernel mode (primarily for compatibility mode) is
i386 on Snow Leopard.
To force 64-bit, you need to hold down 6 and 4 when you boot. Though,
the 32-bit kernel can
still run 64-bit programs (as is evident from what has been discussed
here).

I've just committed some changes - could you guys try compiling a ruby
without the
rvm_archflags variable set in your rvmrc to see if it's better
behaved? it now
checks both hw.optional.x86_64 and hw.cpu64bits_capable to try and
determine the default
behavior.

Thanks,
-- Darcy

Chad Woolley

unread,
Jul 16, 2010, 10:14:36 AM7/16/10
to rubyversi...@googlegroups.com
On Fri, Jul 16, 2010 at 6:39 AM, Darcy Laycock <darcy....@gmail.com> wrote:
> yehp, the default kernel mode (primarily for compatibility mode) is
> i386 on Snow Leopard.
> To force 64-bit, you need to hold down 6 and 4 when you boot.

This does not work on older macbooks like mine.

Darcy Laycock

unread,
Jul 16, 2010, 10:20:48 AM7/16/10
to rubyversi...@googlegroups.com
The changes or holding down 6 and 4?

--
Please visit http://rvm.beginrescueend.com/ for documentation on rvm.
Please visit https://www.pivotaltracker.com/projects/26822 to see what is being worked on currently.

You received this message because you are subscribed to the Google
Groups "rvm (Ruby Version Manager)" group.
To post to this group, send email to rubyversi...@googlegroups.com
To unsubscribe from this group, send email to
rubyversionmana...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyversionmanager?hl=en



--

Darcy Laycock

Web Developer
Perth, Western Australia
Mobile: 0433 182 229
Email: su...@sutto.net
Web: http://sutto.net/
Reply all
Reply to author
Forward
0 new messages