6

I have a 64-bit CentOS 6 system running a custom-built version of Perl 5.12.5, that is build for 32-bits. (Alas, this is because we are using the same RPMs for 32-bit and 64-bit systems.)

When I build XS modules (e.g. JSON::XS) on the server, it fails because it's building 64-bit libraries. I get an error like

Can't load '.cpanm/work/1370279501.28897/JSON-XS-2.33/blib/arch
/auto/JSON/XS/XS.so' for module JSON::XS: .cpanm/work/137027950
1.28897/JSON-XS-2.33/blib/arch/auto/JSON/XS/XS.so: wrong ELF class: ELFCLASS64
at /opt/perl/lib/5.12.5/i686-linux/DynaLoader.pm line 200.

I've tried setting the CFLAGS variable to "-m32-bit" but it does not work.

What do I need to do to compile XS modules properly? Ideally, I'd like something that works with cpanminus but can use cpan or cpanplus if need be.

Rob
  • 781
  • 5
  • 19
  • Odd. It should use the exact same settings that were used to build Perl. – ikegami Jun 03 '13 at 18:55
  • @ikegami The Perl was build on a 32-bit machine, so perhaps the settings didn't need to be made explicit. – Rob Jun 03 '13 at 19:05
  • Fix your broken Perl (i.e. install it properly) to solve your problem. – ikegami Jun 03 '13 at 19:48
  • @ikegami Can you be more specific? How is it not installed properly? It's in the PATH, the PERL5LIB variable is set correctly, as are local-lib variables set properly. The CPAN and CPANPLUS modules are properly configured and worked fine on the 32-bit system. – Rob Jun 04 '13 at 07:54
  • You said you built it on a different machine than the one on which it's installed, yet `perl` doesn't currently have a cross-compiler. – ikegami Jun 04 '13 at 08:26
  • @ikegami So what is broken about the Perl? What do I need to do to fix it? – Rob Jun 04 '13 at 08:36
  • The fact that you can't install modules. Install it properly. Installation instructions are quite simple, and are found in the INSTALL file. But you already know that if you've built a custom Perl!? – ikegami Jun 04 '13 at 16:35
  • The version of Perl is installed properly. From what I gather, it may not have been _compiled_ properly. – Rob Jun 05 '13 at 12:55
  • You already admitted you didn't install it properly. There's no indication it wasn't compiled properly. What game are you playing??? – ikegami Jun 05 '13 at 14:11
  • In what way did I admit that it wasn't installed properly? – Rob Jun 06 '13 at 08:02
  • Already asked and answered. You said you built it on a different machine than the one on which it's installed. – ikegami Jun 06 '13 at 16:28

2 Answers2

2

Perl's build system (in particular, ExtUtils::MakeMaker and ExtUtils::CBuilder) assumes the compilation platform that was used to build that perl is also usable runtime platform. Evidently that's not the case here.

The obvious solution is to compile perl with options that would result in the same executables on both toolchains. This is rather tricky.

Leon Timmermans
  • 30,029
  • 2
  • 61
  • 110
1

Turns out this answer works for me:

wwalker $ PERL_MM_OPT='CCFLAGS="-m32 -march=i686" LDDLFLAGS="-m32 -march=i686"' /opt/depot/perl-5.8.5/bin/perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support enabled

cpan> install DBIx::Class
Wayne Walker
  • 2,316
  • 3
  • 23
  • 25