Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Can threaded and non threaded perl share the same compiled modules?

by EvdB (Deacon)
on Jun 12, 2003 at 09:38 UTC ( [id://265310]=perlquestion: print w/replies, xml ) Need Help??

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

I want to play with perl threads but I do not want to muck around with my standard perl installation - after all I need to do my job.

If I build a verion of perl with threads (in a separate directory in my home dir) can the threaded and non threaded perl share the same modules? Obviously the pure perl ones will be the same - it is the ones that require compilation that i am wondereing about. Should I create a separate module tree for the threaded perl?

Many thanks.

--tidiness is the memory loss of environmental mnemonics

  • Comment on Can threaded and non threaded perl share the same compiled modules?
  • Download Code

Replies are listed 'Best First'.
Re: Can threaded and non threaded perl share the same compiled modules?
by BrowserUk (Patriarch) on Jun 12, 2003 at 12:18 UTC

    I think that in the absence of an extensive test that showed the contrary, you have to assume that compiled XS modules must be compiled seperately for threaded and non-threaded use.

    From the top of the threads module

    Having threads support requires all of Perl and all of the XS modules +in the Perl installation to be rebuilt, it is not just a question of addi +ng the threads module. (In other words, threaded and non-threaded Perls are binary incompatible.)

    That seems pretty definitive. I would think that any case where you could get away with the same binary for both should be classified as "more luck that judgement":)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Re: Can threaded and non threaded perl share the same compiled modules?
by PodMaster (Abbot) on Jun 12, 2003 at 10:04 UTC
    I don't think so but I cannot be sure since i can't test, so all I can say is try it out.

    I'd test, but I cannot build perl-5.8.x on win32 without threads (nobody seems to be smoking that config on win32) which reminds me we need more smoke testers for windows. Grab Test::Smoke and go wild. We can always use more smoke testers.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Can threaded and non threaded perl share the same compiled modules?
by meredith (Friar) on Jun 12, 2003 at 11:56 UTC
    I do know of people who keep a separate perl install(s) in their home directory for testing. I think you can find the info in the INSTALL file. Here's my suggestion: When you configure, add the system-wide /usr/lib/perl5/site_perl to your lib path to include any PP modules you have installed. It will just ignore(overlook) any compiled modules due to differing build signatures. When you add modules, they'll go in your 'private' lib directories and the existing PP with rebuilt XS and new PP will live happily. I believe this will achieve what you want.

    HTH

    Update: Ah, an oversight! BrowserUk stated what you wanted to know, and above is the idea to minimize losses. Here's what I meant by build signature: Slackware 9.0 ships without threading, pretty vanilla. It puts it the compiled parts in a directory, i386-linux, that is a short description of the major build options. I rebuilt my perl, now my compiled modules go into i686-linux-thread-multi-64all-ld (yeah, I picked a lot of options ;) Maybe this describes what I was trying to say better.

    mhoward - at - hattmoward.org
Re: Can threaded and non threaded perl share the same compiled modules?
by Zaxo (Archbishop) on Jun 12, 2003 at 15:09 UTC
    perlguts describes how the pTHX_ macro changes the number of arguments declared for public functions, depending on whether threading is enabled. There is no binary compatibility, the linker will choke.

    After Compline,
    Zaxo

Re: Can threaded and non threaded perl share the same compiled modules?
by EvdB (Deacon) on Jun 12, 2003 at 15:05 UTC
    The answer, as pointed out above, is that the compiled modules cannot be shared.

    What I ended up doing was passing PREFIX=~/perl to the initial config program and also to CPAN. This has lead to a completely separate install for the threaded perl.

    As a convenience I have linked /usr/local/bin/tperl to /home/evdb/perl/bin/perl so that it is easy in scripts to change the perl version that is used.

    Pity that DBI doesn't trust itself with threads, it rather removed the point of having them for me, I'll go the trusty forking route instead....

    Oh, I was running 5.8.0, 5.6.1 indeed!

    --tidiness is the memory loss of environmental mnemonics

Re: Can threaded and non threaded perl share the same compiled modules?
by gmpassos (Priest) on Jun 12, 2003 at 14:56 UTC
    You said that need to install/compile Perl-5.8.0 to have threads, and want to share the modules with the Perl without threads. So, probably you have Perl-5.6.1 (or less) and and want make it work with Perl-5.8.0. What you are missing is that binarys of Perl-5.6.1 doesn't work with binarys of Perl-5.8.0! So, you can't share any module of Perl-5.6.1 with Perl-5.8.0, specially with XS.

    ** Note that threads are only stable at Perl 5.8.0+. Don't compile old versions to use it.

    Graciliano M. P.
    "The creativity is the expression of the liberty".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://265310]
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-26 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found