December, 2011

8
Dec 11

Compiling 32bit Ruby on a 64bit machine

We achieved a reasonable improvement in out test suite run time (~10%) by running a 32bit Ruby 1.8.7 rather than 64bit. I’m not sure why. These instructions are for F16.

You need some 32bit libraries:

yum install glibc-devel.i686 openssl-devel.i686 zlib-devel.i686

Unfortunately, Ruby 1.8.7-p352 doesn’t seem to enjoy to being cross-compiled (at least on my setup). The patch for bug #5108 fixes this problem for me.

Next, configure the build. The most basic configure command that you need is probably something like this:

CFLAGS="-m32 -O2" LDFLAGS="-m32" CXXFLAGS="-m32" ./configure --prefix=/usr/local/ruby-1.8.7 --target=i686-unknown-linux-gnu

After building and installing, you will probably want to install RubyGems again and will need to rebuild any C extensions you use. Of course, building them will require any associated 32bit libraries. The mysql gem is slightly trickier than some:

yum install mysql-devel.i686
gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config