jawckey has asked for the wisdom of the Perl Monks concerning the following question:

I have a 32 bit perl installed on a X86_64 bit RHEL/5 linux box. Do not know how it ended up 32 bit there but I have it there. I need to build some additional modules now. So is there a way to build 32 bit perl stuff on a 64 bit box/kernel? Or do I have to first install 32 bit linux and then build things there to get 32 bit things. Googled and goof'led around but got no where. Any help/tips are appreciated. Wonder who doesn't appreaciate tips! regards

Replies are listed 'Best First'.
Re: 32 bit perl
by plobsing (Friar) on Nov 17, 2008 at 05:01 UTC

    A few things come to mind:

    • make sure gcc is always invoked using the -m32 option or equivalent (see the manpage)
    • make sure you are linking against 32-bit versions of any libraries you depend on
    • make sure you have 32-bit versions of any libraries you depend on (including headers)

    With luck, points 1 and 2 should be handled automagically by perl, EU::MM/M::B/etc, and/or gcc

      I am new to this web site and found it quite hard to find and go back to where I posted my original question and see what others posted against it. I ended up doing 'Super Search' for the subject line to locate them, and then click on those to see what is posted in response. I then struggled to find out how to post this back. Hope this goes out. Sigh! Thanks a lot for your responses. Ya, there is a -m32 vs -m64 option to gcc. However in the generated Makefile I see lot of things like X86_64 etc etc which look like places where things get installed. I don't think just by changing compile option from -m64 to -m32 will do it everything right. So thought of asking around. Will try more. regards
        I'm pretty new here as well and I have found the Perlmonks FAQ to be helpful. Perhaps you could not find your comment due to the way that new posts are processed. Take a look at Why can't I see my post? for an explanation. If you want to find your write ups the best place will be your home node jawckey. The number next to Writeups: is a link to all your writeups.
Re: 32 bit perl
by graff (Chancellor) on Nov 17, 2008 at 04:14 UTC
    Last time I checked, an intel-based (or intel-like) 64-bit cpu is able to run 32-bit binaries, because (I think) all the 32 bit instructions are available on the 64-bit chips. It might not be optimal, but it should work.

    Have you tried it and found out that something didn't work? If so, what actually happened?

    UPDATE: Sorry, I just realized I was not answering your question. Since you are on a linux system, your compiler is gcc, which should be able to compile binaries as 32-bit or whatever you want. But I'm hoping someone with a stronger background in gcc will give better advice -- I never got very far in learning the zillions of gcc options and controls. Again, it may help to try something, and if it doesn't work, show how it fails. (Googling specific error messages can often lead to useful insights.)

Re: 32 bit perl
by DrHyde (Prior) on Nov 17, 2008 at 10:25 UTC

    You always need to build modules to match the particular build of perl you're interested in. This applies equally to endianness, word length, threading, etc. The standard way to build a module and have everything magically work is:

    $ /path/to/perl Makefile.PL $ make $ make test $ make install
Re: 32 bit perl
by weismat (Friar) on Nov 17, 2008 at 09:22 UTC
    I checked on my RHEL5 X86_64 box and the "standard" perl (/usr/bin/perl) is build with 64 bytes.
    Nevertheless the compiler switch for gcc is -m32 to build the 32 bit version.
    So this needs to be changed in the make file for the module.