Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Last active December 15, 2015 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdoye/5255285 to your computer and use it in GitHub Desktop.
Save nicdoye/5255285 to your computer and use it in GitHub Desktop.
Compiling 32-bit ruby (MIR) on 64-bit RHEL 6

Building 32-bit ruby on 64-bit RHEL 6

Introduction

Will presumably work for many RHEL "derivatives", like CentOS, Oracle Enterprise Linux, Scientific Linux as well as "similar enough" versions of Fedora.

There is a use case for 32-bit ruby as set out in this G+ post

Set up yum

First allow 32-bit libraries to be installed. From RH KB 3628

Edit /etc/yum.conf and insert a line in the main section:

multilib_policy=all

Download the source

Don't forget to check the sum of the file.

wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
md5sum -b ruby-2.0.0-p0.tar.gz

Untar it and go into the directory.

Install various components

Including work by Henry Schräpler

yum will download 32-bit versions if needed, even if you already have the 64-bit versions. Note that this list is not exhaustive; it allowed me to build a working version on an EC2 image. You may also add in ncurses, bison ... things for Ruby/Tk

yum -y install openssl openssl-devel gcc glibc-devel libgcc gdbm gdbm-devel readline readline-devel libffi libffi-devel zlib zlib-devel

Configure

Including work by Henry Schräpler

CFLAGS="-m32" LDFLAGS="-m32" CXXFLAGS="-m32" ./configure --target=i686-unknown-linux-gnu --prefix=/opt/ruby-2.0.0-p0-m32-001 && make && make install

Test

Check it's a 32-bit ruby and that openssl is there. (Not much of a test).

file /opt/ruby-2.0.0-p0-m32-001/bin/ruby
ldd /opt/ruby-2.0.0-p0-m32-001/lib/ruby/2.0.0/i686-linux/openssl.so
/opt/ruby-2.0.0-p0-m32-001/bin/ruby --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment