I recently needed to run 32-bit Perl 5.8 on a 64-bit Centos 6 system.
Initial research suggested that
perlbrew would be the easiest
way of achieving this, but I wasn't able to find a walkthrough.
Here's what worked for me...
1. Install perlbrew
You'll need to install perlbrew from the CPAN, and it has a load of
dependencies. The wonderful
App::cpanminus makes
this experience as painless as possible, so I installed it before
moving onto perlbrew itself.
$ sudo yum install perl-CPAN
$ sudo cpan App::cpanminus
$ sudo cpanm install App::perlbrew
1. Initialise perlbrew
Next, get perlbrew ready for use. Pay attention to the output of the
init step - it will direct you to make a change to your shell configuration.
$ perlbrew init
$ perlbrew install-patchperl
2. Install 32-bit Libraries
Installing these two packages was enough to build a 32-bit perl core.
If you're building additional XS modules against the 32-bit perl, they
may require other 32-bit libraries to be installed.
$ sudo yum install glibc-devel.i686 libgcc.i686
3. Build A Perl
$ perlbrew install 5.8.9 -Accflags="-m32 -march=i686" -Aldflags="-m32 -march=i686" -Alddlflags="-shared -m32 -march=i686"
Fetching perl-5.8.9 as /home/zts/perl5/perlbrew/dists/perl-5.8.9.tar.bz2
Installing /home/zts/perl5/perlbrew/build/perl-5.8.9 into ~/perl5/perlbrew/perls/perl-5.8.9
This could take a while. You can run the following command on another shell to track the status:
tail -f ~/perl5/perlbrew/build.perl-5.8.9.log
perl-5.8.9 is successfully installed.
That's all there is to it, though the result isn't quite perfect.
While the above invocation builds a 32-bit perl, it doesn't override
the system's archname - so the resulting @INC looks like this:
@INC:
/home/zts/perl5/perlbrew/perls/perl-5.8.9/lib/5.8.9/x86_64-linux
/home/zts/perl5/perlbrew/perls/perl-5.8.9/lib/5.8.9
/home/zts/perl5/perlbrew/perls/perl-5.8.9/lib/site_perl/5.8.9/x86_64-linux
/home/zts/perl5/perlbrew/perls/perl-5.8.9/lib/site_perl/5.8.9
.
For my purposes, this is simply an aesthetic issue - the
x86_64-linux directories contain 32-bit shared objects - and I chose
not to spend any more time perfecting it. If you happen to know which
option(s) I'm missing, please leave a comment below.